From c59a39e16b3f3f18f3af1a4bec89b178292e1e66 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Fri, 22 Aug 2025 17:16:38 -0700 Subject: [PATCH] api: Introduce new scheme for preserving ABI compatibility This patch implements the new scheme that we hope will preserve ABI compatibility across minor (yearly) releases. Brief summary: * We will strive to have annual minor releases (e.g., 3.1.x -> 3.2.x) be ABI/link backwards-compatible, as strongly as monthly patch releases (3.1.5 -> 3.1.6) always have been. Every-several-years major releases (3.x -> 4.x) are still a potential full compatibility break. * Consumers of OpenImageIO don't need to change their code, and can just continue to refer to `OIIO::Foo` or `OIIO::Bar()` as always. * Internally, all items in the public OIIO APIs will be in a versioned inner namespace, and will continue to live in the versioned namespace where they were first introduced, forever. If they need to change in an ABI-breaking way, they will be *duplicated* in the newer namespaces, so the old version continues to be available in the old namespace. * The new header nsversions.h contains a long and detailed comment explaining how all the new declarations work. --- Detailed explanation: "Major" or "first digit" releases, which only happen once every several years for us, are full ABI+API breaks. Previously, "minor" or "second digit" releases, which are annual, have fully incompatible ABIs, with separate namespaces to enforce it. Here, we are striving to allow our annual/minor releases to no longer break ABI, to make upgrading easier for downstream users. The basics are that once a symbol is introduced, it will forever live in the namespace of that release. Subsequent release years will have their own namespaces, but will either alias or duplicate the original symbols. This is enabled by our recent (in the lead-up to 3.1) introduction of a split 2-part namespacing scheme. So 3.2 is the first release that has the potential to perserve compatibility with 3.1 in this way. In this PR, I have done this for the whole codebase. It works! -- as measured by being able to have our automated ABI checker show 100% back compatibility with 3.1. So currently, even though this is the nascent 3.2 tree, everything in the public APIs live in the 3.1 ABI namespace. And so they will remain, except for changes that cannot be done without breaking ABI back-compatibility, which will then end up with multiple versions in different versioned namespaces. Let's look this over and decide if we like it. It does involve our developers to do some hoop jumping and take extra care as we develop, to keep things associated with the right namespaces. Users of OpenImageIO shouldn't need to change anything on their end, nor to be aware of this at all. Signed-off-by: Larry Gritz --- .github/workflows/build-steps.yml | 2 +- .github/workflows/ci.yml | 2 +- src/build-scripts/ci-abicheck.bash | 2 +- src/doc/Doxyfile | 2 + src/include/OpenImageIO/argparse.h | 17 +- src/include/OpenImageIO/atomic.h | 18 +- src/include/OpenImageIO/attrdelegate.h | 11 +- src/include/OpenImageIO/benchmark.h | 20 +- src/include/OpenImageIO/bit.h | 17 +- src/include/OpenImageIO/color.h | 31 ++- src/include/OpenImageIO/deepdata.h | 9 +- src/include/OpenImageIO/detail/farmhash.h | 19 +- src/include/OpenImageIO/detail/fmt.h | 17 +- .../OpenImageIO/detail/pugixml/pugixml.cpp | 32 +-- .../OpenImageIO/detail/pugixml/pugixml.hpp | 10 +- src/include/OpenImageIO/errorhandler.h | 4 +- src/include/OpenImageIO/filesystem.h | 29 +- src/include/OpenImageIO/filter.h | 4 +- src/include/OpenImageIO/fmath.h | 20 ++ src/include/OpenImageIO/fstream_mingw.h | 12 +- src/include/OpenImageIO/function_view.h | 8 +- src/include/OpenImageIO/hash.h | 16 +- src/include/OpenImageIO/image_span.h | 35 +-- src/include/OpenImageIO/image_view.h | 4 +- src/include/OpenImageIO/imagebuf.h | 18 +- src/include/OpenImageIO/imagebufalgo.h | 19 +- src/include/OpenImageIO/imagebufalgo_opencv.h | 4 +- src/include/OpenImageIO/imagebufalgo_util.h | 11 +- src/include/OpenImageIO/imagecache.h | 17 +- src/include/OpenImageIO/imageio.h | 93 +++++-- src/include/OpenImageIO/memory.h | 15 +- src/include/OpenImageIO/nsversions.h | 252 ++++++++++++++++++ src/include/OpenImageIO/oiioversion.h.in | 44 +-- src/include/OpenImageIO/optparser.h | 11 +- src/include/OpenImageIO/parallel.h | 53 +++- src/include/OpenImageIO/paramlist.h | 21 +- src/include/OpenImageIO/platform.h | 42 ++- src/include/OpenImageIO/plugin.h | 13 +- src/include/OpenImageIO/refcnt.h | 14 +- src/include/OpenImageIO/simd.h | 30 +-- src/include/OpenImageIO/span.h | 121 +++++---- src/include/OpenImageIO/strided_ptr.h | 9 +- src/include/OpenImageIO/string_view.h | 15 +- src/include/OpenImageIO/strongparam.h | 9 +- src/include/OpenImageIO/strutil.h | 17 +- src/include/OpenImageIO/sysutil.h | 4 +- src/include/OpenImageIO/texture.h | 34 ++- src/include/OpenImageIO/thread.h | 169 +++--------- src/include/OpenImageIO/tiffutils.h | 23 ++ src/include/OpenImageIO/timer.h | 4 +- src/include/OpenImageIO/type_traits.h | 12 +- src/include/OpenImageIO/typedesc.h | 67 ++++- .../OpenImageIO/unordered_map_concurrent.h | 10 +- src/include/OpenImageIO/ustring.h | 23 +- src/include/OpenImageIO/vecparam.h | 20 +- src/include/imageio_pvt.h | 11 +- src/libOpenImageIO/color_ocio.cpp | 20 +- src/libOpenImageIO/deepdata.cpp | 7 +- src/libOpenImageIO/exif.cpp | 26 +- src/libOpenImageIO/formatspec.cpp | 103 +++++-- src/libOpenImageIO/icc.cpp | 5 +- src/libOpenImageIO/imagebuf.cpp | 90 ++----- src/libOpenImageIO/imagebufalgo.cpp | 20 +- src/libOpenImageIO/imagebufalgo_addsub.cpp | 8 +- src/libOpenImageIO/imagebufalgo_channels.cpp | 8 +- src/libOpenImageIO/imagebufalgo_compare.cpp | 24 +- src/libOpenImageIO/imagebufalgo_copy.cpp | 14 +- src/libOpenImageIO/imagebufalgo_deep.cpp | 12 +- src/libOpenImageIO/imagebufalgo_demosaic.cpp | 6 +- .../imagebufalgo_demosaic_prv.h | 4 +- src/libOpenImageIO/imagebufalgo_draw.cpp | 47 ++-- src/libOpenImageIO/imagebufalgo_mad.cpp | 6 +- .../imagebufalgo_minmaxchan.cpp | 8 +- src/libOpenImageIO/imagebufalgo_muldiv.cpp | 10 +- src/libOpenImageIO/imagebufalgo_orient.cpp | 16 +- src/libOpenImageIO/imagebufalgo_pixelmath.cpp | 40 +-- src/libOpenImageIO/imagebufalgo_test.cpp | 34 +-- src/libOpenImageIO/imagebufalgo_xform.cpp | 14 +- src/libOpenImageIO/imagebufalgo_yee.cpp | 4 +- src/libOpenImageIO/imageinput.cpp | 60 ++--- src/libOpenImageIO/imageio.cpp | 37 ++- src/libOpenImageIO/imageioplugin.cpp | 36 ++- src/libOpenImageIO/imageoutput.cpp | 33 ++- src/libOpenImageIO/iptc.cpp | 5 +- src/libOpenImageIO/maketexture.cpp | 15 +- src/libOpenImageIO/xmp.cpp | 5 +- src/libtexture/environment.cpp | 4 +- src/libtexture/imagecache.cpp | 19 +- src/libtexture/imagecache_memory_pvt.h | 4 +- src/libtexture/imagecache_pvt.h | 22 +- src/libtexture/texoptions.cpp | 4 +- src/libtexture/texture3d.cpp | 4 +- src/libtexture/texture_pvt.h | 10 +- src/libtexture/texturesys.cpp | 8 +- src/libutil/SHA1.cpp | 4 +- src/libutil/SHA1.h | 4 +- src/libutil/argparse.cpp | 8 +- src/libutil/benchmark.cpp | 21 +- src/libutil/errorhandler.cpp | 4 +- src/libutil/farmhash.cpp | 29 +- src/libutil/filesystem.cpp | 26 +- src/libutil/filter.cpp | 4 +- src/libutil/hashes.cpp | 4 +- src/libutil/paramlist.cpp | 43 +-- src/libutil/plugin.cpp | 4 +- src/libutil/strutil.cpp | 55 ++-- src/libutil/strutil_test.cpp | 2 +- src/libutil/sysutil.cpp | 24 +- src/libutil/thread.cpp | 93 +++++-- src/libutil/timer.cpp | 4 +- src/libutil/typedesc.cpp | 108 ++++---- src/libutil/ustring.cpp | 4 +- src/libutil/xxhash.cpp | 4 +- src/oiiotool/oiiotool.cpp | 4 +- 114 files changed, 1779 insertions(+), 1008 deletions(-) create mode 100644 src/include/OpenImageIO/nsversions.h diff --git a/.github/workflows/build-steps.yml b/.github/workflows/build-steps.yml index b75e84c32c..cbc2133223 100644 --- a/.github/workflows/build-steps.yml +++ b/.github/workflows/build-steps.yml @@ -203,7 +203,7 @@ jobs: time make sphinx - name: Upload testsuite debugging artifacts uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 - if: ${{ failure() || inputs.build_docs == '1' || inputs.benchmark == '1' }} + if: ${{ failure() || inputs.build_docs == '1' || inputs.benchmark == '1' || inputs.abi_check != '' }} with: name: oiio-${{github.job}}-${{inputs.nametag}} path: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 197dd8480b..bdeebf4cb1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -388,7 +388,7 @@ jobs: simd: "avx2,f16c" skip_tests: 1 # abi_check: v3.1.3.0 - abi_check: ae5dca7865c9956b43cc04dee00a65ad893e251e + abi_check: 9bfcce725a3806a3f70c7e838d9d98d6d95c917a setenvs: export OIIO_CMAKE_FLAGS="-DOIIO_BUILD_TOOLS=0 -DOIIO_BUILD_TESTS=0 -DUSE_PYTHON=0" USE_OPENCV=0 USE_FFMPEG=0 USE_PYTHON=0 USE_FREETYPE=0 diff --git a/src/build-scripts/ci-abicheck.bash b/src/build-scripts/ci-abicheck.bash index 88c9c56ad0..5c83f5259e 100755 --- a/src/build-scripts/ci-abicheck.bash +++ b/src/build-scripts/ci-abicheck.bash @@ -41,6 +41,7 @@ for lib in $LIBS ; do fgrep "Binary compatibility:" ${lib}-abi-results.txt echo -e "\x1b[33;0m" done +cp -r compat_reports ${BUILDDIR_NEW}/compat_reports || true # # If the "Binary compatibility" summary results say anything other than 100%, @@ -48,7 +49,6 @@ done # for lib in $LIBS ; do if [[ `fgrep "Binary compatibility:" ${lib}-abi-results.txt | grep -v 100\%` != "" ]] ; then - cp -r compat_reports ${BUILDDIR_NEW}/compat_reports exit 1 fi done diff --git a/src/doc/Doxyfile b/src/doc/Doxyfile index 82d533b7a4..64358b8ed3 100644 --- a/src/doc/Doxyfile +++ b/src/doc/Doxyfile @@ -2189,6 +2189,8 @@ PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \ OIIO_NAMESPACE_3_0_END="}" \ OIIO_NAMESPACE_3_1_BEGIN="namespace OIIO {" \ OIIO_NAMESPACE_3_1_END="}" \ + OIIO_NAMESPACE_3_2_BEGIN="namespace OIIO {" \ + OIIO_NAMESPACE_3_2_END="}" \ OIIO_NS_BEGIN="namespace OIIO {" \ OIIO_NS_END="}" \ OIIO_CONSTEXPR17=constexpr \ diff --git a/src/include/OpenImageIO/argparse.h b/src/include/OpenImageIO/argparse.h index 5d323830e1..4b598fdf73 100644 --- a/src/include/OpenImageIO/argparse.h +++ b/src/include/OpenImageIO/argparse.h @@ -20,8 +20,12 @@ #include #include +// Define symbols that let client applications determine if newly added +// features are supported. +#define OIIO_ARGPARSE_SUPPORTS_BRIEFUSAGE 1 +#define OIIO_ARGPARSE_SUPPORTS_HUMAN_PARAMNAME 1 -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN ///////////////////////////////////////////////////////////////////////////// @@ -173,7 +177,7 @@ OIIO_NAMESPACE_BEGIN class OIIO_UTIL_API ArgParse { public: - class Arg; // Forward declarion of Arg + class Arg; // Forward declaration of Arg // ------------------------------------------------------------------ /// @defgroup Setting up an ArgParse @@ -782,11 +786,4 @@ class OIIO_UTIL_API ArgParse { void usage() const { print_help(); } }; - - -// Define symbols that let client applications determine if newly added -// features are supported. -#define OIIO_ARGPARSE_SUPPORTS_BRIEFUSAGE 1 -#define OIIO_ARGPARSE_SUPPORTS_HUMAN_PARAMNAME 1 - -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/include/OpenImageIO/atomic.h b/src/include/OpenImageIO/atomic.h index 1a91c2a3f0..2113d7d3d8 100644 --- a/src/include/OpenImageIO/atomic.h +++ b/src/include/OpenImageIO/atomic.h @@ -19,11 +19,11 @@ -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN using std::atomic; -typedef atomic atomic_int; -typedef atomic atomic_ll; +using atomic_int = atomic; +using atomic_ll = atomic; @@ -79,5 +79,17 @@ atomic_fetch_add(atomic& a, double f) } while (true); } +OIIO_NAMESPACE_3_1_END + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using std::atomic; +using atomic_int = atomic; +using atomic_ll = atomic; +using v3_1::atomic_fetch_add; +using v3_1::atomic_max; +using v3_1::atomic_min; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/attrdelegate.h b/src/include/OpenImageIO/attrdelegate.h index f0fc28b0d0..2fadd00da8 100644 --- a/src/include/OpenImageIO/attrdelegate.h +++ b/src/include/OpenImageIO/attrdelegate.h @@ -14,7 +14,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace pvt { @@ -229,4 +229,13 @@ template class AttrDelegate { }; +OIIO_NAMESPACE_3_1_END + + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::AttrDelegate; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/benchmark.h b/src/include/OpenImageIO/benchmark.h index 2c8b23a6ef..bfcb8b8235 100644 --- a/src/include/OpenImageIO/benchmark.h +++ b/src/include/OpenImageIO/benchmark.h @@ -24,7 +24,7 @@ #endif -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// DoNotOptimize(val) is a helper function for timing benchmarks that fools /// the compiler into thinking the the location 'val' is used and will not @@ -470,6 +470,24 @@ OIIO_FORCEINLINE void clobber_all_memory() { } #endif +OIIO_UTIL_API std::ostream& operator<<(std::ostream& out, + const Benchmarker& bench); + +OIIO_NAMESPACE_3_1_END +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::Benchmarker; +using v3_1::clobber; +using v3_1::clobber_all_memory; +using v3_1::DoNotOptimize; +using v3_1::time_trial; +using v3_1::timed_thread_wedge; +using v3_1::operator<<; +namespace pvt { +using v3_1::pvt::use_char_ptr; +} +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/bit.h b/src/include/OpenImageIO/bit.h index 1b8265b591..08526f3b85 100644 --- a/src/include/OpenImageIO/bit.h +++ b/src/include/OpenImageIO/bit.h @@ -10,7 +10,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// Standards-compliant bit cast of two equally sized types. This is used @@ -273,4 +273,19 @@ rotl64(uint64_t x, int k) +OIIO_NAMESPACE_3_1_END + + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::bitcast; +using v3_1::bitcast_to_float; +using v3_1::bitcast_to_int; +using v3_1::byteswap; +using v3_1::rotl; +using v3_1::rotl32; +using v3_1::rotl64; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/color.h b/src/include/OpenImageIO/color.h index e284e6c337..46676efe76 100644 --- a/src/include/OpenImageIO/color.h +++ b/src/include/OpenImageIO/color.h @@ -12,6 +12,9 @@ #include #include +// Preprocessor symbol to allow conditional compilation depending on +// whether the ColorProcessor class is exposed (it was not prior to OIIO 1.9). +#define OIIO_HAS_COLORPROCESSOR 1 // // Some general color management information materials to have handy: @@ -23,7 +26,12 @@ // -OIIO_NAMESPACE_BEGIN +// Preprocessor symbol to allow conditional compilation depending on +// whether the ColorConfig returns ColorProcessor shared pointers or raw. +#define OIIO_COLORCONFIG_USES_SHARED_PTR 1 + + +OIIO_NAMESPACE_3_1_BEGIN /// The ColorProcessor encapsulates a baked color transformation, suitable for /// application to raw pixels, or ImageBuf(s). These are generated using @@ -50,17 +58,9 @@ class OIIO_API ColorProcessor { } }; -// Preprocessor symbol to allow conditional compilation depending on -// whether the ColorProcessor class is exposed (it was not prior to OIIO 1.9). -#define OIIO_HAS_COLORPROCESSOR 1 - - -typedef std::shared_ptr ColorProcessorHandle; -// Preprocessor symbol to allow conditional compilation depending on -// whether the ColorConfig returns ColorProcessor shared pointers or raw. -#define OIIO_COLORCONFIG_USES_SHARED_PTR 1 +using ColorProcessorHandle = std::shared_ptr; @@ -445,7 +445,18 @@ class OIIO_API ColorConfig { Impl* getImpl() const { return m_impl.get(); } }; +OIIO_NAMESPACE_3_1_END + +// Compatibility +#ifndef OIIO_DOXYGEN +OIIO_NAMESPACE_BEGIN +using v3_1::ColorProcessorHandle; +OIIO_NAMESPACE_END +#endif + + +OIIO_NAMESPACE_BEGIN /// Utility -- convert sRGB value to linear transfer function, without /// any change in color primaries. diff --git a/src/include/OpenImageIO/deepdata.h b/src/include/OpenImageIO/deepdata.h index d814914872..deec7bebd5 100644 --- a/src/include/OpenImageIO/deepdata.h +++ b/src/include/OpenImageIO/deepdata.h @@ -10,12 +10,7 @@ #include #include -OIIO_NAMESPACE_BEGIN - - -struct TypeDesc; -class ImageSpec; - +OIIO_NAMESPACE_3_1_BEGIN /// A `DeepData` holds the contents of an image of ``deep'' pixels (multiple @@ -209,4 +204,4 @@ class OIIO_API DeepData { }; -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/include/OpenImageIO/detail/farmhash.h b/src/include/OpenImageIO/detail/farmhash.h index c5c00652d1..99e9903b7f 100644 --- a/src/include/OpenImageIO/detail/farmhash.h +++ b/src/include/OpenImageIO/detail/farmhash.h @@ -216,7 +216,7 @@ STATIC_INLINE void simpleSwap(T &a, T &b) { #define Hash128to64 OIIO::farmhash::Hash128to64 // namespace NAMESPACE_FOR_HASH_FUNCTIONS { -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace farmhash { namespace inlined { @@ -379,7 +379,8 @@ STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) { // } // namespace NAMESPACE_FOR_HASH_FUNCTIONS } /*end namespace inlined */ -} /*end namespace farmhash*/ OIIO_NAMESPACE_END +} /*end namespace farmhash*/ +OIIO_NAMESPACE_3_1_END // FARMHASH PORTABILITY LAYER: debug mode or max speed? // One may use -DFARMHASH_DEBUG=1 or -DFARMHASH_DEBUG=0 to force the issue. @@ -506,7 +507,7 @@ STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) { // namespace NAMESPACE_FOR_HASH_FUNCTIONS { -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN //using namespace OIIO::farmhash; namespace farmhash { namespace inlined { @@ -2184,8 +2185,16 @@ STATIC_INLINE uint128_t Fingerprint128(const char* s, size_t len) { #undef Murk #undef Chunk -OIIO_NAMESPACE_END - #undef STATIC_INLINE +OIIO_NAMESPACE_3_1_END + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +namespace farmhash { +using namespace OIIO::v3_1::farmhash; +} // namespace farmhash +#endif +OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/detail/fmt.h b/src/include/OpenImageIO/detail/fmt.h index 33fed3cb37..b68ea14e02 100644 --- a/src/include/OpenImageIO/detail/fmt.h +++ b/src/include/OpenImageIO/detail/fmt.h @@ -21,12 +21,12 @@ #if OIIO_VERSION_LESS(3, 1, 2) /* DEPRECATED -- remove at next ABI compatibility boundary */ -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace pvt { OIIO_UTIL_API void log_fmt_error(const char* message); }; -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END #endif // Use the grisu fast floating point formatting for old fmt versions @@ -78,7 +78,7 @@ OIIO_PRAGMA_WARNING_POP #endif -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace pvt { @@ -197,4 +197,15 @@ struct array_formatter : format_parser_with_separator { } // namespace pvt +OIIO_NAMESPACE_3_1_END + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +namespace pvt { +using v3_1::pvt::array_formatter; +using v3_1::pvt::index_formatter; +} // namespace pvt +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/detail/pugixml/pugixml.cpp b/src/include/OpenImageIO/detail/pugixml/pugixml.cpp index 6b381f9cc3..d764c28f9c 100644 --- a/src/include/OpenImageIO/detail/pugixml/pugixml.cpp +++ b/src/include/OpenImageIO/detail/pugixml/pugixml.cpp @@ -150,17 +150,17 @@ using std::memset; // We put implementation details into an anonymous namespace in source mode, but have to keep it in non-anonymous namespace in header-only mode to prevent binary bloat. #ifdef PUGIXML_HEADER_ONLY -# define PUGI__NS_BEGIN OIIO_NAMESPACE_BEGIN namespace pugi { namespace impl { -# define PUGI__NS_END } } OIIO_NAMESPACE_END +# define PUGI__NS_BEGIN OIIO_NAMESPACE_3_1_BEGIN namespace pugi { namespace impl { +# define PUGI__NS_END } } OIIO_NAMESPACE_3_1_END # define PUGI__FN inline # define PUGI__FN_NO_INLINE inline #else # if defined(_MSC_VER) && _MSC_VER < 1300 // MSVC6 seems to have an amusing bug with anonymous namespaces inside namespaces -# define PUGI__NS_BEGIN OIIO_NAMESPACE_BEGIN namespace pugi { namespace impl { -# define PUGI__NS_END } } OIIO_NAMESPACE_END +# define PUGI__NS_BEGIN OIIO_NAMESPACE_3_1_BEGIN namespace pugi { namespace impl { +# define PUGI__NS_END } } OIIO_NAMESPACE_3_1_END # else -# define PUGI__NS_BEGIN OIIO_NAMESPACE_BEGIN namespace pugi { namespace impl { namespace { -# define PUGI__NS_END } } } OIIO_NAMESPACE_END +# define PUGI__NS_BEGIN OIIO_NAMESPACE_3_1_BEGIN namespace pugi { namespace impl { namespace { +# define PUGI__NS_END } } } OIIO_NAMESPACE_3_1_END # endif # define PUGI__FN # define PUGI__FN_NO_INLINE PUGI__NO_INLINE @@ -168,7 +168,7 @@ using std::memset; // uintptr_t #if (defined(_MSC_VER) && _MSC_VER < 1600) || (defined(__BORLANDC__) && __BORLANDC__ < 0x561) -OIIO_NAMESPACE_BEGIN namespace pugi +OIIO_NAMESPACE_3_1_BEGIN namespace pugi { # ifndef _UINTPTR_T_DEFINED typedef size_t uintptr_t; @@ -177,7 +177,7 @@ OIIO_NAMESPACE_BEGIN namespace pugi typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; -} OIIO_NAMESPACE_END +} OIIO_NAMESPACE_3_1_END #else # include #endif @@ -1048,7 +1048,7 @@ PUGI__NS_END #endif #ifdef PUGIXML_COMPACT -OIIO_NAMESPACE_BEGIN namespace pugi +OIIO_NAMESPACE_3_1_BEGIN namespace pugi { struct xml_attribute_struct { @@ -1091,9 +1091,9 @@ OIIO_NAMESPACE_BEGIN namespace pugi impl::compact_pointer first_attribute; }; -} OIIO_NAMESPACE_END +} OIIO_NAMESPACE_3_1_END #else -OIIO_NAMESPACE_BEGIN namespace pugi +OIIO_NAMESPACE_3_1_BEGIN namespace pugi { struct xml_attribute_struct { @@ -1132,7 +1132,7 @@ OIIO_NAMESPACE_BEGIN namespace pugi xml_attribute_struct* first_attribute; }; -} OIIO_NAMESPACE_END +} OIIO_NAMESPACE_3_1_END #endif PUGI__NS_BEGIN @@ -5071,7 +5071,7 @@ PUGI__NS_BEGIN }; PUGI__NS_END -OIIO_NAMESPACE_BEGIN namespace pugi +OIIO_NAMESPACE_3_1_BEGIN namespace pugi { PUGI__FN xml_writer_file::xml_writer_file(void* file_): file(file_) { @@ -7358,7 +7358,7 @@ OIIO_NAMESPACE_BEGIN namespace pugi { return impl::xml_memory::deallocate; } -} OIIO_NAMESPACE_END +} OIIO_NAMESPACE_3_1_END #if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC)) namespace std @@ -12172,7 +12172,7 @@ PUGI__NS_BEGIN } PUGI__NS_END -OIIO_NAMESPACE_BEGIN namespace pugi +OIIO_NAMESPACE_3_1_BEGIN namespace pugi { #ifndef PUGIXML_NO_EXCEPTIONS PUGI__FN xpath_exception::xpath_exception(const xpath_parse_result& result_): _result(result_) @@ -12953,7 +12953,7 @@ OIIO_NAMESPACE_BEGIN namespace pugi { return query.evaluate_node(*this); } -} OIIO_NAMESPACE_END +} OIIO_NAMESPACE_3_1_END #endif diff --git a/src/include/OpenImageIO/detail/pugixml/pugixml.hpp b/src/include/OpenImageIO/detail/pugixml/pugixml.hpp index a7f1680f36..b39fa832ea 100644 --- a/src/include/OpenImageIO/detail/pugixml/pugixml.hpp +++ b/src/include/OpenImageIO/detail/pugixml/pugixml.hpp @@ -134,13 +134,13 @@ #endif -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace pugi {} -OIIO_NAMESPACE_END -namespace pugi = OIIO::pugi; +OIIO_NAMESPACE_3_1_END +namespace pugi = OIIO::v3_1::pugi; -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace pugi { // Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE @@ -1457,7 +1457,7 @@ namespace pugi allocation_function PUGIXML_FUNCTION get_memory_allocation_function(); deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function(); } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END #if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC)) namespace std diff --git a/src/include/OpenImageIO/errorhandler.h b/src/include/OpenImageIO/errorhandler.h index 007386903f..ac96204bbd 100644 --- a/src/include/OpenImageIO/errorhandler.h +++ b/src/include/OpenImageIO/errorhandler.h @@ -10,7 +10,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// ErrorHandler is a simple class that accepts error messages /// (classified as errors, severe errors, warnings, info, messages, or @@ -136,4 +136,4 @@ class OIIO_UTIL_API ErrorHandler { int m_verbosity; }; -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/include/OpenImageIO/filesystem.h b/src/include/OpenImageIO/filesystem.h index 98eaf617b9..1f4084d93d 100644 --- a/src/include/OpenImageIO/filesystem.h +++ b/src/include/OpenImageIO/filesystem.h @@ -44,20 +44,22 @@ -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN #if OIIO_FILESYSTEM_USE_STDIO_FILEBUF // MingW uses GCC to build, but does not support having a wchar_t* passed as argument // of ifstream::open or ofstream::open. To properly support UTF-8 encoding on MingW we must // use the __gnu_cxx::stdio_filebuf GNU extension that can be used with _wfsopen and returned // into a istream which share the same API as ifsteam. The same reasoning holds for ofstream. -typedef basic_ifstream ifstream; -typedef basic_ofstream ofstream; +using ifstream = basic_ifstream; +using ofstream = basic_ofstream; #else -typedef std::ifstream ifstream; -typedef std::ofstream ofstream; +using ifstream = std::ifstream; +using ofstream = std::ofstream; #endif + + /// @namespace Filesystem /// /// @brief Platform-independent utilities for manipulating file names, @@ -243,12 +245,12 @@ OIIO_UTIL_API std::string current_path (); /// Version of std::ifstream.open that can handle UTF-8 paths /// -OIIO_UTIL_API void open (OIIO::ifstream &stream, string_view path, +OIIO_UTIL_API void open (ifstream &stream, string_view path, std::ios_base::openmode mode = std::ios_base::in); /// Version of std::ofstream.open that can handle UTF-8 paths /// -OIIO_UTIL_API void open (OIIO::ofstream &stream, string_view path, +OIIO_UTIL_API void open (ofstream &stream, string_view path, std::ios_base::openmode mode = std::ios_base::out); /// Version of C open() that can handle UTF-8 paths, returning an integer @@ -286,7 +288,7 @@ OIIO_UTIL_API bool write_text_file (string_view filename, string_view str); template bool write_binary_file (string_view filename, cspan data) { - OIIO::ofstream out; + ofstream out; Filesystem::open(out, filename, std::ios::out | std::ios::binary); out.write((const char*)data.data(), data.size() * sizeof(T)); return out.good(); @@ -584,4 +586,15 @@ class OIIO_UTIL_API IOMemReader : public IOProxy { }; // namespace Filesystem +OIIO_NAMESPACE_3_1_END + +// Compatibility +#ifndef OIIO_DOXYGEN +OIIO_NAMESPACE_BEGIN +using ifstream = v3_1::ifstream; +using ofstream = v3_1::ofstream; +namespace Filesystem { +using namespace OIIO::v3_1::Filesystem; +}; // namespace Filesystem OIIO_NAMESPACE_END +#endif diff --git a/src/include/OpenImageIO/filter.h b/src/include/OpenImageIO/filter.h index 93d1a9c099..5bc00f0e1f 100644 --- a/src/include/OpenImageIO/filter.h +++ b/src/include/OpenImageIO/filter.h @@ -12,7 +12,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// Quick structure that describes a filter. /// @@ -156,4 +156,4 @@ class OIIO_UTIL_API Filter2D { }; -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/include/OpenImageIO/fmath.h b/src/include/OpenImageIO/fmath.h index e97a748c1b..bb73ff14ea 100644 --- a/src/include/OpenImageIO/fmath.h +++ b/src/include/OpenImageIO/fmath.h @@ -46,6 +46,12 @@ OIIO_NAMESPACE_BEGIN +// NOTE: Almost everything in fmath.h is either inline or templated, and +// therefore can be left in the "current" OIIO namespace, they are never +// visible between translation units. But if this ever comes up as a problem, +// we can just move them into an older v3_1 namespace and appropriate `using` +// directives to alias it into other namespaces. + /// If the caller defines OIIO_FMATH_HEADER_ONLY to nonzero, then 100% of the /// implementation of fmath functions will be defined directly in this header @@ -743,7 +749,10 @@ scaled_conversion(const S& src, F scale, F min, F max) } } +OIIO_NAMESPACE_END + +OIIO_NAMESPACE_3_1_BEGIN /// Convert n consecutive values from the type of S to the type of D. /// The conversion is not a simple cast, but correctly remaps the @@ -1017,6 +1026,11 @@ convert_type (const S &src) } } +OIIO_NAMESPACE_3_1_END + + +OIIO_NAMESPACE_BEGIN +using v3_1::convert_type; /// Helper function to convert channel values between different bit depths. @@ -2272,6 +2286,12 @@ interpolate_linear (float x, span_strided y) // (end miscellaneous numerical methods) //////////////////////////////////////////////////////////////////////////// +OIIO_NAMESPACE_END +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::convert_type; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/fstream_mingw.h b/src/include/OpenImageIO/fstream_mingw.h index 4ac577474f..6a4e860729 100644 --- a/src/include/OpenImageIO/fstream_mingw.h +++ b/src/include/OpenImageIO/fstream_mingw.h @@ -24,7 +24,7 @@ # include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN template> @@ -309,7 +309,15 @@ basic_ofstream<_CharT, _Traits>::close() } // basic_fstream -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END + +// Compatibility +OIIO_NAMESPACE_BEGIN +# ifndef OIIO_DOXYGEN +using v3_1::basic_ifstream; +using v3_1::basic_ofstream; +# endif +OIIO_NAMESPACE_END #endif // #if defined(_WIN32) && defined(__GLIBCXX__) diff --git a/src/include/OpenImageIO/function_view.h b/src/include/OpenImageIO/function_view.h index 5df9842a2e..e945bfe5cf 100644 --- a/src/include/OpenImageIO/function_view.h +++ b/src/include/OpenImageIO/function_view.h @@ -47,7 +47,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// function_view is a lightweight non-owning generic callable @@ -105,4 +105,10 @@ template class function_view { }; +OIIO_NAMESPACE_3_1_END + + +// Compatibility +OIIO_NAMESPACE_BEGIN +using v3_1::function_view; OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/hash.h b/src/include/OpenImageIO/hash.h index 12e58d1616..8424869a97 100644 --- a/src/include/OpenImageIO/hash.h +++ b/src/include/OpenImageIO/hash.h @@ -27,7 +27,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN using std::hash; using std::unordered_map; @@ -563,7 +563,7 @@ inline uint128_t Fingerprint128(const Str& s) { class CSHA1; // opaque forward declaration -/// Class that encapsulates SHA-1 hashing, a crypticographic-strength +/// Class that encapsulates SHA-1 hashing, a cryptographic-strength /// 160-bit hash function. It's not as fast as our other hashing /// methods, but has an extremely low chance of having collisions. class OIIO_API SHA1 { @@ -616,4 +616,16 @@ class OIIO_API SHA1 { }; +OIIO_NAMESPACE_3_1_END + + +// Compatibility +OIIO_NAMESPACE_BEGIN +// Replicate the hashing namespaces in v3_1:: inside OIIO:: +namespace fasthash { using namespace OIIO::v3_1::fasthash; } +namespace xxhash { using namespace OIIO::v3_1::xxhash; } +namespace bjhash { using namespace OIIO::v3_1::bjhash; } +namespace murmur { using namespace OIIO::v3_1::murmur; } +namespace farmhash { using namespace OIIO::v3_1::farmhash; } +using v3_1::SHA1; OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/image_span.h b/src/include/OpenImageIO/image_span.h index 5f685eb6ad..2684c15504 100644 --- a/src/include/OpenImageIO/image_span.h +++ b/src/include/OpenImageIO/image_span.h @@ -11,24 +11,8 @@ #include -OIIO_NAMESPACE_BEGIN - -#ifndef OIIO_STRIDE_T_DEFINED -# define OIIO_STRIDE_T_DEFINED -/// Type we use to express how many pixels (or bytes) constitute an image, -/// tile, or scanline. -using imagesize_t = uint64_t; - -/// Type we use for stride lengths between pixels, scanlines, or image -/// planes. -using stride_t = int64_t; - -/// Special value to indicate a stride length that should be -/// auto-computed. -inline constexpr stride_t AutoStride = std::numeric_limits::min(); -#endif - +OIIO_NAMESPACE_3_1_BEGIN /// image_span : a non-owning reference to an image-like n-D array having /// between 2 and 4 dimensions representing channel, x, y, z with each @@ -52,6 +36,8 @@ template class image_span { using stride_type = int64_t; using size_type = uint32_t; + static constexpr stride_t AutoStride = std::numeric_limits::min(); + /// Default ctr -- points to nothing image_span() = default; @@ -385,6 +371,8 @@ as_image_span_writable_bytes(const image_span& src) noexcept src.ystride(), src.zstride(), src.chansize()); } + + /// Verify that the image_span has all its contents lying within the /// contiguous span. OIIO_API bool @@ -402,4 +390,17 @@ image_span_within_span(const image_span& ispan, as_bytes(contiguous)); } +OIIO_NAMESPACE_3_1_END + + +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::as_image_span_bytes; +using v3_1::as_image_span_writable_bytes; +using v3_1::image1d_span; +using v3_1::image2d_span; +using v3_1::image3d_span; +using v3_1::image_span; +using v3_1::image_span_within_span; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/image_view.h b/src/include/OpenImageIO/image_view.h index 6d1bae6102..6811bac5e7 100644 --- a/src/include/OpenImageIO/image_view.h +++ b/src/include/OpenImageIO/image_view.h @@ -12,7 +12,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// image_view : a non-owning reference to an image-like array (indexed by @@ -123,4 +123,4 @@ class OIIO_DEPRECATED("image_view is deprecated. Consider image_span.") }; -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/include/OpenImageIO/imagebuf.h b/src/include/OpenImageIO/imagebuf.h index 2015e923db..ad55228101 100644 --- a/src/include/OpenImageIO/imagebuf.h +++ b/src/include/OpenImageIO/imagebuf.h @@ -37,13 +37,7 @@ -OIIO_NAMESPACE_BEGIN - -class ImageBuf; -class ImageBufImpl; // Opaque type for the unique_ptr. -class ImageCache; -class ImageCacheTile; - +OIIO_NAMESPACE_3_1_BEGIN /// Return pixel data window for this ImageSpec as a ROI. @@ -2042,4 +2036,14 @@ class OIIO_API ImageBuf { }; +OIIO_NAMESPACE_3_1_END + + +// Compatibility +OIIO_NAMESPACE_BEGIN +using v3_1::get_roi; +using v3_1::get_roi_full; +using v3_1::InitializePixels; +using v3_1::set_roi; +using v3_1::set_roi_full; OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/imagebufalgo.h b/src/include/OpenImageIO/imagebufalgo.h index 5f8063ccfc..f70cbf72e6 100644 --- a/src/include/OpenImageIO/imagebufalgo.h +++ b/src/include/OpenImageIO/imagebufalgo.h @@ -18,18 +18,14 @@ #include #include #include +#include #include #include #include -OIIO_NAMESPACE_BEGIN - -// forward declarations -class ColorConfig; -class ColorProcessor; -class Filter2D; +OIIO_NAMESPACE_3_1_BEGIN /// @defgroup ImageBufAlgo_intro (ImageBufAlgo common principles) @@ -2707,3 +2703,14 @@ inline bool fit(ImageBuf &dst, const ImageBuf &src, Filter2D *filter, } // end namespace ImageBufAlgo OIIO_NAMESPACE_END + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::Image_or_Const; +namespace ImageBufAlgo { +using namespace OIIO::v3_1::ImageBufAlgo; +} +#endif +OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/imagebufalgo_opencv.h b/src/include/OpenImageIO/imagebufalgo_opencv.h index 56b0e349a4..7ce0373632 100644 --- a/src/include/OpenImageIO/imagebufalgo_opencv.h +++ b/src/include/OpenImageIO/imagebufalgo_opencv.h @@ -59,7 +59,7 @@ OIIO_PRAGMA_WARNING_POP -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace ImageBufAlgo { @@ -294,4 +294,4 @@ ImageBufAlgo::capture_image(int cameranum, TypeDesc convert) } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/include/OpenImageIO/imagebufalgo_util.h b/src/include/OpenImageIO/imagebufalgo_util.h index afbc944208..86b145dcab 100644 --- a/src/include/OpenImageIO/imagebufalgo_util.h +++ b/src/include/OpenImageIO/imagebufalgo_util.h @@ -13,11 +13,8 @@ -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN -using std::bind; -using std::cref; -using std::ref; using namespace std::placeholders; using std::placeholders::_1; @@ -808,4 +805,10 @@ perpixel_op(const ImageBuf& srcA, const ImageBuf& srcB, } // end namespace ImageBufAlgo +OIIO_NAMESPACE_3_1_END + + +OIIO_NAMESPACE_BEGIN +using namespace std::placeholders; +using std::placeholders::_1; OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/imagecache.h b/src/include/OpenImageIO/imagecache.h index 008b33bf34..20b784601f 100644 --- a/src/include/OpenImageIO/imagecache.h +++ b/src/include/OpenImageIO/imagecache.h @@ -25,16 +25,7 @@ -OIIO_NAMESPACE_BEGIN - -// Forward declarations -class TextureOpt_v2; - -class ImageCachePerThreadInfo; -class ImageCacheFile; -class ImageCacheTile; -class ImageCacheImpl; - +OIIO_NAMESPACE_3_1_BEGIN /// Define an API to an abstract class that manages image files, @@ -1343,8 +1334,8 @@ class OIIO_API ImageCache { ~ImageCache(); private: - friend class TextureSystem; - friend class TextureSystemImpl; + friend class OIIO::TextureSystem; + friend class OIIO::TextureSystemImpl; // PIMPL idiom using Impl = ImageCacheImpl; @@ -1356,4 +1347,4 @@ class OIIO_API ImageCache { }; -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/include/OpenImageIO/imageio.h b/src/include/OpenImageIO/imageio.h index f7576a2060..1002d8cf0b 100644 --- a/src/include/OpenImageIO/imageio.h +++ b/src/include/OpenImageIO/imageio.h @@ -39,14 +39,9 @@ #include #include -OIIO_NAMESPACE_BEGIN -class DeepData; -class ImageBuf; -class Timer; -#ifndef OIIO_STRIDE_T_DEFINED -# define OIIO_STRIDE_T_DEFINED +OIIO_NAMESPACE_3_1_BEGIN /// Type we use to express how many pixels (or bytes) constitute an image, /// tile, or scanline. using imagesize_t = uint64_t; @@ -58,7 +53,21 @@ using stride_t = int64_t; /// Special value to indicate a stride length that should be /// auto-computed. inline constexpr stride_t AutoStride = std::numeric_limits::min(); + +OIIO_NAMESPACE_3_1_END + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::imagesize_t; +using v3_1::stride_t; +using v3_1::AutoStride; #endif +OIIO_NAMESPACE_END + + + +OIIO_NAMESPACE_3_1_BEGIN // Signal that this version of ImageBuf has constructors from spans #define OIIO_IMAGEINPUT_IMAGE_SPAN_SUPPORT 1 @@ -75,11 +84,6 @@ typedef bool (*ProgressCallback)(void *opaque_data, float portion_done); -// Forward declaration of IOProxy -namespace Filesystem { - class IOProxy; -} - /// ROI is a small helper struct describing a rectangular region of interest /// in an image. The region is [xbegin,xend) x [begin,yend) x [zbegin,zend), @@ -4107,7 +4111,7 @@ inline bool getattribute(string_view name, TypeDesc type, span value) { OIIO_DASSERT(BaseTypeFromC::value == type.basetype && type.size() == value.size_bytes()); - return OIIO::getattribute(name, type, OIIO::as_writable_bytes(value)); + return OIIO::v3_1::getattribute(name, type, OIIO::as_writable_bytes(value)); } /// A version of `getattribute()` that stores the value in a span of @@ -4222,12 +4226,12 @@ inline std::map> get_extension_map() { std::map> map; - auto all_extensions = OIIO::get_string_attribute("extension_list"); - for (auto oneformat : OIIO::Strutil::splitsv(all_extensions, ";")) { - auto format_exts = OIIO::Strutil::splitsv(oneformat, ":", 2); + auto all_extensions = get_string_attribute("extension_list"); + for (auto oneformat : Strutil::splitsv(all_extensions, ";")) { + auto format_exts = Strutil::splitsv(oneformat, ":", 2); if (format_exts.size() != 2) continue; // something went wrong - map[format_exts[0]] = OIIO::Strutil::splits(format_exts[1], ","); + map[format_exts[0]] = Strutil::splits(format_exts[1], ","); } return map; } @@ -4510,15 +4514,18 @@ OIIO_API void log_time(string_view key, const Timer& timer, int count = 1); // to force correct linkage on some systems OIIO_API void _ImageIO_force_link (); +OIIO_NAMESPACE_3_1_END + ////////////////////////////////////////////////////////////////////////// // DEPRECATED things // -// These are all hidden from ocumentation and internal use, and should trigger -// deprecation warnings if used externally. They will most likely be removed -// entirely before the final release of OIIO 3.0. +// These are all hidden from documentation and internal use, and should +// trigger deprecation warnings if used externally. They will most likely be +// removed entirely before the final release of OIIO 3.0. // #if !defined(OIIO_INTERNAL) && !defined(OIIO_DOXYGEN) +OIIO_NAMESPACE_BEGIN #if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(2, 1, 0) // DEPRECATED(2.1): old name @@ -4556,13 +4563,61 @@ inline void debug (const char* fmt, const T1& v1, const Args&... args) } #endif +OIIO_NAMESPACE_END #endif // ////////////////////////////////////////////////////////////////////////// + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +// clang-format on +using v3_1::add_dither; +using v3_1::attribute; +using v3_1::convert_image; +using v3_1::convert_pixel_values; +using v3_1::copy_image; +using v3_1::cspan_from_buffer; +using v3_1::debug; +using v3_1::debugfmt; +using v3_1::declare_imageio_format; +using v3_1::equivalent_colorspace; +using v3_1::errorfmt; +using v3_1::get_extension_map; +using v3_1::get_float_attribute; +using v3_1::get_int_attribute; +using v3_1::get_string_attribute; +using v3_1::getattribute; +using v3_1::geterror; +using v3_1::has_error; +using v3_1::is_imageio_format_name; +using v3_1::log_time; +using v3_1::openimageio_version; +using v3_1::parallel_convert_image; +using v3_1::premult; +using v3_1::ProgressCallback; +using v3_1::roi_intersection; +using v3_1::roi_union; +using v3_1::set_colorspace; +using v3_1::set_colorspace_rec709_gamma; +using v3_1::shutdown; +using v3_1::span_from_buffer; +using v3_1::wrap_black; +using v3_1::wrap_clamp; +using v3_1::wrap_impl; +using v3_1::wrap_mirror; +using v3_1::wrap_periodic; +using v3_1::wrap_periodic_pow2; +namespace pvt { +using v3_1::pvt::append_error; +} +#endif OIIO_NAMESPACE_END + #if FMT_VERSION >= 100000 FMT_BEGIN_NAMESPACE template<> struct formatter : ostream_formatter {}; diff --git a/src/include/OpenImageIO/memory.h b/src/include/OpenImageIO/memory.h index e9b8379fbe..cb71ec4c00 100644 --- a/src/include/OpenImageIO/memory.h +++ b/src/include/OpenImageIO/memory.h @@ -18,7 +18,7 @@ #include #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace pvt { @@ -127,4 +127,15 @@ footprint(const std::vector& vec) } // namespace pvt -OIIO_NAMESPACE_END \ No newline at end of file +OIIO_NAMESPACE_3_1_END + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +namespace pvt { +using v3_1::pvt::footprint; +using v3_1::pvt::heapsize; +} // namespace pvt +#endif +OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/nsversions.h b/src/include/OpenImageIO/nsversions.h new file mode 100644 index 0000000000..51ae50777f --- /dev/null +++ b/src/include/OpenImageIO/nsversions.h @@ -0,0 +1,252 @@ +// Copyright Contributors to the OpenImageIO project. +// SPDX-License-Identifier: Apache-2.0 +// https://github.com/AcademySoftwareFoundation/OpenImageIO + +// clang-format off + +#ifndef OPENIMAGEIO_NSVERSIONS_H +#define OPENIMAGEIO_NSVERSIONS_H + +#ifndef OPENIMAGEIO_VERSION_H +# error "oiioversion.h must always be included before nsversions.h" +#endif + + +// Establish the namespaces. +// +// The outer namespace defaults to OpenImageIO, but can be overriden at build +// time. "OIIO" is always defined as an alias to this namespace, so client +// software can always say `OIIO:Foo` without needing to know the custom outer +// namespace. +// +// The primary inner namespace is vMAJ_MIN (or in main, vMAJ_MIN_PAT). The +// outer namespace declares the inner namespace as "inline", so anything in it +// is visible in OIIO by default. +// +// But we also keep around all the symbols for older vOLDMAJ_OLDMIN, so that +// we don't lose link/ABI compatibility with apps compiled for older minor +// versions within the same major version family. +// +// +// Here is the scheme we use to maintain ABI compatibility across minor +// version boundaries. +// +// 1. Declarations in the current new namespace +// +// * Pure OIIO internals that are not exposed in the public APIs or +// headers, and therefore generate no externally visible linker symbols. +// * NEW items that will break ABI or API, in main (will be moved into a +// specific version namespace before release). +// +// These declarations perpetually live in the "current" namespace: +// +// OIIO_NAMESPACE_BEGIN +// inline int myfunc() { ... } +// constexpr int myconst = 3; +// template Mytemplate { ... } +// // ONLY if Mytemplate is not used as the type of a parameter +// // or return value of any exposed public OIIO API function! +// // If it ever is, it should be moved to a versioned namespace. +// OIIO_NAMESPACE_END +// +// Because of the inline inner default namespace, user code can just refer +// to these as `OIIO::myfunc()`, `OIIO::myconst`, etc. +// +// 2. Declarations carried over from previous versions and aliased into +// later/current namespaces: +// +// * Anything that was introduced in earlier versions and is enclosed in a +// namespace (like `Filesystem`, `Strutil`, or `ImageBufAlgo`). +// * Existing classes that were introduced in earlier OIIO versions, and +// any modifications that can be amended without breaking their ABIs +// (such as adding a non-virtual method). This also includes templated +// classes used to pass parameters or return values by OIIO's APIs. +// * Functions that were introduced in earlier versions and can simply +// be aliased into subsequent namespaces with `using`. +// * NEW items in the above categories that are logically related to +// existing things should be placed in the oldest namespace where the +// rest of its cohort lives, if that can be done without conflicting with +// existing symbols. +// +// These live in the namespace of the version where they were first +// introduced. Later versions alias these into their namespaces with +// `using`. +// +// OIIO_NAMESPACE_3_1_BEGIN +// class Myclass { ... }; +// template Mytemplate { ... } +// int standalone_func(); +// namespace Group { +// int func_in_group(); +// } +// OIIO_NAMESPACE_3_1_END +// +// // Alias these items into subsequent version namespaces +// OIIO_NAMESPACE_BEGIN +// using v3_1::Myclass; +// using v3_1::Mytemplate; +// using v3_1::standalone_func; +// namespace Group { +// using namespace v3_1::Group; +// // Makes EVERYTHING declared in v3_1::Group alias to +// // within the current namespace's Group. +// } +// OIIO_NAMESPACE_END +// +// 3. Declarations that must be separately defined in each namespace. +// +// * Classes or functions whose declarations in newer versions have changed +// in an ABI-incompatible way. +// * Standalone functions or globals that are not enclosed in a namespace +// and for whatever reason can't simply be pulled into later namespaces +// with the `using` directive. +// +// These must have separate symbols in each versioned namespace to preserve +// ABI compatibility. But it is customary to make the full and most +// efficient implementation in the newer namespace, and the others be +// trivial wrappers (with some small penalty for the double call, but +// that's ok because it's only incurred when linking against a too-new +// version). +// +// Declarations in the .h header: +// +// OIIO_NAMESPACE_3_1_BEGIN +// int myfunc(); +// class Myclass { int foo; ... } +// int anotherfunc(Myclass& m); +// OIIO_NAMESPACE_3_1_END +// +// // Duplicate in subsequent version namespaces +// OIIO_NAMESPACE_BEGIN +// float myfunc(); // changed return value +// class Myclass { float foo; ... } // data layout changed +// int anotherfunc(Myclass& m); // DIFFERENT Myclass! +// OIIO_NAMESPACE_END +// +// Implementation in the .cpp file: +// +// OIIO_NAMESPACE_BEGIN +// // Current namespace gets a full implementation of myfunc: +// float myfunc() { ... } +// +// // New anotherfunc takes new definition of Myclass: +// int anotherfunc(Myclass& m) { ... } +// OIIO_NAMESPACE_END +// +// OIIO_NAMESPACE_3_1_BEGIN +// // Old version +// int myfunc() { ... } +// +// // Old anotherfunc takes old definition of Myclass: +// int anotherfunc(v3_1::Myclass& m) { ... } +// OIIO_NAMESPACE_3_1_END +// + + +// Macros for defining namespaces with an explicit version +#define OIIO_NS_BEGIN(ver) namespace OIIO_OUTER_NAMESPACE { namespace ver { +#define OIIO_NS_END } } + +// Specialty macro: Make something ABI compatible with 3.1 +#define OIIO_NAMESPACE_3_1_BEGIN OIIO_NS_BEGIN(v3_1) +#define OIIO_NAMESPACE_3_1_END OIIO_NS_END + +// Specialty macro: Make something ABI compatible with 3.2 +#define OIIO_NAMESPACE_3_2_BEGIN OIIO_NS_BEGIN(v3_2) +#define OIIO_NAMESPACE_3_2_END OIIO_NS_END + + + +// Forward declarations of important classes +OIIO_NAMESPACE_3_1_BEGIN +// libOpenImageIO_Util +class ArgParse; +class ColorConfig; +class ColorProcessor; +class ErrorHandler; +class Filter1D; +class Filter2D; +class FilterDesc; +class ParamValue; +class ParamValueList; +class ParamValueSpan; +class ScopedTimer; +class Timer; +struct TypeDesc; +class ustring; +class ustringhash; + +// libOpenImageIO +class DeepData; +class ImageBuf; +class ImageBufImpl; +class ImageCache; +class ImageCachePerThreadInfo; +class ImageCacheFile; +class ImageCacheImpl; +class ImageCacheTile; +class ImageInput; +class ImageOutput; +class ImageSpec; +class paropt; +struct ROI; +class TextureOptBatch_v1; +class TextureOpt_v2; +using TextureOpt = TextureOpt_v2; +class TextureSystem; +class TextureSystemImpl; +namespace Filesystem { + class IOProxy; +} +namespace ImageBufAlgo { } +namespace Strutil { } +namespace Sysutil { } +namespace simd { } +OIIO_NAMESPACE_3_1_END + +OIIO_NAMESPACE_BEGIN +// libOpenImageIO_Util +using v3_1::ArgParse; +using v3_1::ColorConfig; +using v3_1::ColorProcessor; +using v3_1::ErrorHandler; +using v3_1::Filter1D; +using v3_1::Filter2D; +using v3_1::FilterDesc; +using v3_1::ParamValue; +using v3_1::ParamValueList; +using v3_1::ParamValueSpan; +using v3_1::ScopedTimer; +using v3_1::Timer; +using v3_1::TypeDesc; +using v3_1::ustring; +using v3_1::ustringhash; + +// libOpenImageIO +using v3_1::DeepData; +using v3_1::ImageBuf; +using v3_1::ImageBufImpl; +using v3_1::ImageCache; +using v3_1::ImageCachePerThreadInfo; +using v3_1::ImageCacheFile; +using v3_1::ImageCacheImpl; +using v3_1::ImageCacheTile; +using v3_1::ImageInput; +using v3_1::ImageOutput; +using v3_1::ImageSpec; +using v3_1::paropt; +using v3_1::ROI; +using v3_1::TextureOptBatch_v1; +using v3_1::TextureOpt_v2; +using TextureOpt = v3_1::TextureOpt_v2; +using TextureOptBatch = v3_1::TextureOptBatch_v1; +using v3_1::TextureSystem; +using v3_1::TextureSystemImpl; +namespace Filesystem { using namespace v3_1::Filesystem; } +namespace ImageBufAlgo { using namespace v3_1::ImageBufAlgo; } +namespace Strutil { using namespace v3_1::Strutil; } +namespace Sysutil { using namespace v3_1::Sysutil; } +namespace simd { using namespace v3_1::simd; } +OIIO_NAMESPACE_END + +#endif /* defined(OPENIMAGEIO_NSVERSIONS_H) */ diff --git a/src/include/OpenImageIO/oiioversion.h.in b/src/include/OpenImageIO/oiioversion.h.in index b2a1d23ca1..7307df5160 100644 --- a/src/include/OpenImageIO/oiioversion.h.in +++ b/src/include/OpenImageIO/oiioversion.h.in @@ -126,39 +126,16 @@ // The primary inner namespace is vMAJ_MIN (or in main, vMAJ_MIN_PAT). The // outer namespace declares the inner namespace as "inline", so anything in it // is visible in OIIO by default. -// -// Current API symbols should declare things in the default namespace, which -// has its version incremented with every minor (yearly) release: -// -// // Foo.h -// OIIO_NAMESPACE_BEGIN /* implicitly means current for this version */ -// void foo(); -// void bar(); -// OIIO_NAMESPACE_END -// -// Because the default inner namespace is "inline", client code can just refer -// to `OIIO::Foo`, and `OIIO::v3_1::Foo` will be found (assuming that v3_1 is -// the current inner namespace). -// -// Things can also be put in an explicit inner namespace, such as -// -// OIIO_NS_BEGIN(v3_0) -// // for declarations that should be visible by explicit request only, -// // such as OIIO::v3_0::bar(). -// int bar(); -// OIIO_NS_END -// -// Currently, everything is defined with OIIO_NAMESPACE_BEGIN/END, and so is -// put in the current-minor-release namespace. But the mechanisms outlined -// above gives us the ability in the future to have multiple ABI (minor -// release) generations of the same facilities existing simultaneously, to -// preserve ABI compatibility even with minor version bumps. -// + +#define OIIO_OUTER_NAMESPACE @PROJ_NAMESPACE@ +#define OIIO_CURRENT_INNER_NAMESPACE @PROJ_VERSION_NAMESPACE@ namespace @PROJ_NAMESPACE@ { // Current version's new inner namespace is inline so it's used by default. inline namespace @PROJ_VERSION_NAMESPACE@ { } + // Legacy namespaces: + namespace v3_1 { } namespace v3_0 { } } namespace OIIO = @PROJ_NAMESPACE@; @@ -169,16 +146,7 @@ namespace OIIO = @PROJ_NAMESPACE@; #define OIIO_NAMESPACE_END } } #define OIIO_CURRENT_NAMESPACE @PROJ_NAMESPACE@::@PROJ_VERSION_NAMESPACE@ -// Macros for defining legacy namespaces with an explicit version -#define OIIO_NS_BEGIN(ver) namespace @PROJ_NAMESPACE@ { namespace ver { -#define OIIO_NS_END } } - -// Specialty macro: Make something ABI compatible with 3.1 -#define OIIO_NAMESPACE_3_1_BEGIN OIIO_NS_BEGIN(v3_1) -#define OIIO_NAMESPACE_3_1_END OIIO_NS_END - -// Macro to use names without explicit qualifier -#define OIIO_NAMESPACE_USING using namespace @PROJ_NAMESPACE@::@PROJ_VERSION_NAMESPACE@; +#include /// Each imageio DSO/DLL should include this statement: diff --git a/src/include/OpenImageIO/optparser.h b/src/include/OpenImageIO/optparser.h index 7286b3d331..b272eb8915 100644 --- a/src/include/OpenImageIO/optparser.h +++ b/src/include/OpenImageIO/optparser.h @@ -15,7 +15,7 @@ #include #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// Parse a string of the form "name=value" and then call @@ -101,5 +101,14 @@ optparser(C& system, const std::string& optstring) return ok; } +OIIO_NAMESPACE_3_1_END + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::optparse1; +using v3_1::optparser; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/parallel.h b/src/include/OpenImageIO/parallel.h index 1e4709e4d9..399a187129 100644 --- a/src/include/OpenImageIO/parallel.h +++ b/src/include/OpenImageIO/parallel.h @@ -17,7 +17,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// Split strategies /// DEPRECATED(2.4) @@ -197,6 +197,32 @@ parallel_for_chunked(int64_t begin, int64_t end, int64_t chunksize, paropt opt = paropt(0, paropt::SplitDir::Y, 1)); +#ifndef OIIO_DOXYGEN +// DEPRECATED(3.2) -- old version makes a copy of task instead of &&, ick +OIIO_UTIL_API void +parallel_for(int32_t begin, int32_t end, function_view task, + paropt opt = 0); + +// DEPRECATED(3.2) -- old version makes a copy of task instead of &&, ick +OIIO_UTIL_API void +parallel_for(int64_t begin, int64_t end, function_view task, + paropt opt = 0); + +// DEPRECATED(3.2) -- old version makes a copy of task instead of &&, ick +OIIO_UTIL_API void +parallel_for(uint32_t begin, uint32_t end, function_view task, + paropt opt = 0); + +// DEPRECATED(3.2) -- old version makes a copy of task instead of &&, ick +OIIO_UTIL_API void +parallel_for(uint64_t begin, uint64_t end, function_view task, + paropt opt = 0); +#endif + +OIIO_NAMESPACE_3_1_END + + +OIIO_NAMESPACE_BEGIN /// Parallel "for" loop, for a task that takes a single integer index, run /// it on all indices on the range [begin,end): @@ -211,21 +237,25 @@ parallel_for_chunked(int64_t begin, int64_t end, int64_t chunksize, /// (to aid data coherence and minimize the amount of thread queue /// diddling). The chunk size is chosen automatically. OIIO_UTIL_API void -parallel_for(int32_t begin, int32_t end, function_view task, +parallel_for(int32_t begin, int32_t end, function_view&& task, paropt opt = 0); OIIO_UTIL_API void -parallel_for(int64_t begin, int64_t end, function_view task, +parallel_for(int64_t begin, int64_t end, function_view&& task, paropt opt = 0); OIIO_UTIL_API void -parallel_for(uint32_t begin, uint32_t end, function_view task, +parallel_for(uint32_t begin, uint32_t end, function_view&& task, paropt opt = 0); OIIO_UTIL_API void -parallel_for(uint64_t begin, uint64_t end, function_view task, +parallel_for(uint64_t begin, uint64_t end, function_view&& task, paropt opt = 0); +OIIO_NAMESPACE_END + + +OIIO_NAMESPACE_3_1_BEGIN /// Parallel "for" loop, for a task that takes an integer range, run it /// on all indices on the range [begin,end): @@ -295,6 +325,19 @@ parallel_for_2D(int64_t xbegin, int64_t xend, int64_t ybegin, int64_t yend, std::function&& task, paropt opt = 0); +OIIO_NAMESPACE_3_1_END + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::parallel_for_2D; +using v3_1::parallel_for_chunked; +using v3_1::parallel_for_chunked_2D; +using v3_1::parallel_for_range; +using v3_1::parallel_options; +using v3_1::paropt; +using v3_1::SplitDir; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/paramlist.h b/src/include/OpenImageIO/paramlist.h index 4906c16be9..5667a75ed0 100644 --- a/src/include/OpenImageIO/paramlist.h +++ b/src/include/OpenImageIO/paramlist.h @@ -22,7 +22,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// ParamValue holds a named parameter and typed data. Usually, it owns the /// data (holding it in the struct itself if small enough, dynamically @@ -372,15 +372,19 @@ class OIIO_UTIL_API ParamValue { template friend size_t pvt::heapsize(const T&); }; + + /// heapsize specialization for `ParamValue` template<> OIIO_API size_t pvt::heapsize(const ParamValue&); + + /// Factory for a ParamValue that holds a single value of any type supported /// by a corresponding ParamValue constructor (such as int, float, string). template -static ParamValue +inline ParamValue make_pv(string_view name, const T& val) { return ParamValue(name, val); @@ -390,7 +394,7 @@ make_pv(string_view name, const T& val) /// will be interpreted as a C string (TypeString), but all other pointer /// types will just get stored as an opaque pointer (TypePointer). template -static ParamValue +inline ParamValue make_pv(string_view name, T* val) { return ParamValue(name, BaseTypeFromC::value, 1, span(&val, 1)); @@ -842,4 +846,15 @@ class OIIO_UTIL_API ParamValueSpan : public cspan { }; +OIIO_NAMESPACE_3_1_END + + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::make_pv; +using v3_1::ParamValue; +using v3_1::ParamValueList; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/platform.h b/src/include/OpenImageIO/platform.h index 51b16122ec..e4760e5545 100644 --- a/src/include/OpenImageIO/platform.h +++ b/src/include/OpenImageIO/platform.h @@ -531,7 +531,7 @@ -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// Class for describing endianness. Test for endianness as /// `if (endian::native == endian::little)` or @@ -615,8 +615,8 @@ inline bool cpu_has_avx512bw() {int i[4]; cpuid(i,7,0); return (i[1] & (1<<30)) inline bool cpu_has_avx512vl() {int i[4]; cpuid(i,7,0); return (i[1] & (0x80000000 /*1<<31*/)) != 0; } // portable aligned malloc -OIIO_API void* aligned_malloc(std::size_t size, std::size_t align); -OIIO_API void aligned_free(void* ptr); +OIIO_UTIL_API void* aligned_malloc(std::size_t size, std::size_t align); +OIIO_UTIL_API void aligned_free(void* ptr); // basic wrappers to new/delete over-aligned types since this isn't guaranteed to be supported until C++17 template @@ -641,6 +641,9 @@ inline void aligned_delete(T* t) { // DEPRECATED(2.6) using std::enable_if_t; +OIIO_NAMESPACE_3_1_END + + // An enable_if helper to be used in template parameters which results in // much shorter symbols: https://godbolt.org/z/sWw4vP // Borrowed from fmtlib. @@ -648,4 +651,37 @@ using std::enable_if_t; # define OIIO_ENABLE_IF(...) std::enable_if_t<(__VA_ARGS__), int> = 0 #endif + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::endian; +using v3_1::littleendian; +using v3_1::bigendian; +using v3_1::aligned_delete; +using v3_1::aligned_free; +using v3_1::aligned_malloc; +using v3_1::aligned_new; +using v3_1::cpuid; +using v3_1::cpu_has_sse2; +using v3_1::cpu_has_sse3; +using v3_1::cpu_has_ssse3; +using v3_1::cpu_has_fma; +using v3_1::cpu_has_sse41; +using v3_1::cpu_has_sse42; +using v3_1::cpu_has_popcnt; +using v3_1::cpu_has_avx; +using v3_1::cpu_has_f16c; +using v3_1::cpu_has_rdrand; +using v3_1::cpu_has_avx2; +using v3_1::cpu_has_avx512f; +using v3_1::cpu_has_avx512dq; +using v3_1::cpu_has_avx512ifma; +using v3_1::cpu_has_avx512pf; +using v3_1::cpu_has_avx512er; +using v3_1::cpu_has_avx512cd; +using v3_1::cpu_has_avx512bw; +using v3_1::cpu_has_avx512vl; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/plugin.h b/src/include/OpenImageIO/plugin.h index 75b32e104c..fc6c0e7d09 100644 --- a/src/include/OpenImageIO/plugin.h +++ b/src/include/OpenImageIO/plugin.h @@ -20,7 +20,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace Plugin { @@ -74,4 +74,15 @@ geterror(bool clear = true); } // namespace Plugin +OIIO_NAMESPACE_3_1_END + + + +// Compatibility: inherit everything from v3_1::Plugin +#ifndef OIIO_DOXYGEN +OIIO_NAMESPACE_BEGIN +namespace Plugin { +using namespace OIIO::v3_1::Plugin; +} OIIO_NAMESPACE_END +#endif diff --git a/src/include/OpenImageIO/refcnt.h b/src/include/OpenImageIO/refcnt.h index 68cacd319c..a234fab19f 100644 --- a/src/include/OpenImageIO/refcnt.h +++ b/src/include/OpenImageIO/refcnt.h @@ -19,7 +19,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN @@ -254,4 +254,16 @@ footprint(const intrusive_ptr& ref) } // namespace pvt +OIIO_NAMESPACE_3_1_END + + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::intrusive_ptr; +using v3_1::intrusive_ptr_add_ref; +using v3_1::intrusive_ptr_release; +using v3_1::RefCnt; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/simd.h b/src/include/OpenImageIO/simd.h index 11578c1b7c..9bb0b97093 100644 --- a/src/include/OpenImageIO/simd.h +++ b/src/include/OpenImageIO/simd.h @@ -281,7 +281,7 @@ #endif -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace simd { @@ -10284,41 +10284,37 @@ OIIO_FORCEINLINE vfloat16 nmsub (const simd::vfloat16& a, const simd::vfloat16& } // end namespace simd -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END /// Custom fmtlib formatters for our SIMD types. -namespace fmt { -template<> struct formatter +template<> struct fmt::formatter : OIIO::pvt::index_formatter {}; -template<> struct formatter +template<> struct fmt::formatter : OIIO::pvt::index_formatter {}; -template<> struct formatter +template<> struct fmt::formatter : OIIO::pvt::index_formatter {}; -template<> struct formatter +template<> struct fmt::formatter : OIIO::pvt::index_formatter {}; -template<> struct formatter +template<> struct fmt::formatter : OIIO::pvt::index_formatter {}; -template<> struct formatter +template<> struct fmt::formatter : OIIO::pvt::index_formatter {}; -template<> struct formatter +template<> struct fmt::formatter : OIIO::pvt::index_formatter {}; -template<> struct formatter +template<> struct fmt::formatter : OIIO::pvt::array_formatter {}; -} // namespace fmt // Allow C++ metaprogramming to understand that the simd types are trivially // copyable (i.e. memcpy to copy simd types is fine). -namespace std { // not necessary in C++17, just say std::is_trivially_copyable #if defined(__INTEL_COMPILER) // Necessary because we have to define the vint types copy constructors on icc -template<> struct is_trivially_copyable : std::true_type {}; -template<> struct is_trivially_copyable : std::true_type {}; -template<> struct is_trivially_copyable : std::true_type {}; +template<> struct std::is_trivially_copyable : std::true_type {}; +template<> struct std::is_trivially_copyable : std::true_type {}; +template<> struct std::is_trivially_copyable : std::true_type {}; #endif -} // namespace std #undef SIMD_DO diff --git a/src/include/OpenImageIO/span.h b/src/include/OpenImageIO/span.h index 72c6bc2d40..f1c49dafdc 100644 --- a/src/include/OpenImageIO/span.h +++ b/src/include/OpenImageIO/span.h @@ -26,8 +26,6 @@ // https://github.com/tcbrindle/span/blob/master/include/tcb/span.hpp -OIIO_NAMESPACE_BEGIN - // Our pre-3.0 implementation had span::size() as a signed value, because we // wrote it at a time that the draft of std::span said it should be signed. // The final C++20 std::span ended up with an unsigned size, like all the @@ -38,8 +36,10 @@ OIIO_NAMESPACE_BEGIN # define OIIO_SPAN_SIZE_IS_UNSIGNED #endif +OIIO_NAMESPACE_3_1_BEGIN + using span_size_t = size_t; -using oiio_span_size_type = OIIO::span_size_t; // back-compat alias +using oiio_span_size_type = span_size_t; // back-compat alias inline constexpr span_size_t dynamic_extent = std::numeric_limits::max(); @@ -263,6 +263,30 @@ class span { return const_reverse_iterator(m_data - 1); } + /// Compare all elements of two spans for equality + template + constexpr bool operator==(span r) { +#if OIIO_CPLUSPLUS_VERSION >= 20 + return std::equal (begin(), end(), r.begin(), r.end()); +#else + auto lsize = size(); + bool same = (lsize == r.size()); + if (lsize != r.size()) + return false; + for (span_size_t i = 0; i < lsize; ++i) + same &= (m_data[i] == r.m_data[i]); + // Note: If they're not the same size, the body of the loop won't run, + // so there can't be a buffer overrun here. + return same; +#endif + } + + /// Compare all elements of two spans for inequality + template + constexpr bool operator!= (span r) { + return !((*this) == r); + } + private: pointer m_data = nullptr; size_type m_size = 0; @@ -276,27 +300,6 @@ using cspan = span; -/// Compare all elements of two spans for equality -template -constexpr bool operator== (span l, span r) { -#if OIIO_CPLUSPLUS_VERSION >= 20 - return std::equal (l.begin(), l.end(), r.begin(), r.end()); -#else - auto lsize = l.size(); - bool same = (lsize == r.size()); - for (span_size_t i = 0; same && i < lsize; ++i) - same &= (l[i] == r[i]); - return same; -#endif -} - -/// Compare all elements of two spans for inequality -template -constexpr bool operator!= (span l, span r) { - return !(l == r); -} - - /// span_strided : a non-owning, mutable reference to a contiguous /// array with known length and optionally non-default strides through the @@ -385,6 +388,26 @@ class span_strided { constexpr reference back() const noexcept { return (*this)[size()-1]; } constexpr pointer data() const noexcept { return m_data; } + /// Compare all elements of two spans for equality + template + constexpr bool operator== (span_strided r) { + auto lsize = size(); + if (lsize != r.size()) + return false; + for (span_size_t i = 0; i < lsize; ++i) + if ((*this)[i] != r[i]) + return false; + // Note: If they're not the same size, the body of the loop won't run, + // so there can't be a buffer overrun here. + return true; + } + + /// Compare all elements of two spans for inequality + template + constexpr bool operator!= (span_strided r) { + return !((*this) == r); + } + private: pointer m_data = nullptr; size_type m_size = 0; @@ -399,25 +422,6 @@ using cspan_strided = span_strided; -/// Compare all elements of two spans for equality -template -constexpr bool operator== (span_strided l, span_strided r) { - auto lsize = l.size(); - if (lsize != r.size()) - return false; - for (span_size_t i = 0; i < lsize; ++i) - if (l[i] != r[i]) - return false; - return true; -} - -/// Compare all elements of two spans for inequality -template -constexpr bool operator!= (span_strided l, span_strided r) { - return !(l == r); -} - - // clang-format on @@ -712,6 +716,34 @@ check_span(span s, const PtrType* ptr, size_t len = 1) } +OIIO_NAMESPACE_3_1_END + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::as_bytes; +using v3_1::as_bytes_ref; +using v3_1::as_writable_bytes; +using v3_1::check_span; +using v3_1::cspan; +using v3_1::cspan_strided; +using v3_1::dynamic_extent; +using v3_1::make_cspan; +using v3_1::make_span; +using v3_1::oiio_span_size_type; +using v3_1::span; +using v3_1::span_cast; +using v3_1::span_memcpy; +using v3_1::span_size_t; +using v3_1::span_strided; +using v3_1::span_within; +using v3_1::spancpy; +using v3_1::spanset; +using v3_1::spanzero; +#endif +OIIO_NAMESPACE_END + /// OIIO_ALLOCASPAN is used to allocate smallish amount of memory on the /// stack, equivalent of C99 type var_name[size], and then return a span @@ -719,9 +751,6 @@ check_span(span s, const PtrType* ptr, size_t len = 1) #define OIIO_ALLOCA_SPAN(type, size) span(OIIO_ALLOCA(type, size), size) -OIIO_NAMESPACE_END - - // Declare std::size and std::ssize for our span. namespace std { diff --git a/src/include/OpenImageIO/strided_ptr.h b/src/include/OpenImageIO/strided_ptr.h index b210088fdb..bac6ec71c5 100644 --- a/src/include/OpenImageIO/strided_ptr.h +++ b/src/include/OpenImageIO/strided_ptr.h @@ -11,7 +11,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// strided_ptr looks like a 'T*', but it incorporates a stride, so @@ -133,5 +133,12 @@ template class strided_ptr { }; +OIIO_NAMESPACE_3_1_END + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::strided_ptr; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/string_view.h b/src/include/OpenImageIO/string_view.h index 2d5048fcd9..b959bb9d5d 100644 --- a/src/include/OpenImageIO/string_view.h +++ b/src/include/OpenImageIO/string_view.h @@ -32,7 +32,7 @@ #endif -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// A `string_view` is a non-owning, non-copying, non-allocating reference @@ -509,11 +509,22 @@ OIIO_UTIL_API const char* c_str(string_view str); // DEPRECATED(3.0) template<> inline const char* basic_string_view::c_str() const { - return OIIO::c_str(*this); + return OIIO::v3_1::c_str(*this); } +OIIO_NAMESPACE_3_1_END + + +// Compatibility +#ifndef OIIO_DOXYGEN +OIIO_NAMESPACE_BEGIN +using v3_1::basic_string_view; +using v3_1::c_str; +using v3_1::string_view; +using v3_1::wstring_view; OIIO_NAMESPACE_END +#endif #if FMT_VERSION >= 100000 diff --git a/src/include/OpenImageIO/strongparam.h b/src/include/OpenImageIO/strongparam.h index 9126a49973..62a287e7bb 100644 --- a/src/include/OpenImageIO/strongparam.h +++ b/src/include/OpenImageIO/strongparam.h @@ -9,7 +9,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// StrongParam is used to construct an implementation of a derived type @@ -110,6 +110,7 @@ template struct StrongParam { static_assert(std::is_trivial::value, "Need trivial type"); }; +OIIO_NAMESPACE_3_1_END /// Convenience macro for making strong parameter type Name that is Basetype @@ -121,4 +122,10 @@ template struct StrongParam { } + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::StrongParam; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/strutil.h b/src/include/OpenImageIO/strutil.h index 32d5af41bd..c446c49689 100644 --- a/src/include/OpenImageIO/strutil.h +++ b/src/include/OpenImageIO/strutil.h @@ -56,7 +56,8 @@ -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN + /// @namespace Strutil /// /// @brief String-related utilities. @@ -690,6 +691,14 @@ template<> inline uint64_t from_string(string_view s) { auto r = strtoull(std::string(s).c_str(), nullptr, 10); return static_cast(r); } + +template<> inline short from_string(string_view s) { + return static_cast(Strutil::stoi(s)); +} + +template<> inline unsigned short from_string(string_view s) { + return static_cast(Strutil::stoi(s)); +} #endif @@ -1163,7 +1172,11 @@ eval_as_bool(string_view value); } // namespace Strutil +OIIO_NAMESPACE_3_1_END + + +// Compatibility +OIIO_NAMESPACE_BEGIN // Bring the ever-useful Strutil::print into the OIIO namespace. using Strutil::print; - OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/sysutil.h b/src/include/OpenImageIO/sysutil.h index 16d587668c..00552ff396 100644 --- a/src/include/OpenImageIO/sysutil.h +++ b/src/include/OpenImageIO/sysutil.h @@ -30,7 +30,7 @@ -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// @namespace Sysutil /// @@ -186,4 +186,4 @@ class OIIO_UTIL_API Term { } // namespace Sysutil -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/include/OpenImageIO/texture.h b/src/include/OpenImageIO/texture.h index e79558e10d..ef9d5a84f8 100644 --- a/src/include/OpenImageIO/texture.h +++ b/src/include/OpenImageIO/texture.h @@ -44,23 +44,7 @@ OIIO_CONCAT_VERSION(TextureOptBatch_v, OIIO_TEXTUREOPTBATCH_VERSION) -#ifndef INCLUDED_IMATHVEC_H -// Placeholder declaration for Imath::V3f if no Imath headers have been -// included. -namespace Imath { -template class Vec3; -using V3f = Vec3; -} -#endif - - -OIIO_NAMESPACE_BEGIN - -// Forward declarations - -class ImageCache; -class TextureSystemImpl; - +OIIO_NAMESPACE_3_1_BEGIN namespace pvt { @@ -289,7 +273,7 @@ class OIIO_API TextureOpt_v2 { }; -using TextureOpt = TextureOpt_current; +using TextureOpt = TextureOpt_v2; @@ -1782,5 +1766,19 @@ class OIIO_API TextureSystem { // Always use TextureSystem::create() and TextureSystem::destroy(). }; +OIIO_NAMESPACE_3_1_END + + +// Compatibility +#ifndef OIIO_DOXYGEN +OIIO_NAMESPACE_BEGIN +namespace Tex { +using namespace v3_1::Tex; +} +namespace pvt { +using v3_1::pvt::EnvLayout; +using v3_1::pvt::TexFormat; +} // namespace pvt OIIO_NAMESPACE_END +#endif diff --git a/src/include/OpenImageIO/thread.h b/src/include/OpenImageIO/thread.h index 18b8c30ffb..b2af0b4122 100644 --- a/src/include/OpenImageIO/thread.h +++ b/src/include/OpenImageIO/thread.h @@ -54,8 +54,7 @@ // http://en.cppreference.com/w/cpp/atomic - -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// Null mutex that can be substituted for a real one to test how much /// overhead is associated with a particular mutex. @@ -82,9 +81,9 @@ template class null_lock { using std::mutex; using std::recursive_mutex; using std::thread; -typedef std::lock_guard lock_guard; -typedef std::lock_guard recursive_lock_guard; -typedef std::lock_guard recursive_timed_lock_guard; +using lock_guard = std::lock_guard; +using recursive_lock_guard = std::lock_guard; +using recursive_timed_lock_guard = std::lock_guard; @@ -270,128 +269,9 @@ class spin_mutex { }; -typedef spin_mutex::lock_guard spin_lock; - - - -#if 0 - -// OLD CODE vvvvvvvv - - -/// Spinning reader/writer mutex. This is just like spin_mutex, except -/// that there are separate locking mechanisms for "writers" (exclusive -/// holders of the lock, presumably because they are modifying whatever -/// the lock is protecting) and "readers" (non-exclusive, non-modifying -/// tasks that may access the protectee simultaneously). -class spin_rw_mutex { -public: - /// Default constructor -- initialize to unlocked. - /// - spin_rw_mutex (void) { m_readers = 0; } - - ~spin_rw_mutex (void) { } - - /// Copy constructor -- initialize to unlocked. - /// - spin_rw_mutex (const spin_rw_mutex &) { m_readers = 0; } - - /// Assignment does not do anything, since lockedness should not - /// transfer. - const spin_rw_mutex& operator= (const spin_rw_mutex&) { return *this; } - - /// Acquire the reader lock. - /// - void read_lock () { - // Spin until there are no writers active - m_locked.lock(); - // Register ourself as a reader - ++m_readers; - // Release the lock, to let other readers work - m_locked.unlock(); - } - - /// Release the reader lock. - /// - void read_unlock () { - --m_readers; // it's atomic, no need to lock to release - } - - /// Acquire the writer lock. - /// - void write_lock () { - // Make sure no new readers (or writers) can start - m_locked.lock(); - // Spin until the last reader is done, at which point we will be - // the sole owners and nobody else (reader or writer) can acquire - // the resource until we release it. -#if OIIO_THREAD_ALLOW_DCLP - while (*(volatile int *)&m_readers > 0) - ; -#else - while (m_readers > 0) - ; -#endif - } - - /// Release the writer lock. - /// - void write_unlock () { - // Let other readers or writers get the lock - m_locked.unlock (); - } - - /// Acquire an exclusive ("writer") lock. - void lock () { write_lock(); } - - /// Release an exclusive ("writer") lock. - void unlock () { write_unlock(); } - - /// Acquire a shared ("reader") lock. - void lock_shared () { read_lock(); } - - /// Release a shared ("reader") lock. - void unlock_shared () { read_unlock(); } - - /// Helper class: scoped read lock for a spin_rw_mutex -- grabs the - /// read lock upon construction, releases the lock when it exits scope. - class read_lock_guard { - public: - read_lock_guard (spin_rw_mutex &fm) : m_fm(fm) { m_fm.read_lock(); } - ~read_lock_guard () { m_fm.read_unlock(); } - private: - read_lock_guard(); // Do not implement - read_lock_guard(const read_lock_guard& other); // Do not implement - read_lock_guard& operator = (const read_lock_guard& other); // Do not implement - spin_rw_mutex & m_fm; - }; - - /// Helper class: scoped write lock for a spin_rw_mutex -- grabs the - /// read lock upon construction, releases the lock when it exits scope. - class write_lock_guard { - public: - write_lock_guard (spin_rw_mutex &fm) : m_fm(fm) { m_fm.write_lock(); } - ~write_lock_guard () { m_fm.write_unlock(); } - private: - write_lock_guard(); // Do not implement - write_lock_guard(const write_lock_guard& other); // Do not implement - write_lock_guard& operator = (const write_lock_guard& other); // Do not implement - spin_rw_mutex & m_fm; - }; - -private: - OIIO_CACHE_ALIGN - spin_mutex m_locked; // write lock - char pad1_[OIIO_CACHE_LINE_SIZE-sizeof(spin_mutex)]; - OIIO_CACHE_ALIGN - atomic_int m_readers; // number of readers - char pad2_[OIIO_CACHE_LINE_SIZE-sizeof(atomic_int)]; -}; - +using spin_lock = spin_mutex::lock_guard; -#else -// vvv New spin rw lock Oct 2017 /// Spinning reader/writer mutex. This is just like spin_mutex, except /// that there are separate locking mechanisms for "writers" (exclusive @@ -511,11 +391,10 @@ class spin_rw_mutex { std::atomic m_bits { 0 }; }; -#endif -typedef spin_rw_mutex::read_lock_guard spin_rw_read_lock; -typedef spin_rw_mutex::write_lock_guard spin_rw_write_lock; +using spin_rw_read_lock = spin_rw_mutex::read_lock_guard; +using spin_rw_write_lock = spin_rw_mutex::write_lock_guard; @@ -859,4 +738,38 @@ class OIIO_UTIL_API task_set { }; +OIIO_NAMESPACE_3_1_END + + + +// Compatibility -- current version just reuses these old items +// clang-format off +#ifndef OIIO_DOXYGEN +OIIO_NAMESPACE_BEGIN +using v3_1::atomic_backoff; +using v3_1::default_thread_pool; +using v3_1::default_thread_pool_shutdown; +using v3_1::mutex_pool; +using v3_1::null_mutex; +using v3_1::null_lock; +using v3_1::pause; +using v3_1::spin_mutex; +using v3_1::spin_rw_mutex; +using v3_1::task_set; +using v3_1::thread_group; +using v3_1::thread_pool; +using v3_1::yield; + +using std::mutex; +using std::recursive_mutex; +using std::thread; + +using lock_guard = std::lock_guard; +using recursive_lock_guard = std::lock_guard; +using recursive_timed_lock_guard = std::lock_guard; +using spin_lock = spin_mutex::lock_guard; +using spin_rw_read_lock = spin_rw_mutex::read_lock_guard; +using spin_rw_write_lock = spin_rw_mutex::write_lock_guard; OIIO_NAMESPACE_END +#endif +// clang-format on diff --git a/src/include/OpenImageIO/tiffutils.h b/src/include/OpenImageIO/tiffutils.h index 0803634271..c631665b5d 100644 --- a/src/include/OpenImageIO/tiffutils.h +++ b/src/include/OpenImageIO/tiffutils.h @@ -130,7 +130,10 @@ enum TIFFTAG { EXIF_GAMMA = 42240, }; +OIIO_NAMESPACE_END + +OIIO_NAMESPACE_3_1_BEGIN /// Given a TIFF data type code (defined in tiff.h) and a count, return the /// equivalent TypeDesc where one exists. Return TypeUnknown if there is no @@ -250,5 +253,25 @@ OIIO_API const TagInfo* tag_lookup (string_view domain, int tag); OIIO_API const TagInfo* tag_lookup (string_view domain, string_view tagname); +OIIO_NAMESPACE_3_1_END + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::decode_exif; +using v3_1::decode_icc_profile; +using v3_1::decode_iptc_iim; +using v3_1::decode_xmp; +using v3_1::encode_iptc_iim; +using v3_1::encode_xmp; +using v3_1::exif_tag_lookup; +using v3_1::tag_lookup; +using v3_1::tag_table; +using v3_1::TagInfo; +using v3_1::tiff_data_size; +using v3_1::tiff_datatype_to_typedesc; +using v3_1::tiff_dir_data; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/timer.h b/src/include/OpenImageIO/timer.h index bc5d361256..04929ab14f 100644 --- a/src/include/OpenImageIO/timer.h +++ b/src/include/OpenImageIO/timer.h @@ -30,7 +30,7 @@ #define OIIO_TIMER_LINUX_USE_clock_gettime 1 -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN /// Simple timer class. /// @@ -275,4 +275,4 @@ class ScopedTimer { -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/include/OpenImageIO/type_traits.h b/src/include/OpenImageIO/type_traits.h index a4ce7fd362..149f176544 100644 --- a/src/include/OpenImageIO/type_traits.h +++ b/src/include/OpenImageIO/type_traits.h @@ -15,8 +15,6 @@ #include #include -OIIO_NAMESPACE_BEGIN - // An enable_if helper to be used in template parameters which results in // much shorter symbols: https://godbolt.org/z/sWw4vP @@ -26,6 +24,8 @@ OIIO_NAMESPACE_BEGIN #endif +OIIO_NAMESPACE_3_1_BEGIN + /// has_size_method::value is true if T has a size() method and it returns /// an integral type. template struct has_size_method : std::false_type { }; @@ -45,6 +45,14 @@ template struct has_subscript()[0])>> : std::true_type { }; +OIIO_NAMESPACE_3_1_END + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::has_size_method; +using v3_1::has_subscript; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/typedesc.h b/src/include/OpenImageIO/typedesc.h index 91aa88ccc9..04bf3f9a8c 100644 --- a/src/include/OpenImageIO/typedesc.h +++ b/src/include/OpenImageIO/typedesc.h @@ -34,7 +34,7 @@ -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN ///////////////////////////////////////////////////////////////////////////// /// A TypeDesc describes simple data types. @@ -434,7 +434,6 @@ template<> struct BaseTypeFromC { static constexpr TypeDesc::BASETY template<> struct BaseTypeFromC { static constexpr TypeDesc::BASETYPE value = TypeDesc::STRING; }; template<> struct BaseTypeFromC { static constexpr TypeDesc::BASETYPE value = TypeDesc::STRING; }; template<> struct BaseTypeFromC { static constexpr TypeDesc::BASETYPE value = TypeDesc::STRING; }; -class ustring; template<> struct BaseTypeFromC { static constexpr TypeDesc::BASETYPE value = TypeDesc::STRING; }; template<> struct BaseTypeFromC { static constexpr TypeDesc::BASETYPE value = TypeDesc::STRING; }; template struct BaseTypeFromC { static constexpr TypeDesc::BASETYPE value = TypeDesc::STRING; }; @@ -497,8 +496,6 @@ template<> struct TypeDescFromC { static const constexpr TypeDesc template constexpr TypeDesc TypeDescFromC_v = TypeDescFromC>::value(); -class ustringhash; // forward declaration - /// A template mechanism for getting C type of TypeDesc::BASETYPE. @@ -594,7 +591,7 @@ tostring(TypeDesc type, const void* data, const tostring_formatting& fmt = {}); /// * If dsttype is int32 or uint32: other integer types will do their best /// (caveat emptor if you mix signed/unsigned). Also a source string will /// convert to int if and only if its characters form a valid integer. -/// * If dsttype is float: inteegers and other float types will do +/// * If dsttype is float: integers and other float types will do /// their best conversion; strings will convert if and only if their /// characters form a valid float number. OIIO_UTIL_API bool @@ -602,19 +599,68 @@ convert_type(TypeDesc srctype, const void* src, TypeDesc dsttype, void* dst, int n = 1); +OIIO_NAMESPACE_3_1_END + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::tostring_formatting; +using v3_1::tostring; +using v3_1::convert_type; +using v3_1::BaseTypeFromC; +using v3_1::BaseTypeFromC_v; +using v3_1::TypeDescFromC; +using v3_1::TypeDescFromC_v; +using v3_1::CType; + +using v3_1::TypeUnknown; +using v3_1::TypeFloat; +using v3_1::TypeColor; +using v3_1::TypePoint; +using v3_1::TypeVector; +using v3_1::TypeNormal; +using v3_1::TypeMatrix33; +using v3_1::TypeMatrix44; +using v3_1::TypeMatrix; +using v3_1::TypeFloat2; +using v3_1::TypeVector2; +using v3_1::TypeFloat4; +using v3_1::TypeVector4; +using v3_1::TypeString; +using v3_1::TypeInt; +using v3_1::TypeUInt; +using v3_1::TypeInt32; +using v3_1::TypeUInt32; +using v3_1::TypeInt16; +using v3_1::TypeUInt16; +using v3_1::TypeInt8; +using v3_1::TypeUInt8; +using v3_1::TypeInt64; +using v3_1::TypeUInt64; +using v3_1::TypeVector2i; +using v3_1::TypeVector3i; +using v3_1::TypeBox2; +using v3_1::TypeBox3; +using v3_1::TypeBox2i; +using v3_1::TypeBox3i; +using v3_1::TypeHalf; +using v3_1::TypeTimeCode; +using v3_1::TypeKeyCode; +using v3_1::TypeRational; +using v3_1::TypePointer; +using v3_1::TypeUstringhash; +#endif OIIO_NAMESPACE_END // Supply a fmtlib compatible custom formatter for TypeDesc. #if FMT_VERSION >= 100000 -FMT_BEGIN_NAMESPACE -template<> struct formatter : ostream_formatter {}; -FMT_END_NAMESPACE +template<> struct fmt::formatter : ostream_formatter {}; #else -FMT_BEGIN_NAMESPACE template <> -struct formatter { +struct fmt::formatter { // Parses format specification // C++14: constexpr auto parse(format_parse_context& ctx) const { auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) // c++11 @@ -640,5 +686,4 @@ struct formatter { return format_to(ctx.out(), "{}", t.c_str()); } }; -FMT_END_NAMESPACE #endif diff --git a/src/include/OpenImageIO/unordered_map_concurrent.h b/src/include/OpenImageIO/unordered_map_concurrent.h index 95eb6c6d65..2c82981185 100644 --- a/src/include/OpenImageIO/unordered_map_concurrent.h +++ b/src/include/OpenImageIO/unordered_map_concurrent.h @@ -9,7 +9,7 @@ #include #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace pvt { @@ -599,4 +599,12 @@ class unordered_map_concurrent { }; +OIIO_NAMESPACE_3_1_END + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::unordered_map_concurrent; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/ustring.h b/src/include/OpenImageIO/ustring.h index 2d82d6bd10..aba90ffdf5 100644 --- a/src/include/OpenImageIO/ustring.h +++ b/src/include/OpenImageIO/ustring.h @@ -25,8 +25,6 @@ #include -OIIO_NAMESPACE_BEGIN - // Feature tests #define OIIO_USTRING_HAS_USTRINGHASH 1 #define OIIO_USTRING_HAS_CTR_FROM_USTRINGHASH 1 @@ -34,8 +32,7 @@ OIIO_NAMESPACE_BEGIN #define OIIO_HAS_USTRINGHASH_FORMATTER 1 -class ustringhash; // forward declaration - +OIIO_NAMESPACE_3_1_BEGIN /// A ustring is an alternative to char* or std::string for storing @@ -1008,8 +1005,12 @@ inline ustring::ustring(ustringhash hash) } #endif +OIIO_NAMESPACE_3_1_END + +OIIO_NAMESPACE_BEGIN + /// ustring string literal operator inline ustring operator""_us(const char* str, std::size_t len) @@ -1025,8 +1026,11 @@ operator""_ush(const char* str, std::size_t len) return ustringhash(str, len); } +OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_BEGIN + /// Functor class to use for comparisons when sorting ustrings, if you /// want the strings sorted lexicographically. class ustringLess { @@ -1101,6 +1105,17 @@ to_string(const ustringhash& value) } // end namespace Strutil +OIIO_NAMESPACE_3_1_END + + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::iequals; +using v3_1::ustringLess; +using v3_1::ustringPtrIsLess; +#endif OIIO_NAMESPACE_END diff --git a/src/include/OpenImageIO/vecparam.h b/src/include/OpenImageIO/vecparam.h index b2bf70c6cc..bd47d78851 100644 --- a/src/include/OpenImageIO/vecparam.h +++ b/src/include/OpenImageIO/vecparam.h @@ -11,7 +11,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN // NOTE: These interoperable type templates were copied from the // [Imath project](http://github.com/AcademySoftwareFoundation/imath), @@ -388,4 +388,22 @@ using M33fParam = MatrixParam; using M44fParam = MatrixParam; +OIIO_NAMESPACE_3_1_END + + + +// Compatibility +OIIO_NAMESPACE_BEGIN +#ifndef OIIO_DOXYGEN +using v3_1::has_double_subscript_RC; +using v3_1::has_subscript_N; +using v3_1::has_xy; +using v3_1::has_xyz; +using v3_1::has_xyzw; +using v3_1::M33fParam; +using v3_1::M44fParam; +using v3_1::MatrixParam; +using v3_1::V3fParam; +using v3_1::Vec3Param; +#endif OIIO_NAMESPACE_END diff --git a/src/include/imageio_pvt.h b/src/include/imageio_pvt.h index ae28898fa3..273375cd77 100644 --- a/src/include/imageio_pvt.h +++ b/src/include/imageio_pvt.h @@ -4,7 +4,7 @@ /// \file -/// Declarations for things that are used privately by ImageIO. +/// Declarations for things that are used privately by OpenImageIO. #ifndef OPENIMAGEIO_IMAGEIO_PVT_H @@ -17,11 +17,10 @@ OIIO_NAMESPACE_BEGIN - -namespace ImageBufAlgo { -struct PixelStats; -} - +// Note: Everything in pvt namespace is expected to be local to the library +// and does not appear in exported headers that client software will see. +// Therefore, it should all stay in the current namespace except where +// specifically noted. namespace pvt { diff --git a/src/libOpenImageIO/color_ocio.cpp b/src/libOpenImageIO/color_ocio.cpp index 03623221de..26f45c8d2b 100644 --- a/src/libOpenImageIO/color_ocio.cpp +++ b/src/libOpenImageIO/color_ocio.cpp @@ -29,7 +29,7 @@ namespace OCIO = OCIO_NAMESPACE; -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace { // Some test colors we use to interrogate transformations @@ -806,7 +806,7 @@ ColorConfig::Impl::init(string_view filename) filename = Sysutil::getenv("OCIO"); if (filename.empty() && !disable_builtin_configs) filename = "ocio://default"; - if (filename.size() && !Filesystem::exists(filename) + if (filename.size() && !OIIO::Filesystem::exists(filename) && !Strutil::istarts_with(filename, "ocio://")) { error("Requested non-existent OCIO config \"{}\"", filename); } else { @@ -867,7 +867,7 @@ ColorConfig::Impl::init(string_view filename) bool ColorConfig::reset(string_view filename) { - pvt::LoggedTimer logtime("ColorConfig::reset"); + OIIO::pvt::LoggedTimer logtime("ColorConfig::reset"); if (m_impl && (filename == getImpl()->configname() || (filename == "" @@ -2010,7 +2010,7 @@ ImageBufAlgo::colorconvert(ImageBuf& dst, const ImageBuf& src, string_view from, const ColorConfig* colorconfig, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::colorconvert"); + OIIO::pvt::LoggedTimer logtime("IBA::colorconvert"); if (from.empty() || from == "current") { from = src.spec().get_string_attribute("oiio:Colorspace", "scene_linear"); @@ -2071,7 +2071,7 @@ ImageBufAlgo::colormatrixtransform(ImageBuf& dst, const ImageBuf& src, M44fParam M, bool unpremult, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::colormatrixtransform"); + OIIO::pvt::LoggedTimer logtime("IBA::colormatrixtransform"); ColorProcessorHandle processor = ColorConfig::default_colorconfig().createMatrixTransform(M); logtime.stop(); // transition to other colorconvert @@ -2253,7 +2253,7 @@ ImageBufAlgo::colorconvert(ImageBuf& dst, const ImageBuf& src, const ColorProcessor* processor, bool unpremult, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::colorconvert"); + OIIO::pvt::LoggedTimer logtime("IBA::colorconvert"); // If the processor is NULL, return false (error) if (!processor) { dst.errorfmt( @@ -2318,7 +2318,7 @@ ImageBufAlgo::ociolook(ImageBuf& dst, const ImageBuf& src, string_view looks, bool inverse, string_view key, string_view value, const ColorConfig* colorconfig, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::ociolook"); + OIIO::pvt::LoggedTimer logtime("IBA::ociolook"); if (from.empty() || from == "current") { auto linearspace = colorconfig->resolve("scene_linear"); from = src.spec().get_string_attribute("oiio:Colorspace", linearspace); @@ -2381,7 +2381,7 @@ ImageBufAlgo::ociodisplay(ImageBuf& dst, const ImageBuf& src, bool inverse, string_view key, string_view value, const ColorConfig* colorconfig, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::ociodisplay"); + OIIO::pvt::LoggedTimer logtime("IBA::ociodisplay"); ColorProcessorHandle processor; { if (!colorconfig) @@ -2453,7 +2453,7 @@ ImageBufAlgo::ociofiletransform(ImageBuf& dst, const ImageBuf& src, const ColorConfig* colorconfig, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::ociofiletransform"); + OIIO::pvt::LoggedTimer logtime("IBA::ociofiletransform"); if (name.empty()) { dst.errorfmt("Unknown filetransform name"); return false; @@ -2512,7 +2512,7 @@ ImageBufAlgo::ocionamedtransform(ImageBuf& dst, const ImageBuf& src, const ColorConfig* colorconfig, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::ocionamedtransform"); + OIIO::pvt::LoggedTimer logtime("IBA::ocionamedtransform"); ColorProcessorHandle processor; { if (!colorconfig) diff --git a/src/libOpenImageIO/deepdata.cpp b/src/libOpenImageIO/deepdata.cpp index a06661d633..35b9ebc8c0 100644 --- a/src/libOpenImageIO/deepdata.cpp +++ b/src/libOpenImageIO/deepdata.cpp @@ -16,7 +16,7 @@ #include #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN // Each pixel has a capacity (number of samples allocated) and a number of @@ -32,6 +32,9 @@ OIIO_NAMESPACE_BEGIN class DeepData::Impl { // holds all the nontrivial stuff + // NOTE: Because the definition of DeepData::Impl is not exposed + // externally, it can change at will even though it's inside the v3_1 + // namespace. friend class DeepData; public: @@ -1273,4 +1276,4 @@ DeepData::occlusion_cull(int64_t pixel) } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/exif.cpp b/src/libOpenImageIO/exif.cpp index 5b3252c88b..ccf63979a5 100644 --- a/src/libOpenImageIO/exif.cpp +++ b/src/libOpenImageIO/exif.cpp @@ -119,7 +119,10 @@ TagMap::mapname() const return m_impl->m_mapname; } +OIIO_NAMESPACE_END + +OIIO_NAMESPACE_3_1_BEGIN const TagInfo* tag_lookup(string_view domain, int tag) @@ -229,8 +232,11 @@ tiff_dir_data(const TIFFDirEntry& td, cspan data) return cspan(data.data() + begin, len); } +OIIO_NAMESPACE_3_1_END +OIIO_NAMESPACE_BEGIN + #if DEBUG_EXIF_READ || DEBUG_EXIF_WRITE static bool print_dir_entry(std::ostream& out, const TagMap& tagmap, @@ -613,7 +619,10 @@ pvt::gps_tagmap_ref() return T; } +OIIO_NAMESPACE_END + +OIIO_NAMESPACE_3_1_BEGIN cspan tag_table(string_view tablename) @@ -626,6 +635,10 @@ tag_table(string_view tablename) return cspan(tiff_tag_table); } +OIIO_NAMESPACE_3_1_END + + +OIIO_NAMESPACE_BEGIN /// Add one EXIF directory entry's data to spec under the given 'name'. @@ -1152,6 +1165,10 @@ pvt::append_tiff_dir_entry(std::vector& dirs, } +OIIO_NAMESPACE_END + + +OIIO_NAMESPACE_3_1_BEGIN bool decode_exif(string_view exif, ImageSpec& spec) @@ -1236,8 +1253,8 @@ decode_exif(cspan exif, ImageSpec& spec) if (makernote_offset > 0) { if (Strutil::iequals(spec.get_string_attribute("Make"), "Canon")) { if (!decode_ifd(exif, makernote_offset, spec, - pvt::canon_maker_tagmap_ref(), ifd_offsets_seen, - swab)) + OIIO::pvt::canon_maker_tagmap_ref(), + ifd_offsets_seen, swab)) return false; } // Now we can erase the attrib we used to pass the message about @@ -1360,7 +1377,7 @@ encode_exif(const ImageSpec& spec, std::vector& blob, // If we're a canon camera, construct the dirs for the Makernote, // with the data adding to the main blob. if (Strutil::iequals(spec.get_string_attribute("Make"), "Canon")) - pvt::encode_canon_makernote(blob, makerdirs, spec, tiffstart); + OIIO::pvt::encode_canon_makernote(blob, makerdirs, spec, tiffstart); #if DEBUG_EXIF_WRITE std::cerr << "Blob header size " << blob.size() << "\n"; @@ -1526,5 +1543,4 @@ exif_tag_lookup(string_view name, int& tag, int& tifftype, int& count) return true; } - -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/formatspec.cpp b/src/libOpenImageIO/formatspec.cpp index ec317e0f14..81374b9624 100644 --- a/src/libOpenImageIO/formatspec.cpp +++ b/src/libOpenImageIO/formatspec.cpp @@ -97,6 +97,10 @@ pvt::get_default_quantize(TypeDesc format, long long& quant_min, } } +OIIO_NAMESPACE_END + + +OIIO_NAMESPACE_3_1_BEGIN ImageSpec::ImageSpec(TypeDesc format) noexcept @@ -659,8 +663,11 @@ ImageSpec::channelindex(string_view name) const return -1; } +OIIO_NAMESPACE_3_1_END +OIIO_NAMESPACE_BEGIN + std::string pvt::explain_justprint(const ParamValue& p, const void* extradata) { @@ -910,7 +917,10 @@ static ExplanationTableEntry explanation[] = { } // namespace +OIIO_NAMESPACE_END + +OIIO_NAMESPACE_3_1_BEGIN std::string ImageSpec::metadata_val(const ParamValue& p, bool human) @@ -1263,6 +1273,76 @@ ImageSpec::decode_compression_metadata(string_view defaultcomp, +void +ImageSpec::set_colorspace(string_view colorspace) +{ + ColorConfig::default_colorconfig().set_colorspace(*this, colorspace); + // Invalidate potentially contradictory metadata + erase_attribute("CICP"); +} + + + +ROI +get_roi(const ImageSpec& spec) +{ + return ROI(spec.x, spec.x + spec.width, spec.y, spec.y + spec.height, + spec.z, spec.z + spec.depth, 0, spec.nchannels); +} + + + +ROI +get_roi_full(const ImageSpec& spec) +{ + return ROI(spec.full_x, spec.full_x + spec.full_width, spec.full_y, + spec.full_y + spec.full_height, spec.full_z, + spec.full_z + spec.full_depth, 0, spec.nchannels); +} + + + +void +set_roi(ImageSpec& spec, const ROI& newroi) +{ + spec.x = newroi.xbegin; + spec.y = newroi.ybegin; + spec.z = newroi.zbegin; + spec.width = newroi.width(); + spec.height = newroi.height(); + spec.depth = newroi.depth(); +} + + + +void +set_roi_full(ImageSpec& spec, const ROI& newroi) +{ + spec.full_x = newroi.xbegin; + spec.full_y = newroi.ybegin; + spec.full_z = newroi.zbegin; + spec.full_width = newroi.width(); + spec.full_height = newroi.height(); + spec.full_depth = newroi.depth(); +} + + + +template<> +size_t +pvt::heapsize(const ImageSpec& is) +{ + size_t size = pvt::heapsize(is.channelformats); + size += pvt::heapsize(is.channelnames); + size += pvt::heapsize(is.extra_attribs); + return size; +} + +OIIO_NAMESPACE_3_1_END + + +OIIO_NAMESPACE_BEGIN + bool pvt::check_texture_metadata_sanity(ImageSpec& spec) { @@ -1290,27 +1370,4 @@ pvt::check_texture_metadata_sanity(ImageSpec& spec) } - -void -ImageSpec::set_colorspace(string_view colorspace) -{ - ColorConfig::default_colorconfig().set_colorspace(*this, colorspace); - // Invalidate potentially contradictory metadata - erase_attribute("CICP"); -} - - - -template<> -size_t -pvt::heapsize(const ImageSpec& is) -{ - size_t size = pvt::heapsize(is.channelformats); - size += pvt::heapsize(is.channelnames); - size += pvt::heapsize(is.extra_attribs); - return size; -} - - - OIIO_NAMESPACE_END diff --git a/src/libOpenImageIO/icc.cpp b/src/libOpenImageIO/icc.cpp index a27ae35bbe..13d22478bc 100644 --- a/src/libOpenImageIO/icc.cpp +++ b/src/libOpenImageIO/icc.cpp @@ -232,7 +232,10 @@ extract(cspan iccdata, size_t& offset, ICCTag& result, } // namespace +OIIO_NAMESPACE_END + +OIIO_NAMESPACE_3_1_BEGIN bool decode_icc_profile(cspan iccdata, ImageSpec& spec, std::string& error) @@ -397,4 +400,4 @@ decode_icc_profile(cspan iccdata, ImageSpec& spec, std::string& error) return true; } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebuf.cpp b/src/libOpenImageIO/imagebuf.cpp index eab61a75cc..e25c1f1fc2 100644 --- a/src/libOpenImageIO/imagebuf.cpp +++ b/src/libOpenImageIO/imagebuf.cpp @@ -38,52 +38,10 @@ std::atomic IB_total_open_time(0.0f); std::atomic IB_total_image_read_time(0.0f); } // namespace pvt +OIIO_NAMESPACE_END -ROI -get_roi(const ImageSpec& spec) -{ - return ROI(spec.x, spec.x + spec.width, spec.y, spec.y + spec.height, - spec.z, spec.z + spec.depth, 0, spec.nchannels); -} - - - -ROI -get_roi_full(const ImageSpec& spec) -{ - return ROI(spec.full_x, spec.full_x + spec.full_width, spec.full_y, - spec.full_y + spec.full_height, spec.full_z, - spec.full_z + spec.full_depth, 0, spec.nchannels); -} - - - -void -set_roi(ImageSpec& spec, const ROI& newroi) -{ - spec.x = newroi.xbegin; - spec.y = newroi.ybegin; - spec.z = newroi.zbegin; - spec.width = newroi.width(); - spec.height = newroi.height(); - spec.depth = newroi.depth(); -} - - - -void -set_roi_full(ImageSpec& spec, const ROI& newroi) -{ - spec.full_x = newroi.xbegin; - spec.full_y = newroi.ybegin; - spec.full_z = newroi.zbegin; - spec.full_width = newroi.width(); - spec.full_height = newroi.height(); - spec.full_depth = newroi.depth(); -} - - +OIIO_NAMESPACE_3_1_BEGIN span span_from_buffer(void* data, TypeDesc format, int nchannels, int width, @@ -615,7 +573,7 @@ ImageBufImpl::~ImageBufImpl() // Upon destruction, print uncaught errors to help users who don't know // how to properly check for errors. if (!m_err.empty() /* Note: safe becausethis is the dtr */ - && pvt::imagebuf_print_uncaught_errors) { + && OIIO::pvt::imagebuf_print_uncaught_errors) { OIIO::print( "An ImageBuf was destroyed with a pending error message that was never\n" "retrieved via ImageBuf::geterror(). This was the error message:\n{}\n", @@ -782,16 +740,16 @@ ImageBufImpl::new_pixels(ImageBuf::IBStorage storage, size_t size, m_bufspan = {}; } m_allocated_size = size; - pvt::IB_local_mem_current += m_allocated_size; - atomic_max(pvt::IB_local_mem_peak, - static_cast(pvt::IB_local_mem_current)); + OIIO::pvt::IB_local_mem_current += m_allocated_size; + atomic_max(OIIO::pvt::IB_local_mem_peak, + static_cast(OIIO::pvt::IB_local_mem_current)); } if (data && size) memcpy(m_pixels.get(), data, size); - if (pvt::oiio_print_debug > 1) + if (OIIO::pvt::oiio_print_debug > 1) OIIO::debugfmt("IB allocated {} MB, global IB memory now {} MB\n", - size >> 20, pvt::IB_local_mem_current >> 20); + size >> 20, OIIO::pvt::IB_local_mem_current >> 20); eval_contiguous(); return m_pixels.get(); } @@ -801,11 +759,11 @@ void ImageBufImpl::free_pixels() { if (m_allocated_size) { - if (pvt::oiio_print_debug > 1) + if (OIIO::pvt::oiio_print_debug > 1) OIIO::debugfmt("IB freed {} MB, global IB memory now {} MB\n", m_allocated_size >> 20, - pvt::IB_local_mem_current >> 20); - pvt::IB_local_mem_current -= m_allocated_size; + OIIO::pvt::IB_local_mem_current >> 20); + OIIO::pvt::IB_local_mem_current -= m_allocated_size; m_allocated_size = 0; } m_pixels.reset(); @@ -934,7 +892,7 @@ ImageBufImpl::reset(string_view filename, int subimage, int miplevel, { clear(); m_name = ustring(filename); - if (m_imagecache || pvt::imagebuf_use_imagecache) { + if (m_imagecache || OIIO::pvt::imagebuf_use_imagecache) { // Invalidate the image in cache. Do so unconditionally if there's a // chance that configuration hints may have changed. invalidate(m_name, config || m_configspec); @@ -1146,13 +1104,13 @@ ImageBufImpl::init_spec(string_view filename, int subimage, int miplevel, && m_current_subimage == subimage && m_current_miplevel == miplevel) return true; // Already done - pvt::LoggedTimer logtime("IB::init_spec"); + OIIO::pvt::LoggedTimer logtime("IB::init_spec"); m_name = filename; // If we weren't given an imagecache but "imagebuf:use_imagecache" // attribute was set, use a shared IC. - if (!m_imagecache && pvt::imagebuf_use_imagecache) + if (!m_imagecache && OIIO::pvt::imagebuf_use_imagecache) m_imagecache = ImageCache::create(true); if (m_imagecache) { @@ -1279,20 +1237,20 @@ ImageBufImpl::init_spec(string_view filename, int subimage, int miplevel, auto input = ImageInput::open(filename, m_configspec.get(), m_rioproxy); if (!input) { error("Could not open file: {}", OIIO::geterror()); - atomic_fetch_add(pvt::IB_total_open_time, float(timer())); + atomic_fetch_add(OIIO::pvt::IB_total_open_time, float(timer())); return false; } m_spec = input->spec(subimage, miplevel); m_nativespec = m_spec; if (input->has_error()) { errorfmt("Error reading: {}", input->geterror()); - atomic_fetch_add(pvt::IB_total_open_time, float(timer())); + atomic_fetch_add(OIIO::pvt::IB_total_open_time, float(timer())); return false; } if (m_spec.format == TypeUnknown) { errorfmt("Could not seek to subimage={} miplevel={}", subimage, miplevel); - atomic_fetch_add(pvt::IB_total_open_time, float(timer())); + atomic_fetch_add(OIIO::pvt::IB_total_open_time, float(timer())); return false; } m_badfile = false; @@ -1320,7 +1278,7 @@ ImageBufImpl::init_spec(string_view filename, int subimage, int miplevel, m_current_subimage = subimage; m_current_miplevel = miplevel; m_pixelaspect = m_spec.get_float_attribute("pixelaspectratio", 1.0f); - atomic_fetch_add(pvt::IB_total_open_time, float(timer())); + atomic_fetch_add(OIIO::pvt::IB_total_open_time, float(timer())); } return !m_badfile; } @@ -1374,7 +1332,7 @@ ImageBufImpl::read(int subimage, int miplevel, int chbegin, int chend, return false; } - pvt::LoggedTimer logtime("IB::read"); + OIIO::pvt::LoggedTimer logtime("IB::read"); m_current_subimage = subimage; m_current_miplevel = miplevel; if (chend < 0 || chend > nativespec().nchannels) @@ -1399,7 +1357,7 @@ ImageBufImpl::read(int subimage, int miplevel, int chbegin, int chend, } else { error(input->geterror()); } - atomic_fetch_add(pvt::IB_total_image_read_time, float(timer())); + atomic_fetch_add(OIIO::pvt::IB_total_image_read_time, float(timer())); return ok; } @@ -1511,7 +1469,7 @@ ImageBufImpl::read(int subimage, int miplevel, int chbegin, int chend, m_pixels_valid = false; error(OIIO::geterror()); } - atomic_fetch_add(pvt::IB_total_image_read_time, float(timer())); + atomic_fetch_add(OIIO::pvt::IB_total_image_read_time, float(timer())); // Since we have read in the entire image now, if we are using an // IOProxy, we invalidate any cache entry to avoid lifetime issues // related to the IOProxy. This helps to eliminate trouble emerging @@ -1623,7 +1581,7 @@ ImageBuf::write(ImageOutput* out, ProgressCallback progress_callback, } bool ok = true; ok &= m_impl->validate_pixels(); - pvt::LoggedTimer logtime("IB::write inner"); + OIIO::pvt::LoggedTimer logtime("IB::write inner"); if (out->supports("thumbnail") && has_thumbnail()) { auto thumb = get_thumbnail(); // Strutil::print("IB::write: has thumbnail ROI {}\n", thumb->roi()); @@ -1749,7 +1707,7 @@ ImageBuf::write(string_view _filename, TypeDesc dtype, string_view _fileformat, ProgressCallback progress_callback, void* progress_callback_data) const { - pvt::LoggedTimer logtime("IB::write"); + OIIO::pvt::LoggedTimer logtime("IB::write"); string_view filename = _filename.size() ? _filename : string_view(name()); string_view fileformat = _fileformat.size() ? _fileformat : filename; if (filename.size() == 0) { @@ -3700,4 +3658,4 @@ ImageBuf::unlock() const } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo.cpp b/src/libOpenImageIO/imagebufalgo.cpp index 483327093d..2b346737b7 100644 --- a/src/libOpenImageIO/imagebufalgo.cpp +++ b/src/libOpenImageIO/imagebufalgo.cpp @@ -57,7 +57,7 @@ /////////////////////////////////////////////////////////////////////////// -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN bool @@ -819,7 +819,7 @@ ImageBufAlgo::convolve(ImageBuf& dst, const ImageBuf& src, const ImageBuf& kernel, bool normalize, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::convolve"); + OIIO::pvt::LoggedTimer logtime("IBA::convolve"); if (!IBAprep(roi, &dst, &src, IBAprep_REQUIRE_SAME_NCHANNELS)) return false; bool ok; @@ -1130,7 +1130,7 @@ bool ImageBufAlgo::median_filter(ImageBuf& dst, const ImageBuf& src, int width, int height, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::median_filter"); + OIIO::pvt::LoggedTimer logtime("IBA::median_filter"); if (!IBAprep(roi, &dst, &src, IBAprep_REQUIRE_SAME_NCHANNELS | IBAprep_NO_SUPPORT_VOLUME)) return false; @@ -1212,7 +1212,7 @@ bool ImageBufAlgo::dilate(ImageBuf& dst, const ImageBuf& src, int width, int height, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::dilate"); + OIIO::pvt::LoggedTimer logtime("IBA::dilate"); if (!IBAprep(roi, &dst, &src, IBAprep_REQUIRE_SAME_NCHANNELS | IBAprep_NO_SUPPORT_VOLUME)) return false; @@ -1243,7 +1243,7 @@ bool ImageBufAlgo::erode(ImageBuf& dst, const ImageBuf& src, int width, int height, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::erode"); + OIIO::pvt::LoggedTimer logtime("IBA::erode"); if (!IBAprep(roi, &dst, &src, IBAprep_REQUIRE_SAME_NCHANNELS | IBAprep_NO_SUPPORT_VOLUME)) return false; @@ -1308,7 +1308,7 @@ hfft_(ImageBuf& dst, const ImageBuf& src, bool inverse, bool unitary, ROI roi, bool ImageBufAlgo::fft(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::fft"); + OIIO::pvt::LoggedTimer logtime("IBA::fft"); if (src.spec().depth > 1) { dst.errorfmt("ImageBufAlgo::fft does not support volume images"); return false; @@ -1379,7 +1379,7 @@ ImageBufAlgo::fft(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) bool ImageBufAlgo::ifft(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::ifft"); + OIIO::pvt::LoggedTimer logtime("IBA::ifft"); if (src.nchannels() != 2 || src.spec().format != TypeDesc::FLOAT) { dst.errorfmt("ifft can only be done on 2-channel float images"); return false; @@ -1505,7 +1505,7 @@ bool ImageBufAlgo::polar_to_complex(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::polar_to_complex"); + OIIO::pvt::LoggedTimer logtime("IBA::polar_to_complex"); if (src.nchannels() != 2) { dst.errorfmt("polar_to_complex can only be done on 2-channel"); return false; @@ -1542,7 +1542,7 @@ bool ImageBufAlgo::complex_to_polar(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::complex_to_polar"); + OIIO::pvt::LoggedTimer logtime("IBA::complex_to_polar"); if (src.nchannels() != 2) { dst.errorfmt("complex_to_polar can only be done on 2-channel"); return false; @@ -1670,4 +1670,4 @@ ImageBufAlgo::fillholes_pushpull(const ImageBuf& src, ROI roi, int nthreads) } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_addsub.cpp b/src/libOpenImageIO/imagebufalgo_addsub.cpp index 7f85acc039..c7a4d83e9c 100644 --- a/src/libOpenImageIO/imagebufalgo_addsub.cpp +++ b/src/libOpenImageIO/imagebufalgo_addsub.cpp @@ -21,7 +21,7 @@ #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN template @@ -88,7 +88,7 @@ bool ImageBufAlgo::add(ImageBuf& dst, Image_or_Const A_, Image_or_Const B_, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::add"); + OIIO::pvt::LoggedTimer logtime("IBA::add"); if (A_.is_img() && B_.is_img()) { const ImageBuf &A(A_.img()), &B(B_.img()); if (!IBAprep(roi, &dst, &A, &B)) @@ -175,7 +175,7 @@ bool ImageBufAlgo::sub(ImageBuf& dst, Image_or_Const A_, Image_or_Const B_, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::sub"); + OIIO::pvt::LoggedTimer logtime("IBA::sub"); if (A_.is_img() && B_.is_img()) { const ImageBuf &A(A_.img()), &B(B_.img()); if (!IBAprep(roi, &dst, &A, &B)) @@ -245,4 +245,4 @@ ImageBufAlgo::sub(Image_or_Const A, Image_or_Const B, ROI roi, int nthreads) } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_channels.cpp b/src/libOpenImageIO/imagebufalgo_channels.cpp index 0946af3f4a..f8416ecb55 100644 --- a/src/libOpenImageIO/imagebufalgo_channels.cpp +++ b/src/libOpenImageIO/imagebufalgo_channels.cpp @@ -21,7 +21,7 @@ #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN template @@ -63,7 +63,7 @@ ImageBufAlgo::channels(ImageBuf& dst, const ImageBuf& src, int nchannels, return ok; } - pvt::LoggedTimer logtime("IBA::channels"); + OIIO::pvt::LoggedTimer logtime("IBA::channels"); // Not intended to create 0-channel images. if (nchannels <= 0) { dst.errorfmt("{}-channel images not supported", nchannels); @@ -228,7 +228,7 @@ bool ImageBufAlgo::channel_append(ImageBuf& dst, const ImageBuf& A, const ImageBuf& B, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::channel_append"); + OIIO::pvt::LoggedTimer logtime("IBA::channel_append"); // If the region is not defined, set it to the union of the valid // regions of the two source images. if (!roi.defined()) @@ -294,4 +294,4 @@ ImageBufAlgo::channel_append(const ImageBuf& A, const ImageBuf& B, ROI roi, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_compare.cpp b/src/libOpenImageIO/imagebufalgo_compare.cpp index f8cc4f58fc..9d96280fb6 100644 --- a/src/libOpenImageIO/imagebufalgo_compare.cpp +++ b/src/libOpenImageIO/imagebufalgo_compare.cpp @@ -21,7 +21,7 @@ #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN void @@ -187,7 +187,7 @@ computePixelStats_(const ImageBuf& src, ImageBufAlgo::PixelStats& stats, ImageBufAlgo::PixelStats ImageBufAlgo::computePixelStats(const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtimer("IBA::computePixelStats"); + OIIO::pvt::LoggedTimer logtimer("IBA::computePixelStats"); ImageBufAlgo::PixelStats stats; if (!roi.defined()) roi = get_roi(src.spec()); @@ -347,7 +347,7 @@ ImageBufAlgo::compare(const ImageBuf& A, const ImageBuf& B, float failthresh, float warnthresh, float failrelative, float warnrelative, ROI roi, int nthreads) { - pvt::LoggedTimer logtimer("IBA::compare"); + OIIO::pvt::LoggedTimer logtimer("IBA::compare"); ImageBufAlgo::CompareResults result; result.error = true; @@ -463,7 +463,7 @@ bool ImageBufAlgo::isConstantColor(const ImageBuf& src, float threshold, span color, ROI roi, int nthreads) { - pvt::LoggedTimer logtimer("IBA::isConstantColor"); + OIIO::pvt::LoggedTimer logtimer("IBA::isConstantColor"); // If no ROI is defined, use the data window of src. if (!roi.defined()) roi = get_roi(src.spec()); @@ -519,7 +519,7 @@ bool ImageBufAlgo::isConstantChannel(const ImageBuf& src, int channel, float val, float threshold, ROI roi, int nthreads) { - pvt::LoggedTimer logtimer("IBA::isConstantChannel"); + OIIO::pvt::LoggedTimer logtimer("IBA::isConstantChannel"); // If no ROI is defined, use the data window of src. if (!roi.defined()) roi = get_roi(src.spec()); @@ -580,7 +580,7 @@ bool ImageBufAlgo::isMonochrome(const ImageBuf& src, float threshold, ROI roi, int nthreads) { - pvt::LoggedTimer logtimer("IBA::isMonochrome"); + OIIO::pvt::LoggedTimer logtimer("IBA::isMonochrome"); // If no ROI is defined, use the data window of src. if (!roi.defined()) roi = get_roi(src.spec()); @@ -632,7 +632,7 @@ ImageBufAlgo::color_count(const ImageBuf& src, imagesize_t* count, int ncolors, cspan color, cspan eps, ROI roi, int nthreads) { - pvt::LoggedTimer logtimer("IBA::color_count"); + OIIO::pvt::LoggedTimer logtimer("IBA::color_count"); // If no ROI is defined, use the data window of src. if (!roi.defined()) roi = get_roi(src.spec()); @@ -698,7 +698,7 @@ ImageBufAlgo::color_range_check(const ImageBuf& src, imagesize_t* lowcount, imagesize_t* inrangecount, cspan low, cspan high, ROI roi, int nthreads) { - pvt::LoggedTimer logtimer("IBA::color_range_check"); + OIIO::pvt::LoggedTimer logtimer("IBA::color_range_check"); // If no ROI is defined, use the data window of src. if (!roi.defined()) roi = get_roi(src.spec()); @@ -753,7 +753,7 @@ deep_nonempty_region(const ImageBuf& src, ROI roi) ROI ImageBufAlgo::nonzero_region(const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtimer("IBA::nonzero_region"); + OIIO::pvt::LoggedTimer logtimer("IBA::nonzero_region"); roi = roi_intersection(roi, src.roi()); if (src.deep()) { @@ -860,7 +860,7 @@ std::string ImageBufAlgo::computePixelHashSHA1(const ImageBuf& src, string_view extrainfo, ROI roi, int blocksize, int nthreads) { - pvt::LoggedTimer logtimer("IBA::computePixelHashSHA1"); + OIIO::pvt::LoggedTimer logtimer("IBA::computePixelHashSHA1"); if (!roi.defined()) roi = get_roi(src.spec()); @@ -941,7 +941,7 @@ std::vector ImageBufAlgo::histogram(const ImageBuf& src, int channel, int bins, float min, float max, bool ignore_empty, ROI roi, int nthreads) { - pvt::LoggedTimer logtimer("IBA::histogram"); + OIIO::pvt::LoggedTimer logtimer("IBA::histogram"); std::vector h; // Sanity checks @@ -979,4 +979,4 @@ ImageBufAlgo::histogram(const ImageBuf& src, int channel, int bins, float min, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_copy.cpp b/src/libOpenImageIO/imagebufalgo_copy.cpp index 0a98cf8905..51a138596f 100644 --- a/src/libOpenImageIO/imagebufalgo_copy.cpp +++ b/src/libOpenImageIO/imagebufalgo_copy.cpp @@ -16,7 +16,7 @@ #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN template @@ -105,7 +105,7 @@ bool ImageBufAlgo::paste(ImageBuf& dst, int xbegin, int ybegin, int zbegin, int chbegin, const ImageBuf& src, ROI srcroi, int nthreads) { - pvt::LoggedTimer logtime("IBA::paste"); + OIIO::pvt::LoggedTimer logtime("IBA::paste"); if (!srcroi.defined()) srcroi = get_roi(src.spec()); @@ -189,7 +189,7 @@ bool ImageBufAlgo::copy(ImageBuf& dst, const ImageBuf& src, TypeDesc convert, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::copy"); + OIIO::pvt::LoggedTimer logtime("IBA::copy"); if (&dst == &src) // trivial copy to self return true; @@ -253,7 +253,7 @@ ImageBufAlgo::copy(const ImageBuf& src, TypeDesc convert, ROI roi, int nthreads) bool ImageBufAlgo::crop(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::crop"); + OIIO::pvt::LoggedTimer logtime("IBA::crop"); dst.clear(); roi.chend = std::min(roi.chend, src.nchannels()); if (!IBAprep(roi, &dst, &src, IBAprep_SUPPORT_DEEP)) @@ -307,7 +307,7 @@ ImageBufAlgo::crop(const ImageBuf& src, ROI roi, int nthreads) bool ImageBufAlgo::cut(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - // pvt::LoggedTimer logtime("IBA::cut"); + // OIIO::pvt::LoggedTimer logtime("IBA::cut"); // Don't log, because all the work is inside crop, which already logs bool ok = crop(dst, src, roi, nthreads); if (!ok) @@ -369,7 +369,7 @@ bool ImageBufAlgo::circular_shift(ImageBuf& dst, const ImageBuf& src, int xshift, int yshift, int zshift, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::circular_shift"); + OIIO::pvt::LoggedTimer logtime("IBA::circular_shift"); if (!IBAprep(roi, &dst, &src)) return false; bool ok; @@ -395,4 +395,4 @@ ImageBufAlgo::circular_shift(const ImageBuf& src, int xshift, int yshift, -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_deep.cpp b/src/libOpenImageIO/imagebufalgo_deep.cpp index b2195583a3..ee8cacb342 100644 --- a/src/libOpenImageIO/imagebufalgo_deep.cpp +++ b/src/libOpenImageIO/imagebufalgo_deep.cpp @@ -20,7 +20,7 @@ #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN // FIXME -- NOT CORRECT! This code assumes sorted, non-overlapping samples. @@ -88,7 +88,7 @@ flatten_(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) bool ImageBufAlgo::flatten(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::flatten"); + OIIO::pvt::LoggedTimer logtime("IBA::flatten"); if (!src.deep()) { // For some reason, we were asked to flatten an already-flat image. // So just copy it. @@ -138,7 +138,7 @@ bool ImageBufAlgo::deepen(ImageBuf& dst, const ImageBuf& src, float zvalue, ROI roi, int /*nthreads*/) { - pvt::LoggedTimer logtime("IBA::deepen"); + OIIO::pvt::LoggedTimer logtime("IBA::deepen"); if (src.deep()) { // For some reason, we were asked to deepen an already-deep image. // So just copy it. @@ -242,7 +242,7 @@ bool ImageBufAlgo::deep_merge(ImageBuf& dst, const ImageBuf& A, const ImageBuf& B, bool occlusion_cull, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::deep_merge"); + OIIO::pvt::LoggedTimer logtime("IBA::deep_merge"); if (!A.deep() || !B.deep()) { // For some reason, we were asked to merge a flat image. dst.errorfmt("deep_merge can only be performed on deep images"); @@ -366,7 +366,7 @@ bool ImageBufAlgo::deep_holdout(ImageBuf& dst, const ImageBuf& src, const ImageBuf& thresh, ROI roi, int /*nthreads*/) { - pvt::LoggedTimer logtime("IBA::deep_holdout"); + OIIO::pvt::LoggedTimer logtime("IBA::deep_holdout"); if (!src.deep() || !thresh.deep()) { dst.errorfmt("deep_holdout can only be performed on deep images"); return false; @@ -444,4 +444,4 @@ ImageBufAlgo::deep_holdout(const ImageBuf& src, const ImageBuf& thresh, ROI roi, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_demosaic.cpp b/src/libOpenImageIO/imagebufalgo_demosaic.cpp index f63ba3e148..9a34554b8d 100644 --- a/src/libOpenImageIO/imagebufalgo_demosaic.cpp +++ b/src/libOpenImageIO/imagebufalgo_demosaic.cpp @@ -12,7 +12,7 @@ #include "imagebufalgo_demosaic_prv.h" #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace { @@ -966,7 +966,7 @@ demosaic(ImageBuf& dst, const ImageBuf& src, KWArgs options, ROI roi, int nthreads) { bool ok = false; - pvt::LoggedTimer logtime("IBA::demosaic"); + OIIO::pvt::LoggedTimer logtime("IBA::demosaic"); std::string pattern; std::string algorithm; @@ -1234,4 +1234,4 @@ mosaic_uint8(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, } // namespace ImageBufAlgo -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_demosaic_prv.h b/src/libOpenImageIO/imagebufalgo_demosaic_prv.h index 204a5f7bb2..9f6678cb3b 100644 --- a/src/libOpenImageIO/imagebufalgo_demosaic_prv.h +++ b/src/libOpenImageIO/imagebufalgo_demosaic_prv.h @@ -7,7 +7,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace ImageBufAlgo { @@ -33,4 +33,4 @@ mosaic_uint8(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, } // namespace ImageBufAlgo -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_draw.cpp b/src/libOpenImageIO/imagebufalgo_draw.cpp index 39460bd04f..d3236eba7f 100644 --- a/src/libOpenImageIO/imagebufalgo_draw.cpp +++ b/src/libOpenImageIO/imagebufalgo_draw.cpp @@ -94,11 +94,16 @@ fill_corners_(ImageBuf& dst, const float* topleft, const float* topright, return true; } +OIIO_NAMESPACE_END + + + +OIIO_NAMESPACE_3_1_BEGIN bool ImageBufAlgo::fill(ImageBuf& dst, cspan pixel, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::fill"); + OIIO::pvt::LoggedTimer logtime("IBA::fill"); if (!IBAprep(roi, &dst)) return false; bool ok; @@ -113,7 +118,7 @@ bool ImageBufAlgo::fill(ImageBuf& dst, cspan top, cspan bottom, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::fill"); + OIIO::pvt::LoggedTimer logtime("IBA::fill"); if (!IBAprep(roi, &dst)) return false; bool ok; @@ -130,7 +135,7 @@ ImageBufAlgo::fill(ImageBuf& dst, cspan topleft, cspan topright, cspan bottomleft, cspan bottomright, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::fill"); + OIIO::pvt::LoggedTimer logtime("IBA::fill"); if (!IBAprep(roi, &dst)) return false; bool ok; @@ -185,7 +190,7 @@ ImageBufAlgo::fill(cspan topleft, cspan topright, bool ImageBufAlgo::zero(ImageBuf& dst, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::zero"); + OIIO::pvt::LoggedTimer logtime("IBA::zero"); if (!IBAprep(roi, &dst)) return false; OIIO_ASSERT(dst.localpixels()); @@ -243,7 +248,7 @@ bool ImageBufAlgo::render_point(ImageBuf& dst, int x, int y, cspan color, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::render_point"); + OIIO::pvt::LoggedTimer logtime("IBA::render_point"); if (!IBAprep(roi, &dst)) return false; IBA_FIX_PERCHAN_LEN_DEF(color, dst.nchannels()); @@ -368,7 +373,7 @@ ImageBufAlgo::render_line(ImageBuf& dst, int x1, int y1, int x2, int y2, cspan color, bool skip_first_point, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::render_line"); + OIIO::pvt::LoggedTimer logtime("IBA::render_line"); if (!IBAprep(roi, &dst)) return false; IBA_FIX_PERCHAN_LEN_DEF(color, dst.nchannels()); @@ -426,7 +431,7 @@ bool ImageBufAlgo::render_box(ImageBuf& dst, int x1, int y1, int x2, int y2, cspan color, bool fill, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::render_box"); + OIIO::pvt::LoggedTimer logtime("IBA::render_box"); if (!IBAprep(roi, &dst)) return false; IBA_FIX_PERCHAN_LEN_DEF(color, dst.nchannels()); @@ -505,7 +510,7 @@ ImageBufAlgo::checker(ImageBuf& dst, int width, int height, int depth, cspan color1, cspan color2, int xoffset, int yoffset, int zoffset, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::checker"); + OIIO::pvt::LoggedTimer logtime("IBA::checker"); if (!IBAprep(roi, &dst)) return false; IBA_FIX_PERCHAN_LEN_DEF(color1, dst.nchannels()); @@ -636,6 +641,7 @@ static bool noise_blue_(ImageBuf& dst, float min, float max, bool mono, int seed, ROI roi, int nthreads) { + using OIIO::pvt::bluenoise_4chan_ptr; ImageBufAlgo::parallel_image(roi, nthreads, [&](ROI roi) { for (ImageBuf::Iterator p(dst, roi); !p.done(); ++p) { float n = 0.0; @@ -643,8 +649,8 @@ noise_blue_(ImageBuf& dst, float min, float max, bool mono, int seed, ROI roi, for (int c = roi.chbegin; c < roi.chend; ++c) { if (c == roi.chbegin || !mono) { if (!bn || !(c & 3)) - bn = pvt::bluenoise_4chan_ptr(p.x(), p.y(), p.z(), - roi.chbegin & ~3, seed); + bn = bluenoise_4chan_ptr(p.x(), p.y(), p.z(), + roi.chbegin & ~3, seed); n = lerp(min, max, bn[c & 3]); } p[c] = p[c] + n; @@ -660,7 +666,7 @@ bool ImageBufAlgo::noise(ImageBuf& dst, string_view noisetype, float A, float B, bool mono, int seed, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::noise"); + OIIO::pvt::LoggedTimer logtime("IBA::noise"); if (!IBAprep(roi, &dst)) return false; bool ok; @@ -709,7 +715,8 @@ namespace { inline ImageSpec bnspec() { - ImageSpec spec(pvt::bntable_res, pvt::bntable_res, 4, TypeFloat); + using OIIO::pvt::bntable_res; + ImageSpec spec(bntable_res, bntable_res, 4, TypeFloat); spec.channelnames = { "X", "Y", "Z", "W" }; spec.alpha_channel = -1; return spec; @@ -720,13 +727,16 @@ const ImageBuf& ImageBufAlgo::bluenoise_image() { // This ImageBuf "wraps" the table. - using namespace pvt; + using namespace OIIO::pvt; static ImageBuf img(bnspec(), make_cspan(&bluenoise_table[0][0][0], bntable_res * bntable_res * 4)); return img; } +OIIO_NAMESPACE_3_1_END + +OIIO_NAMESPACE_BEGIN static std::vector font_search_dirs; static std::vector all_font_files; @@ -1114,11 +1124,15 @@ resolve_font(string_view font_, std::string& result) #endif +OIIO_NAMESPACE_END + + +OIIO_NAMESPACE_3_1_BEGIN ROI ImageBufAlgo::text_size(string_view text, int fontsize, string_view font_) { - pvt::LoggedTimer logtime("IBA::text_size"); + OIIO::pvt::LoggedTimer logtime("IBA::text_size"); ROI size; #ifdef USE_FREETYPE // Thread safety @@ -1164,7 +1178,7 @@ ImageBufAlgo::render_text(ImageBuf& R, int x, int y, string_view text, TextAlignY aligny, int shadow, ROI roi, int /*nthreads*/) { - pvt::LoggedTimer logtime("IBA::render_text"); + OIIO::pvt::LoggedTimer logtime("IBA::render_text"); if (R.spec().depth > 1) { R.errorfmt("ImageBufAlgo::render_text does not support volume images"); return false; @@ -1316,8 +1330,11 @@ ImageBufAlgo::render_text(ImageBuf& R, int x, int y, string_view text, #endif } +OIIO_NAMESPACE_3_1_END +OIIO_NAMESPACE_BEGIN + const std::vector& pvt::font_family_list() { diff --git a/src/libOpenImageIO/imagebufalgo_mad.cpp b/src/libOpenImageIO/imagebufalgo_mad.cpp index 8c484826e2..5707fcd6ac 100644 --- a/src/libOpenImageIO/imagebufalgo_mad.cpp +++ b/src/libOpenImageIO/imagebufalgo_mad.cpp @@ -15,7 +15,7 @@ #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN @@ -142,7 +142,7 @@ bool ImageBufAlgo::mad(ImageBuf& dst, Image_or_Const A_, Image_or_Const B_, Image_or_Const C_, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::mad"); + OIIO::pvt::LoggedTimer logtime("IBA::mad"); // Canonicalize so that if one of A,B is a constant, A is an image. if (A_.is_val() && B_.is_img()) // canonicalize to A_img, B_val @@ -251,4 +251,4 @@ ImageBufAlgo::invert(const ImageBuf& A, ROI roi, int nthreads) } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_minmaxchan.cpp b/src/libOpenImageIO/imagebufalgo_minmaxchan.cpp index 1025220a98..6af4281eae 100644 --- a/src/libOpenImageIO/imagebufalgo_minmaxchan.cpp +++ b/src/libOpenImageIO/imagebufalgo_minmaxchan.cpp @@ -18,7 +18,7 @@ #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN template @@ -43,7 +43,7 @@ minchan_impl(ImageBuf& R, const ImageBuf& A, ROI roi, int nthreads) bool ImageBufAlgo::minchan(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::minchan"); + OIIO::pvt::LoggedTimer logtime("IBA::minchan"); if (!roi.defined()) roi = get_roi(src.spec()); roi.chend = std::min(roi.chend, src.nchannels()); @@ -95,7 +95,7 @@ maxchan_impl(ImageBuf& R, const ImageBuf& A, ROI roi, int nthreads) bool ImageBufAlgo::maxchan(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::maxchan"); + OIIO::pvt::LoggedTimer logtime("IBA::maxchan"); if (!roi.defined()) roi = get_roi(src.spec()); roi.chend = std::min(roi.chend, src.nchannels()); @@ -124,4 +124,4 @@ ImageBufAlgo::maxchan(const ImageBuf& src, ROI roi, int nthreads) } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_muldiv.cpp b/src/libOpenImageIO/imagebufalgo_muldiv.cpp index e393c8a22a..4fa1a6cba0 100644 --- a/src/libOpenImageIO/imagebufalgo_muldiv.cpp +++ b/src/libOpenImageIO/imagebufalgo_muldiv.cpp @@ -22,7 +22,7 @@ #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN template @@ -47,7 +47,7 @@ bool ImageBufAlgo::scale(ImageBuf& dst, const ImageBuf& A, const ImageBuf& B, KWArgs options, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::scale"); + OIIO::pvt::LoggedTimer logtime("IBA::scale"); bool ok = false; if (B.nchannels() == 1) { if (IBAprep(roi, &dst, &A, &B)) @@ -147,7 +147,7 @@ bool ImageBufAlgo::mul(ImageBuf& dst, Image_or_Const A_, Image_or_Const B_, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::mul"); + OIIO::pvt::LoggedTimer logtime("IBA::mul"); if (A_.is_img() && B_.is_img()) { const ImageBuf &A(A_.img()), &B(B_.img()); if (!IBAprep(roi, &dst, &A, &B, IBAprep_CLAMP_MUTUAL_NCHANNELS)) @@ -220,7 +220,7 @@ bool ImageBufAlgo::div(ImageBuf& dst, Image_or_Const A_, Image_or_Const B_, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::div"); + OIIO::pvt::LoggedTimer logtime("IBA::div"); if (A_.is_img() && B_.is_img()) { const ImageBuf &A(A_.img()), &B(B_.img()); if (!IBAprep(roi, &dst, &A, &B, IBAprep_CLAMP_MUTUAL_NCHANNELS)) @@ -276,4 +276,4 @@ ImageBufAlgo::div(Image_or_Const A, Image_or_Const B, ROI roi, int nthreads) -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_orient.cpp b/src/libOpenImageIO/imagebufalgo_orient.cpp index 9a758d2d86..fb1e656ce8 100644 --- a/src/libOpenImageIO/imagebufalgo_orient.cpp +++ b/src/libOpenImageIO/imagebufalgo_orient.cpp @@ -16,7 +16,7 @@ #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN template @@ -45,7 +45,7 @@ ImageBufAlgo::flip(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) tmp.swap(const_cast(src)); return flip(dst, tmp, roi, nthreads); } - pvt::LoggedTimer logtime("IBA::flip"); + OIIO::pvt::LoggedTimer logtime("IBA::flip"); ROI src_roi = roi.defined() ? roi : src.roi(); ROI src_roi_full = src.roi_full(); @@ -95,7 +95,7 @@ ImageBufAlgo::flop(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) return flop(dst, tmp, roi, nthreads); } - pvt::LoggedTimer logtime("IBA::flop"); + OIIO::pvt::LoggedTimer logtime("IBA::flop"); ROI src_roi = roi.defined() ? roi : src.roi(); ROI src_roi_full = src.roi_full(); int offset = src_roi.xbegin - src_roi_full.xbegin; @@ -167,7 +167,7 @@ ImageBufAlgo::rotate90(ImageBuf& dst, const ImageBuf& src, ROI roi, return rotate90(dst, tmp, roi, nthreads); } - pvt::LoggedTimer logtime("IBA::rotate90"); + OIIO::pvt::LoggedTimer logtime("IBA::rotate90"); ROI src_roi = roi.defined() ? roi : src.roi(); ROI src_roi_full = src.roi_full(); @@ -230,7 +230,7 @@ ImageBufAlgo::rotate180(ImageBuf& dst, const ImageBuf& src, ROI roi, return rotate180(dst, tmp, roi, nthreads); } - pvt::LoggedTimer logtime("IBA::rotate180"); + OIIO::pvt::LoggedTimer logtime("IBA::rotate180"); ROI src_roi = roi.defined() ? roi : src.roi(); ROI src_roi_full = src.roi_full(); int xoffset = src_roi.xbegin - src_roi_full.xbegin; @@ -281,7 +281,7 @@ ImageBufAlgo::rotate270(ImageBuf& dst, const ImageBuf& src, ROI roi, return rotate270(dst, tmp, roi, nthreads); } - pvt::LoggedTimer logtime("IBA::rotate270"); + OIIO::pvt::LoggedTimer logtime("IBA::rotate270"); ROI src_roi = roi.defined() ? roi : src.roi(); ROI src_roi_full = src.roi_full(); @@ -420,7 +420,7 @@ bool ImageBufAlgo::transpose(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::transpose"); + OIIO::pvt::LoggedTimer logtime("IBA::transpose"); if (!roi.defined()) roi = get_roi(src.spec()); roi.chend = std::min(roi.chend, src.nchannels()); @@ -459,4 +459,4 @@ ImageBufAlgo::transpose(const ImageBuf& src, ROI roi, int nthreads) return result; } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_pixelmath.cpp b/src/libOpenImageIO/imagebufalgo_pixelmath.cpp index 33c98a709a..04daeaad27 100644 --- a/src/libOpenImageIO/imagebufalgo_pixelmath.cpp +++ b/src/libOpenImageIO/imagebufalgo_pixelmath.cpp @@ -22,7 +22,7 @@ #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN template @@ -63,7 +63,7 @@ bool ImageBufAlgo::min(ImageBuf& dst, Image_or_Const A_, Image_or_Const B_, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::min"); + OIIO::pvt::LoggedTimer logtime("IBA::min"); if (A_.is_img() && B_.is_img()) { const ImageBuf &A(A_.img()), &B(B_.img()); if (!IBAprep(roi, &dst, &A, &B)) @@ -160,7 +160,7 @@ bool ImageBufAlgo::max(ImageBuf& dst, Image_or_Const A_, Image_or_Const B_, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::max"); + OIIO::pvt::LoggedTimer logtime("IBA::max"); if (A_.is_img() && B_.is_img()) { const ImageBuf &A(A_.img()), &B(B_.img()); if (!IBAprep(roi, &dst, &A, &B)) @@ -245,7 +245,7 @@ bool ImageBufAlgo::clamp(ImageBuf& dst, const ImageBuf& src, cspan min, cspan max, bool clampalpha01, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::clamp"); + OIIO::pvt::LoggedTimer logtime("IBA::clamp"); if (!IBAprep(roi, &dst, &src)) return false; const float big = std::numeric_limits::max(); @@ -313,7 +313,7 @@ bool ImageBufAlgo::absdiff(ImageBuf& dst, Image_or_Const A_, Image_or_Const B_, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::absdiff"); + OIIO::pvt::LoggedTimer logtime("IBA::absdiff"); if (!IBAprep(roi, &dst, A_.imgptr(), B_.imgptr(), nullptr, IBAprep_CLAMP_MUTUAL_NCHANNELS)) return false; @@ -412,7 +412,7 @@ bool ImageBufAlgo::pow(ImageBuf& dst, const ImageBuf& A, cspan b, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::pow"); + OIIO::pvt::LoggedTimer logtime("IBA::pow"); if (!IBAprep(roi, &dst, &A, IBAprep_CLAMP_MUTUAL_NCHANNELS)) return false; IBA_FIX_PERCHAN_LEN_DEF(b, dst.nchannels()); @@ -524,7 +524,7 @@ bool ImageBufAlgo::channel_sum(ImageBuf& dst, const ImageBuf& src, cspan weights, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::channel_sum"); + OIIO::pvt::LoggedTimer logtime("IBA::channel_sum"); if (!roi.defined()) roi = get_roi(src.spec()); roi.chend = std::min(roi.chend, src.nchannels()); @@ -742,7 +742,7 @@ bool ImageBufAlgo::rangecompress(ImageBuf& dst, const ImageBuf& src, bool useluma, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::rangecompress"); + OIIO::pvt::LoggedTimer logtime("IBA::rangecompress"); if (!IBAprep(roi, &dst, &src, IBAprep_CLAMP_MUTUAL_NCHANNELS)) return false; bool ok; @@ -758,7 +758,7 @@ bool ImageBufAlgo::rangeexpand(ImageBuf& dst, const ImageBuf& src, bool useluma, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::rangeexpand"); + OIIO::pvt::LoggedTimer logtime("IBA::rangeexpand"); if (!IBAprep(roi, &dst, &src, IBAprep_CLAMP_MUTUAL_NCHANNELS)) return false; bool ok; @@ -838,7 +838,7 @@ bool ImageBufAlgo::unpremult(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::unpremult"); + OIIO::pvt::LoggedTimer logtime("IBA::unpremult"); if (!IBAprep(roi, &dst, &src, IBAprep_CLAMP_MUTUAL_NCHANNELS)) return false; if (src.spec().alpha_channel < 0 @@ -917,7 +917,7 @@ premult_(ImageBuf& R, const ImageBuf& A, bool preserve_alpha0, ROI roi, bool ImageBufAlgo::premult(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::premult"); + OIIO::pvt::LoggedTimer logtime("IBA::premult"); if (!IBAprep(roi, &dst, &src, IBAprep_CLAMP_MUTUAL_NCHANNELS)) return false; if (src.spec().alpha_channel < 0) { @@ -953,7 +953,7 @@ bool ImageBufAlgo::repremult(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::repremult"); + OIIO::pvt::LoggedTimer logtime("IBA::repremult"); if (!IBAprep(roi, &dst, &src, IBAprep_CLAMP_MUTUAL_NCHANNELS)) return false; if (src.spec().alpha_channel < 0) { @@ -1074,7 +1074,7 @@ ImageBufAlgo::contrast_remap(ImageBuf& dst, const ImageBuf& src, cspan scontrast, cspan sthresh, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::contrast_remap"); + OIIO::pvt::LoggedTimer logtime("IBA::contrast_remap"); if (!IBAprep(roi, &dst, &src)) return false; // Force all the input spans to have values for all channels. @@ -1148,7 +1148,7 @@ bool ImageBufAlgo::saturate(ImageBuf& dst, const ImageBuf& src, float scale, int firstchannel, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::saturate"); + OIIO::pvt::LoggedTimer logtime("IBA::saturate"); if (!IBAprep(roi, &dst, &src, IBAprep_CLAMP_MUTUAL_NCHANNELS)) return false; @@ -1230,7 +1230,7 @@ ImageBufAlgo::color_map(ImageBuf& dst, const ImageBuf& src, int srcchannel, int nknots, int channels, cspan knots, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::color_map"); + OIIO::pvt::LoggedTimer logtime("IBA::color_map"); if (srcchannel >= src.nchannels()) { dst.errorfmt("invalid source channel selected"); return false; @@ -1358,7 +1358,7 @@ bool ImageBufAlgo::color_map(ImageBuf& dst, const ImageBuf& src, int srcchannel, string_view mapname, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::color_map"); + OIIO::pvt::LoggedTimer logtime("IBA::color_map"); if (srcchannel >= src.nchannels()) { dst.errorfmt("invalid source channel selected"); return false; @@ -1565,7 +1565,7 @@ ImageBufAlgo::fixNonFinite(ImageBuf& dst, const ImageBuf& src, NonFiniteFixMode mode, int* pixelsFixed, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::fixNonFinite"); + OIIO::pvt::LoggedTimer logtime("IBA::fixNonFinite"); if (mode != ImageBufAlgo::NONFINITE_NONE && mode != ImageBufAlgo::NONFINITE_BLACK && mode != ImageBufAlgo::NONFINITE_BOX3 @@ -1750,7 +1750,7 @@ bool ImageBufAlgo::over(ImageBuf& dst, const ImageBuf& A, const ImageBuf& B, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::over"); + OIIO::pvt::LoggedTimer logtime("IBA::over"); if (!IBAprep(roi, &dst, &A, &B, NULL, IBAprep_REQUIRE_ALPHA | IBAprep_REQUIRE_SAME_NCHANNELS)) return false; @@ -1793,7 +1793,7 @@ bool ImageBufAlgo::zover(ImageBuf& dst, const ImageBuf& A, const ImageBuf& B, bool z_zeroisinf, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::zover"); + OIIO::pvt::LoggedTimer logtime("IBA::zover"); if (!IBAprep(roi, &dst, &A, &B, NULL, IBAprep_REQUIRE_ALPHA | IBAprep_REQUIRE_Z | IBAprep_REQUIRE_SAME_NCHANNELS)) @@ -1819,4 +1819,4 @@ ImageBufAlgo::zover(const ImageBuf& A, const ImageBuf& B, bool z_zeroisinf, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_test.cpp b/src/libOpenImageIO/imagebufalgo_test.cpp index 3ea14c46bc..940e2a8ff5 100644 --- a/src/libOpenImageIO/imagebufalgo_test.cpp +++ b/src/libOpenImageIO/imagebufalgo_test.cpp @@ -1316,15 +1316,15 @@ test_simple_perpixel() template std::string -mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, - const std::string& pattern, const float (&white_balance)[4], - int nthreads); +do_mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, + const std::string& pattern, const float (&white_balance)[4], + int nthreads); template<> std::string -mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, - const std::string& pattern, const float (&white_balance)[4], - int nthreads) +do_mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, + const std::string& pattern, const float (&white_balance)[4], + int nthreads) { return ImageBufAlgo::mosaic_float(dst, src, x_offset, y_offset, pattern, white_balance, nthreads); @@ -1332,9 +1332,9 @@ mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, template<> std::string -mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, - const std::string& pattern, const float (&white_balance)[4], - int nthreads) +do_mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, + const std::string& pattern, const float (&white_balance)[4], + int nthreads) { return ImageBufAlgo::mosaic_half(dst, src, x_offset, y_offset, pattern, white_balance, nthreads); @@ -1342,9 +1342,9 @@ mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, template<> std::string -mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, - const std::string& pattern, const float (&white_balance)[4], - int nthreads) +do_mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, + int y_offset, const std::string& pattern, + const float (&white_balance)[4], int nthreads) { return ImageBufAlgo::mosaic_uint16(dst, src, x_offset, y_offset, pattern, white_balance, nthreads); @@ -1352,9 +1352,9 @@ mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, template<> std::string -mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, int y_offset, - const std::string& pattern, const float (&white_balance)[4], - int nthreads) +do_mosaic(ImageBuf& dst, const ImageBuf& src, int x_offset, + int y_offset, const std::string& pattern, + const float (&white_balance)[4], int nthreads) { return ImageBufAlgo::mosaic_uint8(dst, src, x_offset, y_offset, pattern, white_balance, nthreads); @@ -1421,8 +1421,8 @@ test_demosaic(const DemosaicTestConfig& config, const ImageBuf& src_image, ImageSpec dst_spec(src_spec.width, src_spec.height, 1, type); ImageBuf mosaiced_image(dst_spec); - std::string layout = mosaic(mosaiced_image, src_image, x, y, - config.pattern, wb, 0); + std::string layout = do_mosaic(mosaiced_image, src_image, x, y, + config.pattern, wb, 0); mosaiced_image.specmod().attribute("raw:FilterPattern", layout); mosaiced_image.specmod().attribute("raw:WhiteBalance", diff --git a/src/libOpenImageIO/imagebufalgo_xform.cpp b/src/libOpenImageIO/imagebufalgo_xform.cpp index 5de60fb497..0abbb1ace8 100644 --- a/src/libOpenImageIO/imagebufalgo_xform.cpp +++ b/src/libOpenImageIO/imagebufalgo_xform.cpp @@ -21,7 +21,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace { @@ -378,7 +378,7 @@ warp_impl(ImageBuf& dst, const ImageBuf& src, const Imath::M33f& M, const Filter2D* filter, bool recompute_roi, ImageBuf::WrapMode wrap, bool edgeclamp, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::warp"); + OIIO::pvt::LoggedTimer logtime("IBA::warp"); ROI src_roi_full = src.roi_full(); ROI dst_roi, dst_roi_full; if (dst.initialized()) { @@ -860,7 +860,7 @@ bool ImageBufAlgo::resize(ImageBuf& dst, const ImageBuf& src, KWArgs options, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::resize"); + OIIO::pvt::LoggedTimer logtime("IBA::resize"); static const ustring recognized[] = { filtername_us, @@ -929,7 +929,7 @@ bool ImageBufAlgo::fit(ImageBuf& dst, const ImageBuf& src, KWArgs options, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::fit"); + OIIO::pvt::LoggedTimer logtime("IBA::fit"); static const ustring recognized[] = { filtername_us, @@ -1148,7 +1148,7 @@ bool ImageBufAlgo::resample(ImageBuf& dst, const ImageBuf& src, bool interpolate, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::resample"); + OIIO::pvt::LoggedTimer logtime("IBA::resample"); if (!IBAprep(roi, &dst, &src, IBAprep_NO_SUPPORT_VOLUME | IBAprep_NO_COPY_ROI_FULL | IBAprep_SUPPORT_DEEP)) @@ -1459,7 +1459,7 @@ ImageBufAlgo::st_warp(ImageBuf& dst, const ImageBuf& src, const ImageBuf& stbuf, const Filter2D* filter, int chan_s, int chan_t, bool flip_s, bool flip_t, ROI roi, int nthreads) { - pvt::LoggedTimer logtime("IBA::st_warp"); + OIIO::pvt::LoggedTimer logtime("IBA::st_warp"); if (!check_st_warp_args(dst, src, stbuf, chan_s, chan_t, roi)) { return false; @@ -1534,4 +1534,4 @@ ImageBufAlgo::st_warp(const ImageBuf& src, const ImageBuf& stbuf, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imagebufalgo_yee.cpp b/src/libOpenImageIO/imagebufalgo_yee.cpp index 39daa77248..7ee875ebe5 100644 --- a/src/libOpenImageIO/imagebufalgo_yee.cpp +++ b/src/libOpenImageIO/imagebufalgo_yee.cpp @@ -28,7 +28,7 @@ powf(const Imath::Vec3& x, float y) -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace { @@ -336,4 +336,4 @@ ImageBufAlgo::compare_Yee(const ImageBuf& img0, const ImageBuf& img1, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imageinput.cpp b/src/libOpenImageIO/imageinput.cpp index 4ae22eb7fc..03af1297c5 100644 --- a/src/libOpenImageIO/imageinput.cpp +++ b/src/libOpenImageIO/imageinput.cpp @@ -22,8 +22,9 @@ #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN using namespace pvt; +using namespace OIIO::pvt; // store an error message per thread, for a specific ImageInput @@ -35,7 +36,7 @@ class ImageInput::Impl { public: Impl() : m_id(++input_next_id) - , m_threads(pvt::oiio_threads) + , m_threads(OIIO::pvt::oiio_threads) { } @@ -322,7 +323,7 @@ ImageInput::read_scanlines(int subimage, int miplevel, int ybegin, int yend, int z, int chbegin, int chend, TypeDesc format, void* data, stride_t xstride, stride_t ystride) { - pvt::LoggedTimer logtime("II::read_scanlines"); + OIIO::pvt::LoggedTimer logtime("II::read_scanlines"); ImageSpec spec; int rps = 0; { @@ -520,7 +521,7 @@ bool ImageInput::read_native_scanlines(int subimage, int miplevel, int ybegin, int yend, span data) { - if (pvt::oiio_print_debug + if (OIIO::pvt::oiio_print_debug #ifndef NDEBUG || true #endif @@ -544,7 +545,7 @@ ImageInput::read_native_scanlines(int subimage, int miplevel, int ybegin, int yend, int chbegin, int chend, span data) { - if (pvt::oiio_print_debug + if (OIIO::pvt::oiio_print_debug #ifndef NDEBUG || true #endif @@ -967,7 +968,7 @@ bool ImageInput::read_native_tiles(int subimage, int miplevel, int xbegin, int xend, int ybegin, int yend, span data) { - if (pvt::oiio_print_debug + if (OIIO::pvt::oiio_print_debug #ifndef NDEBUG || true #endif @@ -991,7 +992,7 @@ ImageInput::read_native_tiles(int subimage, int miplevel, int xbegin, int xend, int ybegin, int yend, int chbegin, int chend, span data) { - if (pvt::oiio_print_debug + if (OIIO::pvt::oiio_print_debug #ifndef NDEBUG || true #endif @@ -1017,7 +1018,7 @@ ImageInput::read_native_volumetric_tiles(int subimage, int miplevel, int xbegin, int zbegin, int zend, span data) { - if (pvt::oiio_print_debug + if (OIIO::pvt::oiio_print_debug #ifndef NDEBUG || true #endif @@ -1043,7 +1044,7 @@ ImageInput::read_native_volumetric_tiles(int subimage, int miplevel, int xbegin, int zbegin, int zend, int chbegin, int chend, span data) { - if (pvt::oiio_print_debug + if (OIIO::pvt::oiio_print_debug #ifndef NDEBUG || true #endif @@ -1070,7 +1071,7 @@ ImageInput::read_image(int subimage, int miplevel, int chbegin, int chend, ProgressCallback progress_callback, void* progress_callback_data) { - pvt::LoggedTimer logtime("II::read_image"); + OIIO::pvt::LoggedTimer logtime("II::read_image"); ImageSpec spec; int rps = 0; { @@ -1181,7 +1182,7 @@ ImageInput::read_image(int subimage, int miplevel, int chbegin, int chend, return read_image(subimage, miplevel, chbegin, chend, format, data.data(), data.xstride(), data.ystride(), data.zstride()); #else - pvt::LoggedTimer logtime("II::read_image"); + OIIO::pvt::LoggedTimer logtime("II::read_image"); ImageSpec spec; int rps = 0; { @@ -1573,21 +1574,22 @@ ImageInput::check_open(const ImageSpec& spec, ROI range, uint64_t /*flags*/) format_name(), spec.nchannels); return false; } - if (pvt::limit_channels && spec.nchannels > pvt::limit_channels) { + if (OIIO::pvt::limit_channels + && spec.nchannels > OIIO::pvt::limit_channels) { errorfmt( "{} channels exceeds \"limits:channels\" = {}. Possible corrupt input?\nIf you're sure this is a valid file, raise the OIIO global attribute \"limits:channels\".", - spec.nchannels, pvt::limit_channels); + spec.nchannels, OIIO::pvt::limit_channels); return false; } - if (pvt::limit_imagesize_MB + if (OIIO::pvt::limit_imagesize_MB && spec.image_bytes(true) - > pvt::limit_imagesize_MB * imagesize_t(1024 * 1024)) { + > OIIO::pvt::limit_imagesize_MB * imagesize_t(1024 * 1024)) { errorfmt( "Uncompressed image size {:.1f} MB exceeds the {} MB limit.\n" "Image claimed to be {}x{}, {}-channel {}. Possible corrupt input?\n" "If this is a valid file, raise the OIIO attribute \"limits:imagesize_MB\".", float(m_spec.image_bytes(true)) / float(1024 * 1024), - pvt::limit_imagesize_MB, m_spec.width, m_spec.height, + OIIO::pvt::limit_imagesize_MB, m_spec.width, m_spec.height, m_spec.nchannels, m_spec.format); return false; } @@ -1618,20 +1620,11 @@ ImageInput::valid_raw_span_size(cspan buf, const ImageSpec& spec, -template<> -inline size_t -pvt::heapsize(const ImageInput::Impl& impl) -{ - return impl.m_io_local ? sizeof(Filesystem::IOProxy) : 0; -} - - - size_t ImageInput::heapsize() const { - size_t size = pvt::heapsize(m_impl); - size += pvt::heapsize(m_spec); + size_t size = OIIO::pvt::heapsize(m_impl); + size += OIIO::pvt::heapsize(m_spec); return size; } @@ -1645,6 +1638,15 @@ ImageInput::footprint() const +template<> +inline size_t +pvt::heapsize(const ImageInput::Impl& impl) +{ + return impl.m_io_local ? sizeof(Filesystem::IOProxy) : 0; +} + + + template<> size_t pvt::heapsize(const ImageInput& input) @@ -1661,6 +1663,4 @@ pvt::footprint(const ImageInput& input) return input.footprint(); } - - -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imageio.cpp b/src/libOpenImageIO/imageio.cpp index 8c28508958..909f8529d4 100644 --- a/src/libOpenImageIO/imageio.cpp +++ b/src/libOpenImageIO/imageio.cpp @@ -269,7 +269,10 @@ oiio_build_platform() return platform; } +OIIO_NAMESPACE_END + +OIIO_NAMESPACE_3_1_BEGIN void shutdown() @@ -358,7 +361,7 @@ attribute(string_view name, TypeDesc type, const void* val) } if (Strutil::starts_with(name, "gpu:") || Strutil::starts_with(name, "cuda:")) { - return pvt::gpu_attribute(name, type, val); + return OIIO::pvt::gpu_attribute(name, type, val); } // Things below here need to buarded by the attrib_mutex @@ -490,7 +493,7 @@ getattribute(string_view name, TypeDesc type, void* val) } if (Strutil::starts_with(name, "gpu:") || Strutil::starts_with(name, "cuda:")) { - return pvt::gpu_getattribute(name, type, val); + return OIIO::pvt::gpu_getattribute(name, type, val); } // Things below here need to buarded by the attrib_mutex @@ -509,31 +512,31 @@ getattribute(string_view name, TypeDesc type, void* val) } if (name == "format_list" && type == TypeString) { if (format_list.empty()) - pvt::catalog_all_plugins(plugin_searchpath.string()); + OIIO::pvt::catalog_all_plugins(plugin_searchpath.string()); *(ustring*)val = ustring(format_list); return true; } if (name == "input_format_list" && type == TypeString) { if (input_format_list.empty()) - pvt::catalog_all_plugins(plugin_searchpath.string()); + OIIO::pvt::catalog_all_plugins(plugin_searchpath.string()); *(ustring*)val = ustring(input_format_list); return true; } if (name == "output_format_list" && type == TypeString) { if (output_format_list.empty()) - pvt::catalog_all_plugins(plugin_searchpath.string()); + OIIO::pvt::catalog_all_plugins(plugin_searchpath.string()); *(ustring*)val = ustring(output_format_list); return true; } if (name == "extension_list" && type == TypeString) { if (extension_list.empty()) - pvt::catalog_all_plugins(plugin_searchpath.string()); + OIIO::pvt::catalog_all_plugins(plugin_searchpath.string()); *(ustring*)val = ustring(extension_list); return true; } if (name == "library_list" && type == TypeString) { if (library_list.empty()) - pvt::catalog_all_plugins(plugin_searchpath.string()); + OIIO::pvt::catalog_all_plugins(plugin_searchpath.string()); *(ustring*)val = ustring(library_list); return true; } @@ -714,8 +717,11 @@ getattribute(string_view name, TypeDesc type, void* val) return false; } +OIIO_NAMESPACE_3_1_END +OIIO_NAMESPACE_BEGIN + namespace { /// Type-independent template for turning potentially @@ -907,6 +913,10 @@ pvt::parallel_convert_from_float(const float* src, void* dst, size_t nvals, return dst; } +OIIO_NAMESPACE_END + + +OIIO_NAMESPACE_3_1_BEGIN bool @@ -921,7 +931,7 @@ convert_pixel_values(TypeDesc src_type, const void* src, TypeDesc dst_type, if (dst_type == TypeFloat) { // Special case -- converting non-float to float - pvt::convert_to_float(src, (float*)dst, n, src_type); + OIIO::pvt::convert_to_float(src, (float*)dst, n, src_type); return true; } @@ -937,7 +947,7 @@ convert_pixel_values(TypeDesc src_type, const void* src, TypeDesc dst_type, tmp.reset(new float[n]); // Freed when tmp exists its scope buf = tmp.get(); } - pvt::convert_to_float(src, buf, n, src_type); + OIIO::pvt::convert_to_float(src, buf, n, src_type); } // Convert float to 'dst_type' @@ -1219,10 +1229,9 @@ add_bluenoise(int nchannels, int width, int height, int depth, float* data, int channel = c + chorigin; if (channel == alpha_channel || channel == z_channel) continue; - float dither - = pvt::bluenoise_4chan_ptr(x + xorigin, y + yorigin, - z + zorigin, channel & (~3), - ditherseed)[channel & 3]; + float dither = OIIO::pvt::bluenoise_4chan_ptr( + x + xorigin, y + yorigin, z + zorigin, channel & (~3), + ditherseed)[channel & 3]; *val += ditheramplitude * (dither - 0.5f); } } @@ -1432,4 +1441,4 @@ image_span_within_span(const image_span& ispan, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imageioplugin.cpp b/src/libOpenImageIO/imageioplugin.cpp index 3089427445..68462cebf1 100644 --- a/src/libOpenImageIO/imageioplugin.cpp +++ b/src/libOpenImageIO/imageioplugin.cpp @@ -140,7 +140,10 @@ declare_imageio_format_locked(const std::string& format_name, } } +OIIO_NAMESPACE_END + +OIIO_NAMESPACE_3_1_BEGIN /// Register the input and output 'create' routine and list of file /// extensions for a particular format. @@ -151,7 +154,7 @@ declare_imageio_format(const std::string& format_name, ImageOutput::Creator output_creator, const char** output_extensions, const char* lib_version) { - std::lock_guard lock(pvt::imageio_mutex); + std::lock_guard lock(OIIO::pvt::imageio_mutex); declare_imageio_format_locked(format_name, input_creator, input_extensions, output_creator, output_extensions, lib_version); @@ -169,7 +172,7 @@ is_imageio_format_name(string_view name) if (!format_list_vector.size()) { lock.unlock(); // catalog_all_plugins() will lock imageio_mutex. - pvt::catalog_all_plugins(pvt::plugin_searchpath.string()); + OIIO::pvt::catalog_all_plugins(OIIO::pvt::plugin_searchpath.string()); lock.lock(); } for (const auto& n : format_list_vector) @@ -178,7 +181,11 @@ is_imageio_format_name(string_view name) return false; } +OIIO_NAMESPACE_3_1_END + + +OIIO_NAMESPACE_BEGIN static void catalog_plugin(const std::string& format_name, @@ -518,6 +525,10 @@ pvt::is_procedural_plugin(const std::string& name) return procedural_plugins.find(name) != procedural_plugins.end(); } +OIIO_NAMESPACE_END + + +OIIO_NAMESPACE_3_1_BEGIN std::unique_ptr @@ -548,9 +559,10 @@ ImageOutput::create(string_view filename, Filesystem::IOProxy* ioproxy, if (found == output_formats.end()) { lock.unlock(); // catalog_all_plugins() will lock imageio_mutex - catalog_all_plugins(plugin_searchpath.size() - ? plugin_searchpath - : string_view(pvt::plugin_searchpath)); + catalog_all_plugins( + plugin_searchpath.size() + ? plugin_searchpath + : string_view(OIIO::pvt::plugin_searchpath)); lock.lock(); found = output_formats.find(format); } @@ -647,7 +659,7 @@ ImageInput::create(string_view filename, bool do_open, const ImageSpec* config, InputPluginMap::const_iterator found = input_formats.find(format); if (found == input_formats.end()) { if (plugin_searchpath.empty()) - plugin_searchpath = pvt::plugin_searchpath; + plugin_searchpath = OIIO::pvt::plugin_searchpath; lock.unlock(); // catalog_all_plugins() will lock imageio_mutex. catalog_all_plugins(plugin_searchpath); @@ -700,7 +712,7 @@ ImageInput::create(string_view filename, bool do_open, const ImageSpec* config, create_function = nullptr; if (in) { specific_error = in->geterror(); - if (pvt::oiio_print_debug > 1) + if (OIIO::pvt::oiio_print_debug > 1) OIIO::debugfmt( "ImageInput::create: \"{}\" did not open using format \"{}\".\n", filename, in->format_name()); @@ -709,7 +721,7 @@ ImageInput::create(string_view filename, bool do_open, const ImageSpec* config, } } - if (!create_function && pvt::oiio_try_all_readers) { + if (!create_function && OIIO::pvt::oiio_try_all_readers) { // If a plugin can't be found that was explicitly designated for // this extension, then just try every one we find and see if // any will open the file. Add a configuration request that @@ -748,7 +760,7 @@ ImageInput::create(string_view filename, bool do_open, const ImageSpec* config, && !in->valid_file(filename))) { // Since we didn't need to open it, we just checked whether // it was a valid file, and it's not. Try the next one. - if (pvt::oiio_print_debug > 1) + if (OIIO::pvt::oiio_print_debug > 1) OIIO::debugfmt( "ImageInput::create: \"{}\" did not open using format \"{}\" {} [valid_file was false].\n", filename, plugin->first, in->format_name()); @@ -764,13 +776,13 @@ ImageInput::create(string_view filename, bool do_open, const ImageSpec* config, if (ok) { if (!do_open) in->close(); - if (pvt::oiio_print_debug > 1) + if (OIIO::pvt::oiio_print_debug > 1) OIIO::debugfmt( "ImageInput::create: \"{}\" succeeded using format \"{}\".\n", filename, plugin->first); return in; } - if (pvt::oiio_print_debug > 1) + if (OIIO::pvt::oiio_print_debug > 1) OIIO::debugfmt( "ImageInput::create: \"{}\" did not open using format \"{}\" {}.\n", filename, plugin->first, in->format_name()); @@ -809,4 +821,4 @@ ImageInput::create(string_view filename, bool do_open, const ImageSpec* config, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/imageoutput.cpp b/src/libOpenImageIO/imageoutput.cpp index 41e815aabf..1b9edaede5 100644 --- a/src/libOpenImageIO/imageoutput.cpp +++ b/src/libOpenImageIO/imageoutput.cpp @@ -25,8 +25,9 @@ -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN using namespace pvt; +using namespace OIIO::pvt; // store an error message per thread, for a specific ImageInput @@ -38,7 +39,7 @@ class ImageOutput::Impl { public: Impl() : m_id(++output_next_id) - , m_threads(pvt::oiio_threads) + , m_threads(OIIO::pvt::oiio_threads) { } @@ -600,7 +601,7 @@ ImageOutput::write_image(TypeDesc format, const void* data, stride_t xstride, ProgressCallback progress_callback, void* progress_callback_data) { - pvt::LoggedTimer logtime("ImageOutput::write image"); + OIIO::pvt::LoggedTimer logtime("ImageOutput::write image"); bool native = (format == TypeDesc::UNKNOWN); stride_t pixel_bytes = native ? (stride_t)m_spec.pixel_bytes(native) : format.size() * m_spec.nchannels; @@ -1140,20 +1141,11 @@ ImageOutput::check_open(OpenMode mode, const ImageSpec& userspec, ROI range, -template<> -inline size_t -pvt::heapsize(const ImageOutput::Impl& impl) -{ - return impl.m_io_local ? sizeof(Filesystem::IOProxy) : 0; -} - - - size_t ImageOutput::heapsize() const { - size_t size = pvt::heapsize(m_impl); - size += pvt::heapsize(m_spec); + size_t size = OIIO::pvt::heapsize(m_impl); + size += OIIO::pvt::heapsize(m_spec); return size; } @@ -1167,6 +1159,15 @@ ImageOutput::footprint() const +template<> +inline size_t +pvt::heapsize(const ImageOutput::Impl& impl) +{ + return impl.m_io_local ? sizeof(Filesystem::IOProxy) : 0; +} + + + template<> size_t pvt::heapsize(const ImageOutput& output) @@ -1183,6 +1184,4 @@ pvt::footprint(const ImageOutput& output) return output.footprint(); } - - -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/iptc.cpp b/src/libOpenImageIO/iptc.cpp index aa739eb950..b8ee573059 100644 --- a/src/libOpenImageIO/iptc.cpp +++ b/src/libOpenImageIO/iptc.cpp @@ -95,7 +95,10 @@ static IIMtag iimtag[] = { } // anonymous namespace +OIIO_NAMESPACE_END + +OIIO_NAMESPACE_3_1_BEGIN bool decode_iptc_iim(const void* iptc, int length, ImageSpec& spec) @@ -234,4 +237,4 @@ encode_iptc_iim(const ImageSpec& spec, std::vector& iptc) } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/maketexture.cpp b/src/libOpenImageIO/maketexture.cpp index 934d17b56e..ca38206523 100644 --- a/src/libOpenImageIO/maketexture.cpp +++ b/src/libOpenImageIO/maketexture.cpp @@ -29,8 +29,7 @@ #include "imageio_pvt.h" -using namespace OIIO; - +OIIO_NAMESPACE_BEGIN static spin_mutex maketx_mutex; // for anything that needs locking @@ -2042,14 +2041,18 @@ make_texture_impl(ImageBufAlgo::MakeTextureMode mode, const ImageBuf* input, return ok; } +OIIO_NAMESPACE_END + +OIIO_NAMESPACE_3_1_BEGIN + bool ImageBufAlgo::make_texture(ImageBufAlgo::MakeTextureMode mode, string_view filename, string_view outputfilename, const ImageSpec& configspec, std::ostream* outstream) { - pvt::LoggedTimer logtime("IBA::make_texture"); + OIIO::pvt::LoggedTimer logtime("IBA::make_texture"); bool ok = make_texture_impl(mode, NULL, filename, outputfilename, configspec, outstream); if (!ok && outstream && OIIO::has_error()) { @@ -2067,7 +2070,7 @@ ImageBufAlgo::make_texture(ImageBufAlgo::MakeTextureMode mode, string_view outputfilename, const ImageSpec& configspec, std::ostream* outstream) { - pvt::LoggedTimer logtime("IBA::make_texture"); + OIIO::pvt::LoggedTimer logtime("IBA::make_texture"); bool ok = make_texture_impl(mode, NULL, filenames[0], outputfilename, configspec, outstream); if (!ok && outstream && OIIO::has_error()) { @@ -2084,7 +2087,7 @@ ImageBufAlgo::make_texture(ImageBufAlgo::MakeTextureMode mode, const ImageBuf& input, string_view outputfilename, const ImageSpec& configspec, std::ostream* outstream) { - pvt::LoggedTimer logtime("IBA::make_texture"); + OIIO::pvt::LoggedTimer logtime("IBA::make_texture"); bool ok = make_texture_impl(mode, &input, "", outputfilename, configspec, outstream); if (!ok && outstream && OIIO::has_error()) { @@ -2093,3 +2096,5 @@ ImageBufAlgo::make_texture(ImageBufAlgo::MakeTextureMode mode, } return ok; } + +OIIO_NAMESPACE_3_1_END diff --git a/src/libOpenImageIO/xmp.cpp b/src/libOpenImageIO/xmp.cpp index 2301e8abc5..88e9f3fe42 100644 --- a/src/libOpenImageIO/xmp.cpp +++ b/src/libOpenImageIO/xmp.cpp @@ -513,7 +513,10 @@ decode_xmp_node(pugi::xml_node node, ImageSpec& spec, int level = 1, } // anonymous namespace +OIIO_NAMESPACE_END + +OIIO_NAMESPACE_3_1_BEGIN bool decode_xmp(cspan xml, ImageSpec& spec) @@ -857,4 +860,4 @@ encode_xmp(const ImageSpec& spec, bool minimal) } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libtexture/environment.cpp b/src/libtexture/environment.cpp index a103bfcbd1..e1fc9cf87d 100644 --- a/src/libtexture/environment.cpp +++ b/src/libtexture/environment.cpp @@ -199,7 +199,7 @@ convention is dictated by OpenEXR. */ -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN using namespace pvt; using namespace simd; using SubimageInfo = ImageCacheFile::SubimageInfo; @@ -643,4 +643,4 @@ TextureSystemImpl::environment(ustring filename, TextureOptBatch& options, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libtexture/imagecache.cpp b/src/libtexture/imagecache.cpp index e28d8a0e5e..deaf583ed5 100644 --- a/src/libtexture/imagecache.cpp +++ b/src/libtexture/imagecache.cpp @@ -36,7 +36,7 @@ #include "imageio_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN using namespace pvt; using ImageDims = ImageCacheFile::ImageDims; using LevelInfo = ImageCacheFile::LevelInfo; @@ -1048,7 +1048,7 @@ ImageCacheFile::init_from_spec() } // Squash some problematic texture metadata if we suspect it's wrong - pvt::check_texture_metadata_sanity(this->spec(0)); + OIIO::pvt::check_texture_metadata_sanity(this->spec(0)); // See if there's a SHA-1 hash in the image description string_view fing = spec.get_string_attribute("oiio:SHA-1"); @@ -2991,8 +2991,9 @@ ImageCacheImpl::resolve_filename(const std::string& filename) const { // Ask if the format can generate imagery procedurally. If so, don't // go looking for a file. - if (pvt::is_procedural_plugin(filename) - || pvt::is_procedural_plugin(Filesystem::extension(filename, false))) + if (OIIO::pvt::is_procedural_plugin(filename) + || OIIO::pvt::is_procedural_plugin( + Filesystem::extension(filename, false))) return filename; if (m_searchdirs.empty() || Filesystem::path_is_absolute(filename, true)) { // Don't bother with the searchpath_find call since it will do an @@ -4390,8 +4391,8 @@ ImageCacheImpl::append_error(string_view message) const size_t ImageCacheImpl::heapsize() const { - using OIIO::pvt::footprint; - using OIIO::pvt::heapsize; + using pvt::footprint; + using pvt::heapsize; size_t size = 0; // strings @@ -4419,8 +4420,8 @@ ImageCacheImpl::heapsize() const size_t ImageCacheImpl::footprint(ImageCacheFootprint& output) const { - using OIIO::pvt::footprint; - using OIIO::pvt::heapsize; + using pvt::footprint; + using pvt::heapsize; // strings output.ic_str_count = m_searchdirs.size() + 2; @@ -4950,4 +4951,4 @@ ImageCache::reset_stats() } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libtexture/imagecache_memory_pvt.h b/src/libtexture/imagecache_memory_pvt.h index a1e2a75310..2d078b6d2c 100644 --- a/src/libtexture/imagecache_memory_pvt.h +++ b/src/libtexture/imagecache_memory_pvt.h @@ -14,7 +14,7 @@ #include "imagecache_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace pvt { @@ -78,4 +78,4 @@ heapsize(const ImageCacheImpl& ic) } // namespace pvt -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libtexture/imagecache_pvt.h b/src/libtexture/imagecache_pvt.h index f81d78ec98..a147ce8a52 100644 --- a/src/libtexture/imagecache_pvt.h +++ b/src/libtexture/imagecache_pvt.h @@ -22,9 +22,6 @@ #include #include -OIIO_NAMESPACE_BEGIN - - #ifndef NDEBUG # define IMAGECACHE_TIME_STATS 1 #else @@ -39,22 +36,25 @@ OIIO_NAMESPACE_BEGIN #define TILE_CACHE_SHARDS 128 - -struct TileID; -class ImageCacheImpl; +OIIO_NAMESPACE_BEGIN struct ImageCacheFootprint; +OIIO_NAMESPACE_END -namespace pvt { +OIIO_NAMESPACE_3_1_BEGIN +namespace pvt { const char* texture_format_name(TexFormat f); const char* texture_type_name(TexFormat f); - } // namespace pvt +struct TileID; + + + /// Structure to hold IC and TS statistics. We combine into a single /// structure to minimize the number of costly ImageCachePerThreadInfo /// retrievals. If somebody is using the ImageCache without a @@ -158,8 +158,8 @@ struct UdimInfo { /// thread-specific IC data including microcache and statistics. /// class OIIO_API ImageCacheFile final : public RefCnt { - using TexFormat = pvt::TexFormat; - using EnvLayout = pvt::EnvLayout; + using TexFormat = v3_1::pvt::TexFormat; + using EnvLayout = v3_1::pvt::EnvLayout; using UdimInfo = pvt::UdimInfo; public: @@ -1397,7 +1397,7 @@ class ImageCacheImpl { }; -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END #endif // OPENIMAGEIO_IMAGECACHE_PVT_H diff --git a/src/libtexture/texoptions.cpp b/src/libtexture/texoptions.cpp index 3b3a72d91a..a634cef2eb 100644 --- a/src/libtexture/texoptions.cpp +++ b/src/libtexture/texoptions.cpp @@ -11,7 +11,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace { // anonymous @@ -94,4 +94,4 @@ Tex::parse_wrapmodes(const char* wrapmodes, Tex::Wrap& swrapcode, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libtexture/texture3d.cpp b/src/libtexture/texture3d.cpp index 19b2dfc2e0..7d492c9da3 100644 --- a/src/libtexture/texture3d.cpp +++ b/src/libtexture/texture3d.cpp @@ -22,7 +22,7 @@ #include "imagecache_pvt.h" #include "texture_pvt.h" -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN using namespace pvt; using LevelInfo = ImageCacheFile::LevelInfo; using SubimageInfo = ImageCacheFile::SubimageInfo; @@ -766,4 +766,4 @@ TextureSystemImpl::texture3d(ustring filename, TextureOptBatch& options, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libtexture/texture_pvt.h b/src/libtexture/texture_pvt.h index d5e5ce67a6..c1de13890a 100644 --- a/src/libtexture/texture_pvt.h +++ b/src/libtexture/texture_pvt.h @@ -14,11 +14,6 @@ #include OIIO_NAMESPACE_BEGIN - -class ImageCache; -class TextureSystemImpl; -class Filter1D; - #ifndef OPENIMAGEIO_IMAGECACHE_PVT_H class ImageCacheFile; class ImageCacheTile; @@ -26,8 +21,11 @@ class ImageCacheTileRef; class ImageCacheTileID; class ImageCacheImpl; #endif +OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_BEGIN + /// Working implementation of the abstract TextureSystem class. class TextureSystemImpl { @@ -554,6 +552,6 @@ TextureSystemImpl::st_to_texel(float s, float t, TextureFile& texturefile, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END #endif // OPENIMAGEIO_TEXTURE_PVT_H diff --git a/src/libtexture/texturesys.cpp b/src/libtexture/texturesys.cpp index 6b6bae186c..249c47b7aa 100644 --- a/src/libtexture/texturesys.cpp +++ b/src/libtexture/texturesys.cpp @@ -34,14 +34,16 @@ #define TEX_FAST_MATH 1 +using namespace OIIO::simd; -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN using namespace pvt; -using namespace simd; +using namespace OIIO::pvt; using LevelInfo = ImageCacheFile::LevelInfo; using SubimageInfo = ImageCacheFile::SubimageInfo; using ImageDims = ImageCacheFile::ImageDims; + namespace { // anonymous // We would like shared_texturesys to be a shared_ptr so that it is @@ -3642,4 +3644,4 @@ TextureSystem::unit_test_hash() } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/SHA1.cpp b/src/libutil/SHA1.cpp index 0ac8959bec..08d246871e 100644 --- a/src/libutil/SHA1.cpp +++ b/src/libutil/SHA1.cpp @@ -49,7 +49,7 @@ #pragma warning(disable: 4127) #endif -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN SHA1::SHA1 (const void *data, size_t size) { @@ -317,4 +317,4 @@ bool CSHA1::GetHash(UINT_8* pbDest20) const #pragma warning(pop) #endif -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/SHA1.h b/src/libutil/SHA1.h index 80970214ee..fca69aee68 100644 --- a/src/libutil/SHA1.h +++ b/src/libutil/SHA1.h @@ -219,7 +219,7 @@ /////////////////////////////////////////////////////////////////////////// // Declare SHA-1 workspace -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN typedef union { @@ -288,7 +288,7 @@ class CSHA1 SHA1_WORKSPACE_BLOCK* m_block; // SHA1 pointer to the byte array above }; -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END #ifndef DO_NOT_UNDEFINE_SHA1 #undef TCHAR diff --git a/src/libutil/argparse.cpp b/src/libutil/argparse.cpp index 6653ee992c..9ad566fac1 100644 --- a/src/libutil/argparse.cpp +++ b/src/libutil/argparse.cpp @@ -21,7 +21,9 @@ #include #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN +// All of ArgParse is still in the v3_1 namespace until it needs to break ABI +// compatibility. class ArgOption final : public ArgParse::Arg { public: @@ -151,7 +153,7 @@ class ArgParse::Impl { : m_argparse(parent) , m_argc(argc) , m_argv(argv) - , m_prog(Filesystem::filename(Sysutil::this_program_path())) + , m_prog(OIIO::Filesystem::filename(Sysutil::this_program_path())) { } @@ -1195,4 +1197,4 @@ ArgParse::set_next_arg(int nextarg) m_impl->m_next_arg = nextarg; } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/benchmark.cpp b/src/libutil/benchmark.cpp index 5642358035..f8e0d2a833 100644 --- a/src/libutil/benchmark.cpp +++ b/src/libutil/benchmark.cpp @@ -10,11 +10,11 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace pvt { -void OIIO_API +void OIIO_UTIL_API #if __has_attribute(__optnone__) __attribute__((__optnone__)) #endif @@ -27,7 +27,7 @@ void OIIO_API // Implementation of clobber_ptr is trivial, but the code in other modules // doesn't know that. -void OIIO_API +void OIIO_UTIL_API #if __has_attribute(__optnone__) __attribute__((__optnone__)) #endif @@ -110,7 +110,7 @@ Benchmarker::compute_stats(std::vector& times, size_t iterations) -OIIO_API +OIIO_UTIL_API std::ostream& operator<<(std::ostream& out, const Benchmarker& bench) { @@ -144,7 +144,7 @@ operator<<(std::ostream& out, const Benchmarker& bench) if (bench.indent()) OIIO::print(out, "{}", std::string(bench.indent(), ' ')); if (unit == int(Benchmarker::Unit::s)) - OIIO::print(out, "{:16}: {}", bench.m_name, + OIIO::print(out, "{:16}: {}", bench.name(), Strutil::timeintervalformat(avg, 2)); else OIIO::print(out, "{:16}: {:6.1f} {} (+/- {:.1f}{}), ", bench.name(), @@ -175,9 +175,14 @@ operator<<(std::ostream& out, const Benchmarker& bench) return out; } +OIIO_NAMESPACE_END + + +OIIO_NAMESPACE_3_1_BEGIN -OIIO_API std::vector + +OIIO_UTIL_API std::vector timed_thread_wedge(function_view task, function_view pretask, function_view posttask, std::ostream* out, int maxthreads, int total_iterations, int ntrials, @@ -220,7 +225,7 @@ timed_thread_wedge(function_view task, function_view pretask, -OIIO_API void +OIIO_UTIL_API void timed_thread_wedge(function_view task, int maxthreads, int total_iterations, int ntrials, cspan threadcounts) { @@ -229,4 +234,4 @@ timed_thread_wedge(function_view task, int maxthreads, ntrials, threadcounts); } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/errorhandler.cpp b/src/libutil/errorhandler.cpp index a9baeb79d7..d0d1a2c385 100644 --- a/src/libutil/errorhandler.cpp +++ b/src/libutil/errorhandler.cpp @@ -12,7 +12,7 @@ -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN @@ -58,4 +58,4 @@ ErrorHandler::operator()(int errcode, const std::string& msg) fflush(stderr); } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/farmhash.cpp b/src/libutil/farmhash.cpp index 128c63e1c7..98773d8dba 100644 --- a/src/libutil/farmhash.cpp +++ b/src/libutil/farmhash.cpp @@ -33,9 +33,9 @@ // namespace NAMESPACE_FOR_HASH_FUNCTIONS { - OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN - namespace farmhash { +namespace farmhash { // BASIC STRING HASHING @@ -43,7 +43,7 @@ // May change from time to time, may differ on different platforms, may differ // depending on NDEBUG. uint32_t Hash32(const char* s, size_t len) { - return farmhash::inlined::Hash32(s, len); + return OIIO::farmhash::inlined::Hash32(s, len); } // Hash function for a byte array. For convenience, a 32-bit seed is also @@ -51,7 +51,7 @@ uint32_t Hash32(const char* s, size_t len) { // May change from time to time, may differ on different platforms, may differ // depending on NDEBUG. uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed) { - return farmhash::inlined::Hash32WithSeed(s, len, seed); + return OIIO::farmhash::inlined::Hash32WithSeed(s, len, seed); } // Hash function for a byte array. For convenience, a 64-bit seed is also @@ -59,14 +59,14 @@ uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed) { // May change from time to time, may differ on different platforms, may differ // depending on NDEBUG. uint64_t Hash64(const char* s, size_t len) { - return farmhash::inlined::Hash64(s, len); + return OIIO::farmhash::inlined::Hash64(s, len); } // Hash function for a byte array. // May change from time to time, may differ on different platforms, may differ // depending on NDEBUG. size_t Hash(const char* s, size_t len) { - return farmhash::inlined::Hash(s, len); + return OIIO::farmhash::inlined::Hash(s, len); } // Hash function for a byte array. For convenience, a 64-bit seed is also @@ -74,7 +74,7 @@ size_t Hash(const char* s, size_t len) { // May change from time to time, may differ on different platforms, may differ // depending on NDEBUG. uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed) { - return farmhash::inlined::Hash64WithSeed(s, len, seed); + return OIIO::farmhash::inlined::Hash64WithSeed(s, len, seed); } // Hash function for a byte array. For convenience, two seeds are also @@ -82,14 +82,14 @@ uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed) { // May change from time to time, may differ on different platforms, may differ // depending on NDEBUG. uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1) { - return farmhash::inlined::Hash64WithSeeds(s, len, seed0, seed1); + return OIIO::farmhash::inlined::Hash64WithSeeds(s, len, seed0, seed1); } // Hash function for a byte array. // May change from time to time, may differ on different platforms, may differ // depending on NDEBUG. uint128_t Hash128(const char* s, size_t len) { - return farmhash::inlined::Hash128(s, len); + return OIIO::farmhash::inlined::Hash128(s, len); } // Hash function for a byte array. For convenience, a 128-bit seed is also @@ -97,7 +97,7 @@ uint128_t Hash128(const char* s, size_t len) { // May change from time to time, may differ on different platforms, may differ // depending on NDEBUG. uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed) { - return farmhash::inlined::Hash128WithSeed(s, len, seed); + return OIIO::farmhash::inlined::Hash128WithSeed(s, len, seed); } // BASIC NON-STRING HASHING @@ -106,21 +106,22 @@ uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed) { // Fingerprint function for a byte array. Most useful in 32-bit binaries. uint32_t Fingerprint32(const char* s, size_t len) { - return farmhash::inlined::Fingerprint32(s, len); + return OIIO::farmhash::inlined::Fingerprint32(s, len); } // Fingerprint function for a byte array. uint64_t Fingerprint64(const char* s, size_t len) { - return farmhash::inlined::Fingerprint64(s, len); + return OIIO::farmhash::inlined::Fingerprint64(s, len); } // Fingerprint function for a byte array. uint128_t Fingerprint128(const char* s, size_t len) { - return farmhash::inlined::Fingerprint128(s, len); + return OIIO::farmhash::inlined::Fingerprint128(s, len); } // Older and still available but perhaps not as fast as the above: // farmhashns::Hash32{,WithSeed}() // } // namespace NAMESPACE_FOR_HASH_FUNCTIONS -} /*end namespace farmhash*/ OIIO_NAMESPACE_END +} /*end namespace farmhash*/ +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/filesystem.cpp b/src/libutil/filesystem.cpp index 5ede2126c3..e19e35a40f 100644 --- a/src/libutil/filesystem.cpp +++ b/src/libutil/filesystem.cpp @@ -40,7 +40,7 @@ using std::error_code; -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN inline filesystem::path @@ -571,7 +571,7 @@ Filesystem::getline(FILE* file, size_t maxlen) void -Filesystem::open(OIIO::ifstream& stream, string_view path, +Filesystem::open(ifstream& stream, string_view path, std::ios_base::openmode mode) { #ifdef _WIN32 @@ -588,7 +588,7 @@ Filesystem::open(OIIO::ifstream& stream, string_view path, void -Filesystem::open(OIIO::ofstream& stream, string_view path, +Filesystem::open(ofstream& stream, string_view path, std::ios_base::openmode mode) { #ifdef _WIN32 @@ -1195,7 +1195,8 @@ Filesystem::IOFile::IOFile(string_view filename, Mode mode) { // Call Filesystem::fopen since it handles UTF-8 file paths on Windows, // which std fopen does not. - m_file = Filesystem::fopen(m_filename, m_mode == Write ? "w+b" : "rb"); + m_file = OIIO::Filesystem::fopen(m_filename, + m_mode == Write ? "w+b" : "rb"); if (!m_file) { m_mode = Closed; int e = errno; @@ -1204,7 +1205,7 @@ Filesystem::IOFile::IOFile(string_view filename, Mode mode) } m_auto_close = true; if (m_mode == Read) - m_size = Filesystem::file_size(filename); + m_size = OIIO::Filesystem::file_size(filename); } Filesystem::IOFile::IOFile(FILE* file, Mode mode) @@ -1212,10 +1213,12 @@ Filesystem::IOFile::IOFile(FILE* file, Mode mode) , m_file(file) { if (m_mode == Read) { - m_pos = Filesystem::ftell(m_file); // save old position - Filesystem::fseek(m_file, 0, SEEK_END); // seek to end - m_size = size_t(Filesystem::ftell(m_file)); // size is end position - Filesystem::fseek(m_file, m_pos, SEEK_SET); // restore old position + m_pos = OIIO::Filesystem::ftell(m_file); // save old position + OIIO::Filesystem::fseek(m_file, 0, SEEK_END); // seek to end + m_size = size_t( + OIIO::Filesystem::ftell(m_file)); // size is end position + OIIO::Filesystem::fseek(m_file, m_pos, + SEEK_SET); // restore old position } } @@ -1241,7 +1244,7 @@ Filesystem::IOFile::seek(int64_t offset) if (!m_file) return false; m_pos = offset; - return Filesystem::fseek(m_file, offset, SEEK_SET) == 0; + return OIIO::Filesystem::fseek(m_file, offset, SEEK_SET) == 0; } size_t @@ -1404,5 +1407,4 @@ Filesystem::IOMemReader::pread(void* buf, size_t size, int64_t offset) return size; } - -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/filter.cpp b/src/libutil/filter.cpp index a39a0d84a9..eb3a346db2 100644 --- a/src/libutil/filter.cpp +++ b/src/libutil/filter.cpp @@ -30,7 +30,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN // Below are the implementations of several 2D filters. They all // inherit their interface from Filter2D. Each must redefine two @@ -1047,4 +1047,4 @@ Filter2D::destroy(Filter2D* filt) } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/hashes.cpp b/src/libutil/hashes.cpp index 52a2e753dd..251269c784 100644 --- a/src/libutil/hashes.cpp +++ b/src/libutil/hashes.cpp @@ -12,7 +12,7 @@ #include #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace bjhash { @@ -782,4 +782,4 @@ uint32_t hashbig( const void *key, size_t length, uint32_t initval) } // end namespace bjhash -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/paramlist.cpp b/src/libutil/paramlist.cpp index 2721a3fc0c..026e80520b 100644 --- a/src/libutil/paramlist.cpp +++ b/src/libutil/paramlist.cpp @@ -12,7 +12,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN void @@ -102,25 +102,6 @@ ParamValue::operator=(ParamValue&& p) noexcept -namespace Strutil { -template<> -inline short -from_string(string_view s) -{ - return static_cast(Strutil::stoi(s)); -} - - -template<> -inline unsigned short -from_string(string_view s) -{ - return static_cast(Strutil::stoi(s)); -} -} // namespace Strutil - - - // helper to parse a list from a string template static void @@ -379,17 +360,6 @@ ParamValue::clear_value() noexcept -template<> -size_t -pvt::heapsize(const ParamValue& pv) -{ - return (pv.m_nonlocal && pv.m_copy) - ? pv.m_nvalues * static_cast(pv.m_type.size()) - : 0; -} - - - ParamValueList::const_iterator ParamValueList::find(ustring name, TypeDesc type, bool casesensitive) const { @@ -953,4 +923,13 @@ ParamValueSpan::getattribute_indexed(string_view name, int index, -OIIO_NAMESPACE_END +template<> +size_t +pvt::heapsize(const ParamValue& pv) +{ + return (pv.m_nonlocal && pv.m_copy) + ? pv.m_nvalues * static_cast(pv.m_type.size()) + : 0; +} + +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/plugin.cpp b/src/libutil/plugin.cpp index a8451c9c9a..8ec0a97979 100644 --- a/src/libutil/plugin.cpp +++ b/src/libutil/plugin.cpp @@ -25,7 +25,7 @@ OIIO_PRAGMA_WARNING_POP #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN using namespace Plugin; @@ -147,4 +147,4 @@ Plugin::geterror(bool clear) return e; } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/strutil.cpp b/src/libutil/strutil.cpp index ef0d80e7a7..224bafaf68 100644 --- a/src/libutil/strutil.cpp +++ b/src/libutil/strutil.cpp @@ -59,6 +59,18 @@ OIIO_PRAGMA_WARNING_POP OIIO_NAMESPACE_BEGIN +namespace pvt { +static const char* oiio_debug_env = getenv("OPENIMAGEIO_DEBUG"); +#ifdef NDEBUG +OIIO_UTIL_API int + oiio_print_debug(oiio_debug_env ? Strutil::stoi(oiio_debug_env) : 0); +#else +OIIO_UTIL_API int + oiio_print_debug(oiio_debug_env ? Strutil::stoi(oiio_debug_env) : 1); +#endif +OIIO_UTIL_API int oiio_print_uncaught_errors(1); +} // namespace pvt + namespace { @@ -77,6 +89,18 @@ static _locale_t c_loc = _create_locale(LC_ALL, "C"); +#if OIIO_VERSION_LESS(3, 1, 2) /* remove at next ABI compatibility boundary */ +void +pvt::log_fmt_error(const char* message) +{ + print("fmt exception: {}\n", message); + Strutil::pvt::append_error(std::string("fmt exception: ") + message); +} +#endif + +OIIO_NAMESPACE_END + + // Locale-independent quickie ASCII digit and alphanum tests, good enough // for our parsing. inline int @@ -101,6 +125,7 @@ isdigit(char c) } +OIIO_NAMESPACE_3_1_BEGIN OIIO_NO_SANITIZE_ADDRESS const char* c_str(string_view str) @@ -166,20 +191,6 @@ Strutil::sync_output(std::ostream& file, string_view str, bool flush) -namespace pvt { -static const char* oiio_debug_env = getenv("OPENIMAGEIO_DEBUG"); -#ifdef NDEBUG -OIIO_UTIL_API int - oiio_print_debug(oiio_debug_env ? Strutil::stoi(oiio_debug_env) : 0); -#else -OIIO_UTIL_API int - oiio_print_debug(oiio_debug_env ? Strutil::stoi(oiio_debug_env) : 1); -#endif -OIIO_UTIL_API int oiio_print_uncaught_errors(1); -} // namespace pvt - - - // ErrorHolder houses a string, with the addition that when it is destroyed, // it will disgorge any un-retrieved error messages, in an effort to help // beginning users diagnose their problems if they have forgotten to call @@ -189,7 +200,7 @@ struct ErrorHolder { ~ErrorHolder() { - if (!error_msg.empty() && pvt::oiio_print_uncaught_errors) { + if (!error_msg.empty() && OIIO::pvt::oiio_print_uncaught_errors) { OIIO::print( "OpenImageIO exited with a pending error message that was never\n" "retrieved via OIIO::geterror(). This was the error message:\n{}\n", @@ -246,17 +257,6 @@ Strutil::pvt::geterror(bool clear) } -#if OIIO_VERSION_LESS(3, 1, 2) /* remove at next ABI compatibility boundary */ -void -pvt::log_fmt_error(const char* message) -{ - print("fmt exception: {}\n", message); - Strutil::pvt::append_error(std::string("fmt exception: ") + message); -} -#endif - - - void Strutil::pvt::debug(string_view message) { @@ -2008,4 +2008,5 @@ Strutil::eval_as_bool(string_view value) } } -OIIO_NAMESPACE_END + +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/strutil_test.cpp b/src/libutil/strutil_test.cpp index fba21ee41f..a9b8bed758 100644 --- a/src/libutil/strutil_test.cpp +++ b/src/libutil/strutil_test.cpp @@ -1315,7 +1315,7 @@ test_string_view() OIIO_CHECK_EQUAL(OIIO::c_str(string_view(sr.data(), 2)), std::string("01")); Strutil::print("addr cstr={:p}, s={:p}, ustring={:p}, sr={:p}, c_str(sr)={:p}\n", (void*)cstr, (void*)s.c_str(), (void*)ustring(cstr).c_str(), (void*)sr.data(), - (void*)c_str(sr)); + (void*)OIIO::c_str(sr)); } diff --git a/src/libutil/sysutil.cpp b/src/libutil/sysutil.cpp index e89af9cfaa..03e9127473 100644 --- a/src/libutil/sysutil.cpp +++ b/src/libutil/sysutil.cpp @@ -76,9 +76,7 @@ OIIO_INTEL_PRAGMA(warning disable 2196) -OIIO_NAMESPACE_BEGIN - -using namespace Sysutil; +OIIO_NAMESPACE_3_1_BEGIN size_t @@ -369,9 +367,6 @@ isatty(int fd) #endif -Term::Term(FILE* file) { m_is_console = isatty(fileno((file))); } - - #ifdef _WIN32 // from https://msdn.microsoft.com/fr-fr/library/windows/desktop/mt638032%28v=vs.85%29.aspx @@ -404,6 +399,11 @@ enableVTMode() +namespace Sysutil { + +Term::Term(FILE* file) { m_is_console = isatty(fileno((file))); } + + Term::Term(const std::ostream& stream) { m_is_console = (&stream == &std::cout && isatty(fileno(stdout))) @@ -525,6 +525,8 @@ Term::ansi_bgcolor(int r, int g, int b) return ret; } +} // end namespace Sysutil + bool @@ -598,7 +600,8 @@ Sysutil::max_open_files() -void* +// Backward link compatibility +OIIO_UTIL_API void* aligned_malloc(std::size_t size, std::size_t align) { #if defined(_WIN32) @@ -609,9 +612,8 @@ aligned_malloc(std::size_t size, std::size_t align) #endif } - - -void +// Backward link compatibility +OIIO_UTIL_API void aligned_free(void* ptr) { #if defined(_WIN32) @@ -685,4 +687,4 @@ Sysutil::setup_crash_stacktrace(string_view filename) } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/thread.cpp b/src/libutil/thread.cpp index 87dd488b1c..d6e605841f 100644 --- a/src/libutil/thread.cpp +++ b/src/libutil/thread.cpp @@ -87,10 +87,15 @@ OIIO_NAMESPACE_END OIIO_NAMESPACE_BEGIN - namespace pvt { OIIO_UTIL_API int oiio_use_tbb(0); // Use TBB if available } +OIIO_NAMESPACE_END + + +OIIO_NAMESPACE_3_1_BEGIN +// Thread utils still in the v3_1 namespace until it needs to break ABI +// compatibility. static int @@ -345,7 +350,7 @@ class thread_pool::Impl { std::vector> threads; std::vector>> flags; - mutable pvt::ThreadsafeQueue*> q; + mutable OIIO::pvt::ThreadsafeQueue*> q; std::atomic isDone; std::atomic isStop; std::atomic nWaiting; // how many threads are waiting @@ -576,20 +581,6 @@ task_set::wait(bool block) -// Helper function to keep track of the recursve depth of our use of the -// thread pool. Call with the adjustment (i.e., parallel_recursive_depth(1) -// to enter, parallel_recursive_depth(-1) to exit), and it will return the -// new value. Call with default args (0) to just return the current depth. -static int -parallel_recursive_depth(int change = 0) -{ - thread_local int depth = 0; // let's only allow one level of parallel work - depth += change; - return depth; -} - - - void paropt::resolve() { @@ -603,6 +594,20 @@ paropt::resolve() +// Helper function to keep track of the recursive depth of our use of the +// thread pool. Call with the adjustment (i.e., parallel_recursive_depth(1) +// to enter, parallel_recursive_depth(-1) to exit), and it will return the +// new value. Call with default args (0) to just return the current depth. +static int +parallel_recursive_depth(int change = 0) +{ + thread_local int depth = 0; // let's only allow one level of parallel work + depth += change; + return depth; +} + + + void parallel_for_chunked_id(int64_t begin, int64_t end, int64_t chunksize, std::function&& task, @@ -652,7 +657,7 @@ parallel_for_chunked(int64_t begin, int64_t end, int64_t chunksize, template inline void -parallel_for_impl(Index begin, Index end, function_view task, +parallel_for_impl(Index begin, Index end, function_view&& task, paropt opt) { if (opt.maxthreads() == 1) { @@ -664,7 +669,7 @@ parallel_for_impl(Index begin, Index end, function_view task, #if OIIO_TBB if (opt.strategy() == paropt::ParStrategy::TryTBB || (opt.strategy() == paropt::ParStrategy::Default - && pvt::oiio_use_tbb)) { + && OIIO::pvt::oiio_use_tbb)) { if (opt.maxthreads()) { tbb::task_arena arena(opt.maxthreads()); arena.execute([=] { tbb::parallel_for(begin, end, task); }); @@ -685,37 +690,79 @@ parallel_for_impl(Index begin, Index end, function_view task, +// DEPRECATED void parallel_for(int begin, int end, function_view task, paropt opt) { - parallel_for_impl(begin, end, task, opt); + parallel_for_impl(begin, end, std::move(task), opt); } +// DEPRECATED void parallel_for(uint32_t begin, uint32_t end, function_view task, paropt opt) { - parallel_for_impl(begin, end, task, opt); + parallel_for_impl(begin, end, std::move(task), opt); } +// DEPRECATED void parallel_for(int64_t begin, int64_t end, function_view task, paropt opt) { - parallel_for_impl(begin, end, task, opt); + parallel_for_impl(begin, end, std::move(task), opt); } +// DEPRECATED void parallel_for(uint64_t begin, uint64_t end, function_view task, paropt opt) { - parallel_for_impl(begin, end, task, opt); + parallel_for_impl(begin, end, std::move(task), opt); +} + +OIIO_NAMESPACE_3_1_END + + +OIIO_NAMESPACE_BEGIN + +void +parallel_for(int begin, int end, function_view&& task, paropt opt) +{ + parallel_for_impl(begin, end, std::move(task), opt); +} + + +void +parallel_for(uint32_t begin, uint32_t end, function_view&& task, + paropt opt) +{ + parallel_for_impl(begin, end, std::move(task), opt); } +void +parallel_for(int64_t begin, int64_t end, function_view&& task, + paropt opt) +{ + parallel_for_impl(begin, end, std::move(task), opt); +} + + +void +parallel_for(uint64_t begin, uint64_t end, function_view&& task, + paropt opt) +{ + parallel_for_impl(begin, end, std::move(task), opt); +} + +OIIO_NAMESPACE_END + + +OIIO_NAMESPACE_3_1_BEGIN template inline void @@ -854,4 +901,4 @@ parallel_for_2D(int64_t xbegin, int64_t xend, int64_t ybegin, int64_t yend, } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/timer.cpp b/src/libutil/timer.cpp index 9dbec63f3c..7692c10e95 100644 --- a/src/libutil/timer.cpp +++ b/src/libutil/timer.cpp @@ -12,7 +12,7 @@ #endif -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN double Timer::seconds_per_tick; Timer::ticks_t Timer::ticks_per_second; @@ -68,4 +68,4 @@ Timer::now(void) const } #endif -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/typedesc.cpp b/src/libutil/typedesc.cpp index 53e2bf07bd..1c58346a7e 100644 --- a/src/libutil/typedesc.cpp +++ b/src/libutil/typedesc.cpp @@ -16,7 +16,7 @@ #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN TypeDesc::TypeDesc(string_view typestring) : basetype(UNKNOWN) @@ -360,6 +360,57 @@ TypeDesc::fromstring(string_view typestring) +bool +TypeDesc::operator<(const TypeDesc& x) const noexcept +{ + if (basetype != x.basetype) + return basetype < x.basetype; + if (aggregate != x.aggregate) + return aggregate < x.aggregate; + if (arraylen != x.arraylen) + return arraylen < x.arraylen; + if (vecsemantics != x.vecsemantics) + return vecsemantics < x.vecsemantics; + return false; // they are equal +} + + + +TypeDesc::BASETYPE +TypeDesc::basetype_merge(TypeDesc at, TypeDesc bt) +{ + BASETYPE a = (BASETYPE)at.basetype; + BASETYPE b = (BASETYPE)bt.basetype; + + // Same type already? done. + if (a == b) + return a; + if (a == UNKNOWN) + return b; + if (b == UNKNOWN) + return a; + // Canonicalize so a's size (in bytes) is >= b's size in bytes. This + // unclutters remaining cases. + if (TypeDesc(a).size() < TypeDesc(b).size()) + std::swap(a, b); + // Double or float trump anything else + if (a == DOUBLE || a == FLOAT) + return a; + if (a == UINT32 && (b == UINT16 || b == UINT8)) + return a; + if (a == INT32 && (b == INT16 || b == UINT16 || b == INT8 || b == UINT8)) + return a; + if ((a == UINT16 || a == HALF) && b == UINT8) + return a; + if ((a == INT16 || a == HALF) && (b == INT8 || b == UINT8)) + return a; + // Out of common cases. For all remaining edge cases, punt and say that + // we prefer float. + return FLOAT; +} + + + tostring_formatting::tostring_formatting( const char* int_fmt, const char* float_fmt, const char* string_fmt, const char* ptr_fmt, const char* aggregate_begin, const char* aggregate_end, @@ -801,7 +852,7 @@ convert_type(TypeDesc srctype, const void* src, TypeDesc dsttype, void* dst, if (srctype == TypeUstringhash) (*(ustring*)dst) = ustring::from_hash(*(const ustring::hash_t*)src); else - (*(ustring*)dst) = ustring(tostring(srctype, src)); + (*(ustring*)dst) = ustring(OIIO::tostring(srctype, src)); return true; } @@ -858,55 +909,4 @@ convert_type(TypeDesc srctype, const void* src, TypeDesc dsttype, void* dst, return false; } - - -bool -TypeDesc::operator<(const TypeDesc& x) const noexcept -{ - if (basetype != x.basetype) - return basetype < x.basetype; - if (aggregate != x.aggregate) - return aggregate < x.aggregate; - if (arraylen != x.arraylen) - return arraylen < x.arraylen; - if (vecsemantics != x.vecsemantics) - return vecsemantics < x.vecsemantics; - return false; // they are equal -} - - - -TypeDesc::BASETYPE -TypeDesc::basetype_merge(TypeDesc at, TypeDesc bt) -{ - BASETYPE a = (BASETYPE)at.basetype; - BASETYPE b = (BASETYPE)bt.basetype; - - // Same type already? done. - if (a == b) - return a; - if (a == UNKNOWN) - return b; - if (b == UNKNOWN) - return a; - // Canonicalize so a's size (in bytes) is >= b's size in bytes. This - // unclutters remaining cases. - if (TypeDesc(a).size() < TypeDesc(b).size()) - std::swap(a, b); - // Double or float trump anything else - if (a == DOUBLE || a == FLOAT) - return a; - if (a == UINT32 && (b == UINT16 || b == UINT8)) - return a; - if (a == INT32 && (b == INT16 || b == UINT16 || b == INT8 || b == UINT8)) - return a; - if ((a == UINT16 || a == HALF) && b == UINT8) - return a; - if ((a == INT16 || a == HALF) && (b == INT8 || b == UINT8)) - return a; - // Out of common cases. For all remaining edge cases, punt and say that - // we prefer float. - return FLOAT; -} - -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/ustring.cpp b/src/libutil/ustring.cpp index 211c944e67..3da39ccf65 100644 --- a/src/libutil/ustring.cpp +++ b/src/libutil/ustring.cpp @@ -12,7 +12,7 @@ #include #include -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN // Use rw spin locks typedef spin_rw_mutex ustring_mutex_t; @@ -662,4 +662,4 @@ ustring::memory() return table.get_memory_usage(); } -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/libutil/xxhash.cpp b/src/libutil/xxhash.cpp index c0afcfefbb..e988bab4c5 100644 --- a/src/libutil/xxhash.cpp +++ b/src/libutil/xxhash.cpp @@ -140,7 +140,7 @@ typedef unsigned long long U64; #endif -OIIO_NAMESPACE_BEGIN +OIIO_NAMESPACE_3_1_BEGIN namespace xxhash { @@ -952,4 +952,4 @@ unsigned long long XXH64_digest (const XXH64_state_t* state_in) } // namespace xxhash -OIIO_NAMESPACE_END +OIIO_NAMESPACE_3_1_END diff --git a/src/oiiotool/oiiotool.cpp b/src/oiiotool/oiiotool.cpp index bf75e18870..c0ae72f9a2 100644 --- a/src/oiiotool/oiiotool.cpp +++ b/src/oiiotool/oiiotool.cpp @@ -3424,7 +3424,7 @@ ImageBufAlgox::cryptomatte_colors(ImageBuf& dst, const ImageBuf& src, span channelset, ROI roi, int nthreads) { - // pvt::LoggedTimer logtime("IBA::cryptomatte_colors"); + // OIIO::pvt::LoggedTimer logtime("IBA::cryptomatte_colors"); if (!roi.defined()) roi = get_roi(src.spec()); roi.chend = std::min(roi.chend, src.nchannels()); @@ -7535,7 +7535,7 @@ handle_sequence(Oiiotool& ot, int argc, const char** argv) OIIO::print("Running {} frames in parallel with {} threads\n", nfilenames, parallel_frame_threads); ot.begin_parallel_frame_loop(parallel_frame_threads); - parallel_for( + OIIO::parallel_for( uint64_t(0), uint64_t(nfilenames), [&](uint64_t i) { one_sequence_iteration(ot, i, frame_numbers[0][i],