diff -Nru openimageio-1.3.13/CHANGES openimageio-1.3.14/CHANGES --- openimageio-1.3.13/CHANGES 2014-04-03 06:08:57.000000000 +0000 +++ openimageio-1.3.14/CHANGES 2014-05-19 20:19:01.000000000 +0000 @@ -1,5 +1,18 @@ Changes: +Release 1.3.14 (19 May 2014 -- compared to 1.3.13) +-------------------------------------------------- +* OpenEXR output: More robust with certain malformed metadata. (#841) (1.4.6) +* Rename the string_ref class to string_view. (This is unused in OIIO, it + is for compatibility with OSL.) +* Build fixes on Linux when using BUILDSTATIC=1. +* Add round_to_multiple_of_pow2 to fmath.h +* Add STOP_ON_WARNING option to the top level Makeile wrapper. +* Add documentation on the Python binding for IBA::cut. +* oiiotool --over and --zover now set the output image's display window to + the union of the inputs' display window, rather than to the foreground. + + Release 1.3.13 (2 Apr 2014 -- compared to 1.3.12) ------------------------------------------------- * Bug fix to string_ref::c_str(). diff -Nru openimageio-1.3.13/CMakeLists.txt openimageio-1.3.14/CMakeLists.txt --- openimageio-1.3.13/CMakeLists.txt 2014-04-03 06:08:57.000000000 +0000 +++ openimageio-1.3.14/CMakeLists.txt 2014-05-19 20:19:01.000000000 +0000 @@ -3,7 +3,7 @@ # Release version of the library set (OIIO_VERSION_MAJOR 1) set (OIIO_VERSION_MINOR 3) -set (OIIO_VERSION_PATCH 13) +set (OIIO_VERSION_PATCH 14) set (OIIO_VERSION_RELEASE_TYPE "") # "dev", "betaX", "RCY", "" cmake_minimum_required (VERSION 2.6) @@ -125,6 +125,12 @@ set (PYLIB_INCLUDE_SONAME OFF CACHE BOOL "If ON, soname/soversion will be set for Python module library") set (PYLIB_LIB_PREFIX OFF CACHE BOOL "If ON, prefix the Python module with 'lib'") +if (BUILDSTATIC AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + # On Linux, the lack of -fPIC when building static libraries seems + # incompatible with the dynamic library needed for the Python bindings. + set (USE_PYTHON OFF) +endif() + if (NOTHREADS) message (STATUS "NO THREADS!") add_definitions ("-DNOTHREADS=1") diff -Nru openimageio-1.3.13/debian/changelog openimageio-1.3.14/debian/changelog --- openimageio-1.3.13/debian/changelog 2014-04-12 03:25:41.000000000 +0000 +++ openimageio-1.3.14/debian/changelog 2014-05-20 05:30:08.000000000 +0000 @@ -1,3 +1,9 @@ +openimageio (1.3.14-0irie1~trusty1) trusty; urgency=medium + + * New upstream release + + -- IRIE Shinsuke Tue, 20 May 2014 14:29:30 +0900 + openimageio (1.3.13-0irie1~trusty1) trusty; urgency=medium * New upstream release diff -Nru openimageio-1.3.13/INSTALL openimageio-1.3.14/INSTALL --- openimageio-1.3.13/INSTALL 2014-04-03 06:08:57.000000000 +0000 +++ openimageio-1.3.14/INSTALL 2014-05-19 20:19:01.000000000 +0000 @@ -22,9 +22,10 @@ ------------------------------------- The following dependencies must be installed to build the core of -OpenImageIO: Boost, libjpeg, libtiff, libpng and OpenEXR. These can be installed -using the standard package managers on your system. Optionally, -to build the image viewing tools, you will need Qt, OpenGL, and GLEW. +OpenImageIO: Boost, libjpeg, libtiff, libpng and OpenEXR. These can be +installed using the standard package managers on your system. +Optionally, to build the image viewing tools, you will need Qt, OpenGL, +and GLEW. On OS X, these dependencies can be installed using MacPorts or Homebrew. After installation of either of these package installers, @@ -68,19 +69,36 @@ Additionally, a few helpful modifiers alter some build-time options: make VERBOSE=1 ... Show all compilation commands + make STOP_ON_WARNING=0 Do not stop building if compiler warns make EMBEDPLUGINS=0 ... Don't compile the plugins into libOpenImageIO make USE_OPENGL=0 ... Skip anything that needs OpenGL make USE_QT=0 ... Skip anything that needs Qt make MYCC=xx MYCXX=yy ... Use custom compilers make FORCE_OPENGL_1=1 ... Force iv to use OpenGL's fixed pipeline - make USE_TBB=0 ... Don't use TBB - make USE_PYTHON=1 ... Build the Python binding + make USE_PYTHON=0 ... Don't build the Python binding make BUILDSTATIC=1 ... Build static library instead of shared make LINKSTATIC=1 ... Link with static external libraries when possible make SOVERSION=nn ... Include the specifed major version number in the shared object metadata make NAMESPACE=name Wrap everything in another namespace +The command 'make help' will list all possible options. + +You can also ignore the top level Makefile wrapper, and instead use +CMake directly: + + mkdir build + cd build + cmake .. + +If the compile stops because of warnings, try again with + make nuke + make STOP_ON_WARNING=0 +or, if you are using CMake directly, + cd build + cmake -DSTOP_ON_WARNING=0 .. + + Building on Windows diff -Nru openimageio-1.3.13/Makefile openimageio-1.3.14/Makefile --- openimageio-1.3.13/Makefile 2014-04-03 06:08:57.000000000 +0000 +++ openimageio-1.3.14/Makefile 2014-05-19 20:19:01.000000000 +0000 @@ -143,6 +143,10 @@ MY_CMAKE_FLAGS += -DBOOST_ROOT:STRING=${BOOST_HOME} endif +ifneq (${STOP_ON_WARNING},) +MY_CMAKE_FLAGS += -DSTOP_ON_WARNING:BOOL=${STOP_ON_WARNING} +endif + ifneq (${BUILDSTATIC},) MY_CMAKE_FLAGS += -DBUILDSTATIC:BOOL=${BUILDSTATIC} endif @@ -296,6 +300,7 @@ @echo "" @echo "Helpful modifiers:" @echo " make VERBOSE=1 ... Show all compilation commands" + @echo " make STOP_ON_WARNING=0 Do not stop building if compiler warns" @echo " make SOVERSION=nn ... Include the specifed major version number " @echo " in the shared object metadata" @echo " make NAMESPACE=name Wrap everything in another namespace" Binary files /tmp/5BUPkhC9U1/openimageio-1.3.13/src/doc/openimageio.pdf and /tmp/ywUiEMjGZQ/openimageio-1.3.14/src/doc/openimageio.pdf differ diff -Nru openimageio-1.3.13/src/doc/openimageio.tex openimageio-1.3.14/src/doc/openimageio.tex --- openimageio-1.3.13/src/doc/openimageio.tex 2014-04-03 06:08:57.000000000 +0000 +++ openimageio-1.3.14/src/doc/openimageio.tex 2014-05-19 20:19:01.000000000 +0000 @@ -91,7 +91,7 @@ \date{{\large %Editor: Larry Gritz \\[2ex] Date: 14 Nov 2013 -\\ (with corrections, 2 Apr 2014) +\\ (with corrections, 19 May 2014) }} diff -Nru openimageio-1.3.13/src/doc/pythonbindings.tex openimageio-1.3.14/src/doc/pythonbindings.tex --- openimageio-1.3.13/src/doc/pythonbindings.tex 2014-04-03 06:08:57.000000000 +0000 +++ openimageio-1.3.14/src/doc/pythonbindings.tex 2014-05-19 20:19:01.000000000 +0000 @@ -1636,6 +1636,23 @@ \apiend +\apiitem{bool ImageBufAlgo.{\ce cut} (dst, src, roi=ROI.All, nthreads=0)} +\index{ImageBufAlgo!cut} \indexapi{cut} +\NEW % 1.4 +Reset {\cf dst} to be the specified region of {\cf src}, but moved so +that the resulting new image has its pixel data at the image plane origin. + +\smallskip +\noindent Examples: +\begin{code} + # Set B to be the lower left 200x100 region of A, moved to the origin + A = ImageBuf ("a.tif") + B = ImageBuf() + ImageBufAlgo.cut (B, A, ROI(0,200,380,480)) +\end{code} +\apiend + + \apiitem{bool ImageBufAlgo.{\ce paste} (dst, xbegin, ybegin, zbegin, chbegin, \\ \bigspc\bigspc src, ROI srcroi=ROI.All, nthreads=0)} diff -Nru openimageio-1.3.13/src/include/CMakeLists.txt openimageio-1.3.14/src/include/CMakeLists.txt --- openimageio-1.3.13/src/include/CMakeLists.txt 2014-04-03 06:08:57.000000000 +0000 +++ openimageio-1.3.14/src/include/CMakeLists.txt 2014-05-19 20:19:01.000000000 +0000 @@ -3,7 +3,7 @@ imagebuf.h imagebufalgo.h imagebufalgo_util.h imagecache.h imageio.h optparser.h osdep.h paramlist.h plugin.h - refcnt.h string_ref.h strutil.h sysutil.h + refcnt.h string_ref.h string_view.h strutil.h sysutil.h texture.h thread.h timer.h tinyformat.h typedesc.h ustring.h varyingref.h ) diff -Nru openimageio-1.3.13/src/include/fmath.h openimageio-1.3.14/src/include/fmath.h --- openimageio-1.3.13/src/include/fmath.h 2014-04-03 06:08:57.000000000 +0000 +++ openimageio-1.3.14/src/include/fmath.h 2014-05-19 20:19:01.000000000 +0000 @@ -222,7 +222,7 @@ -/// Round up to the next even multiple of m. +/// Round up to the next whole multiple of m. /// inline int round_to_multiple (int x, int m) @@ -231,6 +231,17 @@ } + +/// Round up to the next whole multiple of m, for the special case where +/// m is definitely a power of 2 (somewhat simpler than the more general +/// round_to_multiple). +inline int +round_to_multiple_of_pow2 (int x, int m) +{ + return (x + m - 1) & (~(m-1)); +} + + /// Return true if the architecture we are running on is little endian /// diff -Nru openimageio-1.3.13/src/include/string_ref.h openimageio-1.3.14/src/include/string_ref.h --- openimageio-1.3.13/src/include/string_ref.h 2014-04-03 06:08:57.000000000 +0000 +++ openimageio-1.3.14/src/include/string_ref.h 2014-05-19 20:19:01.000000000 +0000 @@ -1,346 +1,7 @@ -/* - Copyright 2014 Larry Gritz and the other authors and contributors. - All Rights Reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the software's owners nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - (This is the Modified BSD License) -*/ - +// Back-compatible temporary inclusion of string_view.h #pragma once -#include -#include -#include -#include -#include - -#include "version.h" -#include "export.h" - - -OIIO_NAMESPACE_ENTER { - - -/// string_ref : a non-owning, non-copying, non-allocating reference to a -/// sequence of characters. It encapsulates both a character pointer and a -/// length. -/// -/// A function that takes a string input (but does not need to alter the -/// string in place) may use a string_ref parameter and accept input that -/// is any of char* (C string), string literal (constant char array), a -/// std::string (C++ string), or OIIO ustring. For all of these cases, no -/// extra allocations are performed, and no extra copies of the string -/// contents are performed (as they would be, for example, if the function -/// took a const std::string& argument but was passed a char* or string -/// literal). -/// -/// Furthermore, a function that returns a copy or a substring of one of its -/// inputs (for example, a substr()-like function) may return a string_ref -/// rather than a std::string, and thus generate its return value without -/// any allocation or copying. Upon assignment to a std::string or ustring, -/// it will properly auto-convert. -/// -/// There are two important caveats to using this class: -/// 1. The string_ref merely refers to characters owned by another string, -/// so the string_ref may not be used outside the lifetime of the string -/// it refers to. Thus, string_ref is great for parameter passing, but -/// it's not a good idea to use a string_ref to store strings in a data -/// structure (unless you are really sure you know what you're doing). -/// 2. Because the run of characters that the string_ref refers to may not -/// be 0-terminated, it is important to distinguish between the data() -/// method, which returns the pointer to the characters, and the c_str() -/// method, which is guaranteed to return a valid C string that is -/// 0-terminated. Thus, if you want to pass the contents of a string_ref -/// to a function that expects a 0-terminated string (say, fopen), you -/// must call fopen(my_string_ref.c_str()). Note that the usual case -/// is that the string_ref does refer to a 0-terminated string, and in -/// that case c_str() returns the same thing as data() without any extra -/// expense; but in the rare case that it is not 0-terminated, c_str() -/// will incur extra expense to internally allocate a valid C string. -/// - - -class OIIO_API string_ref { -public: - typedef char charT; - typedef charT value_type; - typedef const charT* pointer; - typedef const charT* const_pointer; - typedef const charT& reference; - typedef const charT& const_reference; - typedef const_pointer const_iterator; - typedef const_iterator iterator; - typedef std::reverse_iterator const_reverse_iterator; - typedef const_reverse_iterator reverse_iterator; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef std::char_traits traits; - static const size_type npos = ~size_type(0); - - /// Default ctr - string_ref () { init(NULL,0); } - /// Copy ctr - string_ref (const string_ref ©) { - init (copy.m_chars, copy.m_len); - } - /// Construct from char* and length. - string_ref (const charT *chars, size_t len) { init (chars, len); } - /// Construct from char*, use strlen to determine length. - string_ref (const charT *chars) { - init (chars, chars ? strlen(chars) : 0); - } - /// Construct from std::string. - string_ref (const std::string &str) { init (str.data(), str.size()); } - - std::string str() const { - return (m_chars ? std::string(m_chars,m_len) : std::string()); - } - - /// Explicitly request a 0-terminated string. USUALLY, this turns out to - /// be just data(), with no significant added expense. But in the more - /// rare case that the string_ref represetns a non-0-terminated - /// substring, it will force an allocation and copy underneath. - const char * c_str() const; - - // assignments - string_ref& operator= (const string_ref ©) { - init (copy.data(), copy.length()); - return *this; - } - - operator std::string() const { return str(); } - - // iterators - const_iterator begin() const { return m_chars; } - const_iterator end() const { return m_chars + m_len; } - const_iterator cbegin() const { return m_chars; } - const_iterator cend() const { return m_chars + m_len; } - const_reverse_iterator rbegin() const { return const_reverse_iterator (end()); } - const_reverse_iterator rend() const { return const_reverse_iterator (begin()); } - const_reverse_iterator crbegin() const { return const_reverse_iterator (end()); } - const_reverse_iterator crend() const { return const_reverse_iterator (begin()); } - - // capacity - size_type size() const { return m_len; } - size_type length() const { return m_len; } - size_type max_size() const { return m_len; } - bool empty() const { return m_len == 0; } - - // element access - const charT& operator[] (size_type pos) const { return m_chars[pos]; } - const charT& at (size_t pos) const { - if (pos >= m_len) - throw (std::out_of_range ("OpenImageIO::string_ref::at")); - return m_chars[pos]; - } - const charT& front() const { return m_chars[0]; } - const charT& back() const { return m_chars[m_len-1]; } - const charT* data() const { return m_chars; } - - // modifiers - void clear() { init(NULL,0); } - void remove_prefix(size_type n) { - if (n > m_len) - n = m_len; - m_chars += n; - m_len -= n; - } - void remove_suffix(size_type n) { - if (n > m_len) - n = m_len; - m_len -= n; - } - - string_ref substr (size_type pos, size_type n=npos) const { - if (pos > size()) - return string_ref(); // start past end -> return empty - if (n == npos || pos + n > size()) - n = size() - pos; - return string_ref (data() + pos, n); - } - - int compare (string_ref x) const { - const int cmp = std::char_traits::compare (m_chars, x.m_chars, (std::min)(m_len, x.m_len)); - return cmp != 0 ? cmp : int(m_len - x.m_len); - // Equivalent to: - // cmp != 0 ? cmp : (m_len == x.m_len ? 0 : (m_len < x.m_len ? -1 : 1)); - } - -#if 0 - // Do these later if anybody needs them - bool starts_with(string_ref x) const; - bool ends_with(string_ref x) const; -#endif - - /// Find the first occurrence of substring s in *this, starting at - /// position pos. - size_type find (string_ref s, size_t pos=0) const { - if (pos > size()) - pos = size(); - const_iterator i = std::search (this->cbegin()+pos, this->cend(), - s.cbegin(), s.cend(), traits::eq); - return i == this->cend() ? npos : std::distance (this->cbegin(), i); - } - - /// Find the first occurrence of character c in *this, starting at - /// position pos. - size_type find (charT c, size_t pos=0) const { - if (pos > size()) - pos = size(); - const_iterator i = std::find_if (this->cbegin()+pos, this->cend(), - traits_eq(c)); - return i == this->cend() ? npos : std::distance (this->cbegin(), i); - } - - /// Find the last occurrence of substring s *this, but only those - /// occurrences earlier than position pos. - size_type rfind (string_ref s, size_t pos=npos) const { - if (pos > size()) - pos = size(); - const_reverse_iterator b = this->crbegin()+(size()-pos); - const_reverse_iterator e = this->crend(); - const_reverse_iterator i = std::search (b, e, s.crbegin(), s.crend(), traits::eq); - return i == e ? npos : (reverse_distance(this->crbegin(),i) - s.size() + 1); - } - - /// Find the last occurrence of character c in *this, but only those - /// occurrences earlier than position pos. - size_type rfind (charT c, size_t pos=npos) const { - if (pos > size()) - pos = size(); - const_reverse_iterator b = this->crbegin()+(size()-pos); - const_reverse_iterator e = this->crend(); - const_reverse_iterator i = std::find_if (b, e, traits_eq(c)); - return i == e ? npos : reverse_distance (this->crbegin(),i); - } - - size_type find_first_of (charT c, size_t pos=0) const { return find (c, pos); } - - size_type find_last_of (charT c, size_t pos=npos) const { return rfind (c, pos); } - - size_type find_first_of (string_ref s) const { - const_iterator i = std::find_first_of (this->cbegin(), this->cend(), - s.cbegin(), s.cend(), traits::eq); - return i == this->cend() ? npos : std::distance (this->cbegin(), i); - } - - size_type find_last_of (string_ref s) const { - const_reverse_iterator i = std::find_first_of (this->crbegin(), this->crend(), - s.cbegin(), s.cend(), traits::eq); - return i == this->crend() ? npos : reverse_distance (this->crbegin(), i); - } - - size_type find_first_not_of (string_ref s) const { - const_iterator i = find_not_of (this->cbegin(), this->cend(), s); - return i == this->cend() ? npos : std::distance (this->cbegin(), i); - } - - size_type find_first_not_of (charT c) const { - for (const_iterator i = this->cbegin(); i != this->cend(); ++i) - if (! traits::eq (c, *i)) - return std::distance (this->cbegin(), i); - return npos; - } - - size_type find_last_not_of (string_ref s) const { - const_reverse_iterator i = find_not_of (this->crbegin(), this->crend(), s); - return i == this->crend() ? npos : reverse_distance (this->crbegin(), i); - } - - size_type find_last_not_of (charT c) const { - for (const_reverse_iterator i = this->crbegin(); i != this->crend(); ++i) - if (! traits::eq (c, *i)) - return reverse_distance (this->crbegin(), i); - return npos; - } - -private: - const charT * m_chars; - size_t m_len; - - void init (const charT *chars, size_t len) { - m_chars = chars; - m_len = len; - } - - template - size_type reverse_distance (r_iter first, r_iter last) const { - return m_len - 1 - std::distance (first, last); - } - - template - iter find_not_of (iter first, iter last, string_ref s) const { - for ( ; first != last ; ++first) - if (! traits::find (s.data(), s.length(), *first)) - return first; - return last; - } - - class traits_eq { - public: - traits_eq (charT ch) : ch(ch) {} - bool operator () (charT val) const { return traits::eq (ch, val); } - charT ch; - }; - -}; - - - -inline bool operator== (string_ref x, string_ref y) { - return x.size() == y.size() ? (x.compare (y) == 0) : false; -} - -inline bool operator!= (string_ref x, string_ref y) { - return x.size() == y.size() ? (x.compare (y) != 0) : true; -} - -inline bool operator< (string_ref x, string_ref y) { - return x.compare(y) < 0; -} - -inline bool operator> (string_ref x, string_ref y) { - return x.compare(y) > 0; -} - -inline bool operator<= (string_ref x, string_ref y) { - return x.compare(y) <= 0; -} - -inline bool operator>= (string_ref x, string_ref y) { - return x.compare(y) >= 0; -} - - +#include "string_view.h" -// Inserter -inline std::ostream& operator<< (std::ostream& out, const string_ref& str) { - if (out.good()) - out.write (str.data(), str.size()); - return out; -} -} OIIO_NAMESPACE_EXIT diff -Nru openimageio-1.3.13/src/include/string_view.h openimageio-1.3.14/src/include/string_view.h --- openimageio-1.3.13/src/include/string_view.h 1970-01-01 00:00:00.000000000 +0000 +++ openimageio-1.3.14/src/include/string_view.h 2014-05-19 20:19:01.000000000 +0000 @@ -0,0 +1,352 @@ +/* + Copyright 2014 Larry Gritz and the other authors and contributors. + All Rights Reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the software's owners nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + (This is the Modified BSD License) +*/ + + +#pragma once + +#include +#include +#include +#include +#include + +#include "version.h" +#include "export.h" + + +OIIO_NAMESPACE_ENTER { + + +/// string_view : a non-owning, non-copying, non-allocating reference to a +/// sequence of characters. It encapsulates both a character pointer and a +/// length. +/// +/// A function that takes a string input (but does not need to alter the +/// string in place) may use a string_view parameter and accept input that +/// is any of char* (C string), string literal (constant char array), a +/// std::string (C++ string), or OIIO ustring. For all of these cases, no +/// extra allocations are performed, and no extra copies of the string +/// contents are performed (as they would be, for example, if the function +/// took a const std::string& argument but was passed a char* or string +/// literal). +/// +/// Furthermore, a function that returns a copy or a substring of one of its +/// inputs (for example, a substr()-like function) may return a string_view +/// rather than a std::string, and thus generate its return value without +/// any allocation or copying. Upon assignment to a std::string or ustring, +/// it will properly auto-convert. +/// +/// There are two important caveats to using this class: +/// 1. The string_view merely refers to characters owned by another string, +/// so the string_view may not be used outside the lifetime of the string +/// it refers to. Thus, string_view is great for parameter passing, but +/// it's not a good idea to use a string_view to store strings in a data +/// structure (unless you are really sure you know what you're doing). +/// 2. Because the run of characters that the string_view refers to may not +/// be 0-terminated, it is important to distinguish between the data() +/// method, which returns the pointer to the characters, and the c_str() +/// method, which is guaranteed to return a valid C string that is +/// 0-terminated. Thus, if you want to pass the contents of a string_view +/// to a function that expects a 0-terminated string (say, fopen), you +/// must call fopen(my_string_view.c_str()). Note that the usual case +/// is that the string_view does refer to a 0-terminated string, and in +/// that case c_str() returns the same thing as data() without any extra +/// expense; but in the rare case that it is not 0-terminated, c_str() +/// will incur extra expense to internally allocate a valid C string. +/// + + +class OIIO_API string_view { +public: + typedef char charT; + typedef charT value_type; + typedef const charT* pointer; + typedef const charT* const_pointer; + typedef const charT& reference; + typedef const charT& const_reference; + typedef const_pointer const_iterator; + typedef const_iterator iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef const_reverse_iterator reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef std::char_traits traits; + static const size_type npos = ~size_type(0); + + /// Default ctr + string_view () { init(NULL,0); } + /// Copy ctr + string_view (const string_view ©) { + init (copy.m_chars, copy.m_len); + } + /// Construct from char* and length. + string_view (const charT *chars, size_t len) { init (chars, len); } + /// Construct from char*, use strlen to determine length. + string_view (const charT *chars) { + init (chars, chars ? strlen(chars) : 0); + } + /// Construct from std::string. + string_view (const std::string &str) { init (str.data(), str.size()); } + + std::string str() const { + return (m_chars ? std::string(m_chars,m_len) : std::string()); + } + + /// Explicitly request a 0-terminated string. USUALLY, this turns out to + /// be just data(), with no significant added expense. But in the more + /// rare case that the string_view represetns a non-0-terminated + /// substring, it will force an allocation and copy underneath. + const char * c_str() const; + + // assignments + string_view& operator= (const string_view ©) { + init (copy.data(), copy.length()); + return *this; + } + + operator std::string() const { return str(); } + + // iterators + const_iterator begin() const { return m_chars; } + const_iterator end() const { return m_chars + m_len; } + const_iterator cbegin() const { return m_chars; } + const_iterator cend() const { return m_chars + m_len; } + const_reverse_iterator rbegin() const { return const_reverse_iterator (end()); } + const_reverse_iterator rend() const { return const_reverse_iterator (begin()); } + const_reverse_iterator crbegin() const { return const_reverse_iterator (end()); } + const_reverse_iterator crend() const { return const_reverse_iterator (begin()); } + + // capacity + size_type size() const { return m_len; } + size_type length() const { return m_len; } + size_type max_size() const { return m_len; } + bool empty() const { return m_len == 0; } + + // element access + const charT& operator[] (size_type pos) const { return m_chars[pos]; } + const charT& at (size_t pos) const { + if (pos >= m_len) + throw (std::out_of_range ("OpenImageIO::string_view::at")); + return m_chars[pos]; + } + const charT& front() const { return m_chars[0]; } + const charT& back() const { return m_chars[m_len-1]; } + const charT* data() const { return m_chars; } + + // modifiers + void clear() { init(NULL,0); } + void remove_prefix(size_type n) { + if (n > m_len) + n = m_len; + m_chars += n; + m_len -= n; + } + void remove_suffix(size_type n) { + if (n > m_len) + n = m_len; + m_len -= n; + } + + string_view substr (size_type pos, size_type n=npos) const { + if (pos > size()) + return string_view(); // start past end -> return empty + if (n == npos || pos + n > size()) + n = size() - pos; + return string_view (data() + pos, n); + } + + int compare (string_view x) const { + const int cmp = std::char_traits::compare (m_chars, x.m_chars, (std::min)(m_len, x.m_len)); + return cmp != 0 ? cmp : int(m_len - x.m_len); + // Equivalent to: + // cmp != 0 ? cmp : (m_len == x.m_len ? 0 : (m_len < x.m_len ? -1 : 1)); + } + +#if 0 + // Do these later if anybody needs them + bool starts_with(string_view x) const; + bool ends_with(string_view x) const; +#endif + + /// Find the first occurrence of substring s in *this, starting at + /// position pos. + size_type find (string_view s, size_t pos=0) const { + if (pos > size()) + pos = size(); + const_iterator i = std::search (this->cbegin()+pos, this->cend(), + s.cbegin(), s.cend(), traits::eq); + return i == this->cend() ? npos : std::distance (this->cbegin(), i); + } + + /// Find the first occurrence of character c in *this, starting at + /// position pos. + size_type find (charT c, size_t pos=0) const { + if (pos > size()) + pos = size(); + const_iterator i = std::find_if (this->cbegin()+pos, this->cend(), + traits_eq(c)); + return i == this->cend() ? npos : std::distance (this->cbegin(), i); + } + + /// Find the last occurrence of substring s *this, but only those + /// occurrences earlier than position pos. + size_type rfind (string_view s, size_t pos=npos) const { + if (pos > size()) + pos = size(); + const_reverse_iterator b = this->crbegin()+(size()-pos); + const_reverse_iterator e = this->crend(); + const_reverse_iterator i = std::search (b, e, s.crbegin(), s.crend(), traits::eq); + return i == e ? npos : (reverse_distance(this->crbegin(),i) - s.size() + 1); + } + + /// Find the last occurrence of character c in *this, but only those + /// occurrences earlier than position pos. + size_type rfind (charT c, size_t pos=npos) const { + if (pos > size()) + pos = size(); + const_reverse_iterator b = this->crbegin()+(size()-pos); + const_reverse_iterator e = this->crend(); + const_reverse_iterator i = std::find_if (b, e, traits_eq(c)); + return i == e ? npos : reverse_distance (this->crbegin(),i); + } + + size_type find_first_of (charT c, size_t pos=0) const { return find (c, pos); } + + size_type find_last_of (charT c, size_t pos=npos) const { return rfind (c, pos); } + + size_type find_first_of (string_view s) const { + const_iterator i = std::find_first_of (this->cbegin(), this->cend(), + s.cbegin(), s.cend(), traits::eq); + return i == this->cend() ? npos : std::distance (this->cbegin(), i); + } + + size_type find_last_of (string_view s) const { + const_reverse_iterator i = std::find_first_of (this->crbegin(), this->crend(), + s.cbegin(), s.cend(), traits::eq); + return i == this->crend() ? npos : reverse_distance (this->crbegin(), i); + } + + size_type find_first_not_of (string_view s) const { + const_iterator i = find_not_of (this->cbegin(), this->cend(), s); + return i == this->cend() ? npos : std::distance (this->cbegin(), i); + } + + size_type find_first_not_of (charT c) const { + for (const_iterator i = this->cbegin(); i != this->cend(); ++i) + if (! traits::eq (c, *i)) + return std::distance (this->cbegin(), i); + return npos; + } + + size_type find_last_not_of (string_view s) const { + const_reverse_iterator i = find_not_of (this->crbegin(), this->crend(), s); + return i == this->crend() ? npos : reverse_distance (this->crbegin(), i); + } + + size_type find_last_not_of (charT c) const { + for (const_reverse_iterator i = this->crbegin(); i != this->crend(); ++i) + if (! traits::eq (c, *i)) + return reverse_distance (this->crbegin(), i); + return npos; + } + +private: + const charT * m_chars; + size_t m_len; + + void init (const charT *chars, size_t len) { + m_chars = chars; + m_len = len; + } + + template + size_type reverse_distance (r_iter first, r_iter last) const { + return m_len - 1 - std::distance (first, last); + } + + template + iter find_not_of (iter first, iter last, string_view s) const { + for ( ; first != last ; ++first) + if (! traits::find (s.data(), s.length(), *first)) + return first; + return last; + } + + class traits_eq { + public: + traits_eq (charT ch) : ch(ch) {} + bool operator () (charT val) const { return traits::eq (ch, val); } + charT ch; + }; + +}; + + + +inline bool operator== (string_view x, string_view y) { + return x.size() == y.size() ? (x.compare (y) == 0) : false; +} + +inline bool operator!= (string_view x, string_view y) { + return x.size() == y.size() ? (x.compare (y) != 0) : true; +} + +inline bool operator< (string_view x, string_view y) { + return x.compare(y) < 0; +} + +inline bool operator> (string_view x, string_view y) { + return x.compare(y) > 0; +} + +inline bool operator<= (string_view x, string_view y) { + return x.compare(y) <= 0; +} + +inline bool operator>= (string_view x, string_view y) { + return x.compare(y) >= 0; +} + + + +// Inserter +inline std::ostream& operator<< (std::ostream& out, const string_view& str) { + if (out.good()) + out.write (str.data(), str.size()); + return out; +} + + + +// Temporary name equivalence +typedef string_view string_ref; + + +} OIIO_NAMESPACE_EXIT diff -Nru openimageio-1.3.13/src/oiiotool/oiiotool.cpp openimageio-1.3.14/src/oiiotool/oiiotool.cpp --- openimageio-1.3.13/src/oiiotool/oiiotool.cpp 2014-04-03 06:08:57.000000000 +0000 +++ openimageio-1.3.14/src/oiiotool/oiiotool.cpp 2014-05-19 20:19:01.000000000 +0000 @@ -2798,6 +2798,7 @@ // Create output image specification. ImageSpec specR = specA; set_roi (specR, roi_union (get_roi(specA), get_roi(specB))); + set_roi_full (specR, roi_union (get_roi_full(specA), get_roi_full(specB))); ot.push (new ImageRec ("over", specR, ot.imagecache)); ImageBuf &Rib ((*ot.curimg)()); @@ -2840,6 +2841,7 @@ // Create output image specification. ImageSpec specR = specA; set_roi (specR, roi_union (get_roi(specA), get_roi(specB))); + set_roi_full (specR, roi_union (get_roi_full(specA), get_roi_full(specB))); ot.push (new ImageRec ("zover", specR, ot.imagecache)); ImageBuf &Rib ((*ot.curimg)()); diff -Nru openimageio-1.3.13/src/openexr.imageio/exrinput.cpp openimageio-1.3.14/src/openexr.imageio/exrinput.cpp --- openimageio-1.3.13/src/openexr.imageio/exrinput.cpp 2014-04-03 06:08:57.000000000 +0000 +++ openimageio-1.3.14/src/openexr.imageio/exrinput.cpp 2014-05-19 20:19:01.000000000 +0000 @@ -280,6 +280,7 @@ m_map["displayWindow"] = ""; m_map["envmap"] = ""; m_map["tiledesc"] = ""; + m_map["tiles"] = ""; m_map["openexr:lineOrder"] = ""; m_map["type"] = ""; // Ones to skip because we consider them irrelevant diff -Nru openimageio-1.3.13/src/openexr.imageio/exroutput.cpp openimageio-1.3.14/src/openexr.imageio/exroutput.cpp --- openimageio-1.3.13/src/openexr.imageio/exroutput.cpp 2014-04-03 06:08:57.000000000 +0000 +++ openimageio-1.3.14/src/openexr.imageio/exroutput.cpp 2014-05-19 20:19:01.000000000 +0000 @@ -844,6 +844,7 @@ // the library, don't mess it up by inadvertently copying it wrong from // the user or from a file we read. if (Strutil::iequals(xname, "type") || + Strutil::iequals(xname, "tiles") || Strutil::iequals(xname, "version") || Strutil::iequals(xname, "chunkCount") || Strutil::iequals(xname, "maxSamplesPerPixel")) { @@ -851,6 +852,7 @@ } // General handling of attributes + try { // Scalar if (type.arraylen == 0) { @@ -1050,7 +1052,11 @@ } #endif } - + } catch (const std::exception &e) { +#ifndef NDEBUG + std::cout << "Caught OpenEXR exception: " << e.what() << "\n"; +#endif + } #ifndef NDEBUG std::cerr << "Don't know what to do with " << type.c_str() << ' ' << xname << "\n";