From 10d6bffc5c880ab86a6f787c69168059bdd59bd9 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sun, 21 Jul 2024 11:59:26 -0700 Subject: [PATCH 01/22] docs: Add deprecation updates to the RELEASING checklist (#4345) Signed-off-by: Larry Gritz --- RELEASING.md | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 64192bb2a4..1df82d3aff 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -155,7 +155,34 @@ have a heading added at the top for the *next* version. pages), and that the [INSTALL.md](../INSTALL.md) file correctly documents the version ranges that we expect to work and that we actively test. -2. Release notes: [CHANGES.md](../CHANGES.md) should be updated to reflect +2. Update deprecations: Deprecations tend to happen in stages, spread over a + few releases, taking steps forward depending on what kind of release is + occurring: + + - Tweak releases (a.b.c.d -> a.b.c.D+1): should not introduce new + deprecations. + - Monthly patch releases (a.b.c.d -> a.b.C+1.0): advertise that a function + is deprecated in its comments, documentation, and release notes. Remember + that these releases are not allowed to break ABI/link compatibility. + - Annual minor releases (a.b.c.d -> a.B+1.0.0): functions previously + marked/documented as deprecated should receive deprecation warnings by + adding `OIIO_DEPRECATED` macros to function or class declarations where + possible, if that has not already been done. Use good judgment about + whether to add these warnings, or postpone to a later release, based on + the amount of disruption that they will likely cause, and how important + it is to rapidly discourage people from using the deprecated function. + For a minor release, we don't allow backwards-incompatible API changes, + so only *remove* a function if there is another function that will accept + the same call signature in the source code. It's allowed to break ABI for + minor releases, so it's ok/encouraged to make a deprecated function from + linked to inline, for example (which might allow it to be removed later + without an ABI change). + - Major releases (a.b.c.d -> A+1.b.c.d): API compatibility breaks are + allowed here, so this is the time to completely remove any functions that + have already had a full minor release where they had been given + deprecation warning macros. + +3. Release notes: [CHANGES.md](../CHANGES.md) should be updated to reflect all the new features and fixes. Looking at the notes from older releases should provide a good example of what we're aiming for. @@ -168,7 +195,7 @@ have a heading added at the top for the *next* version. internals and developer goodies, testing/CI/ports, etc.) and ordered for readability and relevance. -3. Ensure docs are up to date: +4. Ensure docs are up to date: - [README.md](README.md): Actually read it! Make sure it all seems accurate and up to date. @@ -182,7 +209,7 @@ have a heading added at the top for the *next* version. ensure it's building correctly and doesn't have any obvious errors, especially the parts that describe new features. -4. Make sure the the top-level CMakeLists.txt file is updated: +5. Make sure the the top-level CMakeLists.txt file is updated: - The `OpenImageIO_VERSION` should be correct. - The `PROJECT_VERSION_RELEASE_TYPE` variable should be set to "alpha" or @@ -192,14 +219,14 @@ have a heading added at the top for the *next* version. - The `${PROJECT_NAME}_SUPPORTED_RELEASE` variable should be `ON` for any release branch, `OFF` for master. -5. In the https://github.com/AcademySoftwareFoundation/OpenImageIO-images project, create a branch +6. In the https://github.com/AcademySoftwareFoundation/OpenImageIO-images project, create a branch `dev-x.y` for the major/minor branch, and in the main oiio repo, update src/build-scripts/install_test_images.bash to specify `-b dev-x.y` in the checkout of oiio-images to ensure CI tests are against the set of test images corresponding to that major/minor release (just in the branch, not in master!). -6. Make sure everything passes the usual CI workflow. Also check the daily or +7. Make sure everything passes the usual CI workflow. Also check the daily or weekly "analysis" workflows to make sure there aren't any important warnings that should be fixed. From a8d06f390ad1d2be401b70328e9f85c17105e07f Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sun, 21 Jul 2024 16:24:32 -0700 Subject: [PATCH 02/22] build(deps): Raise ffmpeg minimum to 4.0 (released in 2018) (#4352) Signed-off-by: Larry Gritz --- INSTALL.md | 2 +- src/cmake/externalpackages.cmake | 2 +- src/ffmpeg.imageio/ffmpeginput.cpp | 40 ++++++++---------------------- 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index db5412f8d0..1f1d6c0d04 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -41,7 +41,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**. * If you want support for camera "RAW" formats: * **LibRaw >= 0.20** (tested though 0.21.2) * If you want support for a wide variety of video formats: - * ffmpeg >= 3.0 (tested through 7.0) + * **ffmpeg >= 4.0** (tested through 7.0) * If you want support for jpeg 2000 images: * OpenJpeg >= 2.0 (tested through 2.5; we recommend 2.4 or higher for multithreading support) diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake index 14c451f62e..708f012ed3 100644 --- a/src/cmake/externalpackages.cmake +++ b/src/cmake/externalpackages.cmake @@ -161,7 +161,7 @@ checked_find_package (TBB 2017 # DCMTK is used to read DICOM images checked_find_package (DCMTK CONFIG VERSION_MIN 3.6.1) -checked_find_package (FFmpeg VERSION_MIN 3.0) +checked_find_package (FFmpeg VERSION_MIN 4.0) checked_find_package (GIF VERSION_MIN 4 RECOMMEND_MIN 5.0 diff --git a/src/ffmpeg.imageio/ffmpeginput.cpp b/src/ffmpeg.imageio/ffmpeginput.cpp index 926cfbe3d7..a36027f1e7 100644 --- a/src/ffmpeg.imageio/ffmpeginput.cpp +++ b/src/ffmpeg.imageio/ffmpeginput.cpp @@ -2,16 +2,12 @@ // SPDX-License-Identifier: BSD-3-Clause and Apache-2.0 // https://github.com/AcademySoftwareFoundation/OpenImageIO -extern "C" { // ffmpeg is a C api #include + +extern "C" { // ffmpeg is a C api #include #include #include -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 24, 100) -# error "OIIO FFmpeg support requires FFmpeg >= 3.0" -#endif -#include -} // It's hard to figure out FFMPEG versions from what they give us, so // record some of the milestones once and for all for easy reference. @@ -29,6 +25,12 @@ extern "C" { // ffmpeg is a C api #define USE_FFMPEG_4_3 (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58, 91, 100)) #define USE_FFMPEG_4_4 (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58, 134, 100)) +#if !USE_FFMPEG_4_0 +# error "OIIO FFmpeg support requires FFmpeg >= 4.0" +#endif + +#include +} inline int @@ -41,9 +43,9 @@ avpicture_fill(AVFrame* picture, uint8_t* ptr, enum AVPixelFormat pix_fmt, } -#if USE_FFMPEG_3_1 -// AVStream::codec was changed to AVStream::codecpar -# define stream_codec(ix) m_format_context->streams[(ix)]->codecpar +#define stream_codec(ix) m_format_context->streams[(ix)]->codecpar + + // avcodec_decode_video2 was deprecated. // This now works by sending `avpkt` to the decoder, which buffers the // decoded image in `avctx`. Then `avcodec_receive_frame` will copy the @@ -65,16 +67,6 @@ receive_frame(AVCodecContext* avctx, AVFrame* picture, AVPacket* avpkt) return 1; } -#else -# define stream_codec(ix) m_format_context->streams[(ix)]->codec -inline int -receive_frame(AVCodecContext* avctx, AVFrame* picture, AVPacket* avpkt) -{ - int ret; - avcodec_decode_video2(avctx, picture, &ret, avpkt); - return ret; -} -#endif @@ -265,7 +257,6 @@ FFmpegInput::open(const std::string& name, ImageSpec& spec) } // codec context for videostream -#if USE_FFMPEG_3_1 AVCodecParameters* par = stream_codec(m_video_stream); m_codec = avcodec_find_decoder(par->codec_id); @@ -287,15 +278,6 @@ FFmpegInput::open(const std::string& name, ImageSpec& spec) errorfmt("\"{}\" unsupported codec", file_name); return false; } -#else - m_codec_context = stream_codec(m_video_stream); - - m_codec = avcodec_find_decoder(m_codec_context->codec_id); - if (!m_codec) { - errorfmt("\"{}\" unsupported codec", file_name); - return false; - } -#endif if (avcodec_open2(m_codec_context, m_codec, NULL) < 0) { errorfmt("\"{}\" could not open codec", file_name); From 096cb1625f150999231d23cb0b2950abbd60dc88 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 22 Jul 2024 07:06:27 -0700 Subject: [PATCH 03/22] fix: sanitizer new warnings about signed/unsigned offsets in openexr (#4351) Signed-off-by: Larry Gritz --- src/openexr.imageio/exrinput.cpp | 3 ++- src/openexr.imageio/exroutput.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/openexr.imageio/exrinput.cpp b/src/openexr.imageio/exrinput.cpp index 2adb03cbdd..2085ada3a4 100644 --- a/src/openexr.imageio/exrinput.cpp +++ b/src/openexr.imageio/exrinput.cpp @@ -1140,7 +1140,8 @@ OpenEXRInput::read_native_scanlines(int subimage, int miplevel, int ybegin, const PartInfo& part(m_parts[m_subimage]); size_t pixelbytes = m_spec.pixel_bytes(chbegin, chend, true); size_t scanlinebytes = (size_t)m_spec.width * pixelbytes; - char* buf = (char*)data - m_spec.x * pixelbytes - ybegin * scanlinebytes; + char* buf = (char*)data - m_spec.x * stride_t(pixelbytes) + - ybegin * stride_t(scanlinebytes); try { if (part.luminance_chroma) { diff --git a/src/openexr.imageio/exroutput.cpp b/src/openexr.imageio/exroutput.cpp index 0820834d8c..e89cb0a528 100644 --- a/src/openexr.imageio/exroutput.cpp +++ b/src/openexr.imageio/exroutput.cpp @@ -1508,7 +1508,8 @@ OpenEXROutput::write_scanlines(int ybegin, int yend, int z, TypeDesc format, // the bytes to be written, but OpenEXR's frameBuffer.insert() wants // where the address of the "virtual framebuffer" for the whole // image. - char* buf = (char*)d - m_spec.x * pixel_bytes - y * scanlinebytes; + char* buf = (char*)d - m_spec.x * stride_t(pixel_bytes) + - y * stride_t(scanlinebytes); try { Imf::FrameBuffer frameBuffer; size_t chanoffset = 0; From 72daf8b7f2ce78706831790edf5f560ce25b2c45 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 22 Jul 2024 10:36:48 -0700 Subject: [PATCH 04/22] deps: Raise OpenCV minimum to 4.0 (~2018) (#4353) Signed-off-by: Larry Gritz --- INSTALL.md | 2 +- src/cmake/externalpackages.cmake | 2 +- src/libOpenImageIO/imagebufalgo_opencv.cpp | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 1f1d6c0d04..440fca44ba 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -52,7 +52,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**. * TBB >= 2018 (tested through 2021 and OneTBB) * If you want support for converting to and from OpenCV data structures, or for capturing images from a camera: - * OpenCV 3.x, or 4.x (tested through 4.9) + * **OpenCV 4.x** (tested through 4.10) * If you want support for GIF images: * giflib >= 4.1 (tested through 5.2; 5.0+ is strongly recommended for stability and thread safety) diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake index 708f012ed3..373c57659b 100644 --- a/src/cmake/externalpackages.cmake +++ b/src/cmake/externalpackages.cmake @@ -149,7 +149,7 @@ else () endif () include_directories(BEFORE ${OPENCOLORIO_INCLUDES}) -checked_find_package (OpenCV 3.0 +checked_find_package (OpenCV 4.0 DEFINITIONS USE_OPENCV=1) # Intel TBB diff --git a/src/libOpenImageIO/imagebufalgo_opencv.cpp b/src/libOpenImageIO/imagebufalgo_opencv.cpp index a04ce8bbdc..c95a8fd90f 100644 --- a/src/libOpenImageIO/imagebufalgo_opencv.cpp +++ b/src/libOpenImageIO/imagebufalgo_opencv.cpp @@ -28,6 +28,8 @@ # if OIIO_OPENCV_VERSION >= 40000 # include # include +# else +# error "OpenCV 4.0 is the minimum supported version" # endif #endif @@ -161,12 +163,7 @@ ImageBufAlgo::to_OpenCV(cv::Mat& dst, const ImageBuf& src, ROI roi, dstFormat = CV_MAKETYPE(CV_16S, chans); dstSpecFormat = TypeInt16; } else if (spec.format == TypeDesc(TypeDesc::HALF)) { -# if OIIO_OPENCV_VERSION >= 40000 dstFormat = CV_MAKETYPE(CV_16F, chans); -# else - dstFormat = CV_MAKETYPE(CV_32F, chans); - dstSpecFormat = TypeFloat; -# endif } else if (spec.format == TypeDesc(TypeDesc::FLOAT)) { dstFormat = CV_MAKETYPE(CV_32F, chans); } else if (spec.format == TypeDesc(TypeDesc::DOUBLE)) { From 0fed401abf35b93cf1862be4a7bb32f69e99fbcd Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 22 Jul 2024 10:37:44 -0700 Subject: [PATCH 05/22] deps: Raise WebP minimum version to 1.1 (#4354) This new version dates to 2020. Previously, we had supported (purportedly) WebP 0.6.1, but we didn't test that configuration. By bumping to 1.1 minimum, we can use WebP's own exported cmake config, rather than maintaining a FindWebP.cmake mmodule on our side. Signed-off-by: Larry Gritz --- .github/workflows/ci.yml | 10 ++-- INSTALL.md | 2 +- src/build-scripts/build_webp.bash | 4 +- src/cmake/externalpackages.cmake | 4 +- src/cmake/modules/FindWebP.cmake | 77 ------------------------------- 5 files changed, 9 insertions(+), 88 deletions(-) delete mode 100644 src/cmake/modules/FindWebP.cmake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fbf2f8678f..3ea0ac8a8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -150,7 +150,7 @@ jobs: simd: "avx2,f16c" fmt_ver: 10.1.1 pybind11_ver: v2.12.0 - - desc: oldest/hobbled gcc9.3/C++17 py3.7 exr-3.1 no-sse no-ocio + - desc: oldest gcc9.3/C++17 py3.7 exr-3.1 no-sse no-ocio # Oldest versions of the dependencies that we can muster, and various # things disabled (no SSE, OCIO, or OpenCV, don't embed plugins). nametag: linux-oldest @@ -164,7 +164,7 @@ jobs: python_ver: 3.7 setenvs: export CMAKE_VERSION=3.15.5 PTEX_VERSION=v2.3.2 - WEBP_VERSION=v1.0.0 + WEBP_VERSION=v1.1.0 depcmds: sudo rm -rf /usr/local/include/OpenEXR - desc: hobbled gcc9.3/C++17 py3.7 exr-3.1 no-sse no-ocio # Use the oldest supported versions of required dependencies, and @@ -183,7 +183,7 @@ jobs: setenvs: export EMBEDPLUGINS=0 CMAKE_VERSION=3.15.5 PTEX_VERSION=v2.3.2 - WEBP_VERSION=v1.0.0 + WEBP_VERSION=v1.1.0 USE_JPEGTURBO=0 USE_OPENCOLORIO=0 USE_OPENCV=0 @@ -319,7 +319,7 @@ jobs: OPENJPEG_VERSION=v2.4.0 PTEX_VERSION=v2.4.2 PUGIXML_VERSION=v1.14 - WEBP_VERSION=v1.3.0 + WEBP_VERSION=v1.4.0 FREETYPE_VERSION=VER-2-13-2 EXTRA_DEP_PACKAGES="libboost-dev" - desc: bleeding edge gcc14 C++20 py3.12 OCIO/libtiff/exr-master avx2 @@ -367,7 +367,7 @@ jobs: OPENJPEG_VERSION=v2.4.0 PTEX_VERSION=v2.4.2 PUGIXML_VERSION=v1.14 - WEBP_VERSION=v1.3.0 + WEBP_VERSION=v1.4.0 EXTRA_DEP_PACKAGES="libboost-dev" - desc: clang14 C++20 avx2 exr3.1 ocio2.1 nametag: linux-clang14 diff --git a/INSTALL.md b/INSTALL.md index 440fca44ba..edc0e2625a 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -64,7 +64,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**. * If you want support for DICOM medical image files: * DCMTK >= 3.6.1 (tested through 3.6.8) * If you want support for WebP images: - * WebP >= 0.6.1 (tested through 1.4) + * **WebP >= 1.1** (tested through 1.4) * If you want support for OpenColorIO color transformations: * OpenColorIO >= 1.1 (tested through 2.3; 2.0+ is recommended) * If you want support for Ptex: diff --git a/src/build-scripts/build_webp.bash b/src/build-scripts/build_webp.bash index e6e3864794..8af015f683 100755 --- a/src/build-scripts/build_webp.bash +++ b/src/build-scripts/build_webp.bash @@ -11,7 +11,7 @@ set -ex # Repo and branch/tag/commit of webp to download if we don't have it yet WEBP_REPO=${WEBP_REPO:=https://github.com/webmproject/libwebp.git} -WEBP_VERSION=${WEBP_VERSION:=v1.1.0} +WEBP_VERSION=${WEBP_VERSION:=v1.4.0} # Where to put webp repo source (default to the ext area) LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext} @@ -47,7 +47,7 @@ if [[ -z $DEP_DOWNLOAD_ONLY ]]; then -DWEBP_BUILD_GIF2WEBPx=OFF \ -DWEBP_BUILD_IMG2WEBP=OFF \ -DWEBP_BUILD_EXTRAS=OFF \ - -DBUILD_SHARED_LIBS=ON \ + -DBUILD_SHARED_LIBS=${WEBP_BUILD_SHARED_LIBS:-ON} \ ${WEBP_CONFIG_OPTS} time cmake --build ${WEBP_BUILD_DIR} --target install fi diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake index 373c57659b..bc24e048c6 100644 --- a/src/cmake/externalpackages.cmake +++ b/src/cmake/externalpackages.cmake @@ -199,9 +199,7 @@ if (NOT Ptex_FOUND OR NOT Ptex_VERSION) checked_find_package (Ptex) endif () -checked_find_package (WebP) -# Note: When WebP 1.1 (released late 2019) is our minimum, we can use their -# exported configs and remove our FindWebP.cmake module. +checked_find_package (WebP VERSION_MIN 1.1) option (USE_R3DSDK "Enable R3DSDK (RED camera) support" OFF) checked_find_package (R3DSDK NO_RECORD_NOTFOUND) # RED camera diff --git a/src/cmake/modules/FindWebP.cmake b/src/cmake/modules/FindWebP.cmake deleted file mode 100644 index 38c53c6e49..0000000000 --- a/src/cmake/modules/FindWebP.cmake +++ /dev/null @@ -1,77 +0,0 @@ -# Module to find Webp -# -# Copyright Contributors to the OpenImageIO project. -# SPDX-License-Identifier: Apache-2.0 -# https://github.com/AcademySoftwareFoundation/OpenImageIO -# -# This module will first look into the directories defined by the variables: -# - Webp_ROOT, WEBP_INCLUDE_PATH, WEBP_LIBRARY_PATH -# -# This module defines the following variables: -# -# WebP_FOUND True if Webp was found. -# WEBP_INCLUDES Where to find Webp headers -# WEBP_LIBRARIES List of libraries to link against when using Webp -# -# This doesn't work, because the webp headers don't seem to include any -# definitions giving the version: -# WEBP_VERSION Version of Webp (e.g., 3.6.2) - -# Try the config for newer WebP versions. -find_package(WebP CONFIG) - -if (NOT TARGET WebP::webp) -# If not found, roll our own. -# Note: When WebP 1.1 (released late 2019) is our minimum, we can use their -# exported configs and remove our FindWebP.cmake module. - -include (FindPackageHandleStandardArgs) - -find_path (WEBP_INCLUDE_DIR webp/encode.h - HINTS - ${WEBP_INCLUDE_PATH} - ENV WEBP_INCLUDE_PATH - DOC "The directory where Webp headers reside") - -find_library (WEBP_LIBRARY webp - HINTS - ${WEBP_LIBRARY_PATH} - ENV WEBP_LIBRARY_PATH) -find_library (WEBPDEMUX_LIBRARY webpdemux - HINTS - ${WEBP_LIBRARY_PATH} - ENV WEBP_LIBRARY_PATH) - -include (FindPackageHandleStandardArgs) -find_package_handle_standard_args (WebP - REQUIRED_VARS WEBP_INCLUDE_DIR - WEBP_LIBRARY WEBPDEMUX_LIBRARY - ) - -if (WebP_FOUND) - set (WEBP_INCLUDES "${WEBP_INCLUDE_DIR}") - set (WEBP_LIBRARIES ${WEBP_LIBRARY} ${WEBPDEMUX_LIBRARY}) - - if (NOT TARGET WebP::webp) - add_library(WebP::webp UNKNOWN IMPORTED) - set_target_properties(WebP::webp PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${WEBP_INCLUDES}) - set_property(TARGET WebP::webp APPEND PROPERTY - IMPORTED_LOCATION ${WEBP_LIBRARY}) - endif () - if (NOT TARGET WebP::webpdemux) - add_library(WebP::webpdemux UNKNOWN IMPORTED) - set_target_properties(WebP::webpdemux PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${WEBP_INCLUDES}) - set_property(TARGET WebP::webpdemux APPEND PROPERTY - IMPORTED_LOCATION ${WEBPDEMUX_LIBRARY}) - endif () -endif () - -mark_as_advanced ( - WEBP_INCLUDE_DIR - WEBP_LIBRARY - WEBPDEMUX_LIBRARY - ) - -endif () From af51dbfdc1614a4c64d06cf510471552f8c101e4 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 22 Jul 2024 10:38:33 -0700 Subject: [PATCH 06/22] deps: Raise libPNG minimum to 1.6.0 (#4355) Raised from 1.5.13 (maybe? we never carefully checked) to 1.6.0 minimum, which was released in 2013 (so absolutely nobody should be bothered by this). Signed-off-by: Larry Gritz --- INSTALL.md | 2 ++ src/cmake/externalpackages.cmake | 2 +- src/png.imageio/png_pvt.h | 17 +++-------------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index edc0e2625a..4c2114db85 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -38,6 +38,8 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**. * **Python >= 3.7** (tested through 3.12) * **pybind11 >= 2.7** (tested through 2.12) * NumPy + * If you want support for PNG files: + * **libPNG >= 1.6.0** (tested though 1.6.43) * If you want support for camera "RAW" formats: * **LibRaw >= 0.20** (tested though 0.21.2) * If you want support for a wide variety of video formats: diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake index bc24e048c6..dbfd17e898 100644 --- a/src/cmake/externalpackages.cmake +++ b/src/cmake/externalpackages.cmake @@ -118,7 +118,7 @@ endif () # Dependencies for optional formats and features. If these are not found, # we will continue building, but the related functionality will be disabled. -checked_find_package (PNG) +checked_find_package (PNG VERSION_MIN 1.6.0) checked_find_package (BZip2) # Used by ffmpeg and freetype if (NOT BZIP2_FOUND) diff --git a/src/png.imageio/png_pvt.h b/src/png.imageio/png_pvt.h index ab5c02866a..55ce5d62cf 100644 --- a/src/png.imageio/png_pvt.h +++ b/src/png.imageio/png_pvt.h @@ -244,12 +244,8 @@ read_info(png_structp& sp, png_infop& ip, int& bit_depth, int& color_type, } if (png_get_valid(sp, ip, PNG_INFO_iCCP)) { - png_charp profile_name = NULL; -#if OIIO_LIBPNG_VERSION > 10500 /* PNG function signatures changed */ - png_bytep profile_data = NULL; -#else - png_charp profile_data = NULL; -#endif + png_charp profile_name = nullptr; + png_bytep profile_data = nullptr; png_uint_32 profile_length = 0; int compression_type; png_get_iCCP(sp, ip, &profile_name, &compression_type, &profile_data, @@ -628,21 +624,14 @@ write_info(png_structp& sp, png_infop& ip, int& color_type, ImageSpec& spec, // Write ICC profile, if we have anything const ParamValue* icc_profile_parameter = spec.find_attribute( ICC_PROFILE_ATTR); - if (icc_profile_parameter != NULL) { + if (icc_profile_parameter != nullptr) { unsigned int length = icc_profile_parameter->type().size(); if (setjmp(png_jmpbuf(sp))) // NOLINT(cert-err52-cpp) return "Could not set PNG iCCP chunk"; -#if OIIO_LIBPNG_VERSION > 10500 /* PNG function signatures changed */ unsigned char* icc_profile = (unsigned char*)icc_profile_parameter->data(); if (icc_profile && length) png_set_iCCP(sp, ip, "Embedded Profile", 0, icc_profile, length); -#else - char* icc_profile = (char*)icc_profile_parameter->data(); - if (icc_profile && length) - png_set_iCCP(sp, ip, (png_charp) "Embedded Profile", 0, icc_profile, - length); -#endif } if (false && !spec.find_attribute("DateTime")) { From 0f50bf95c9822b513bb900c0a9299581889724c7 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 22 Jul 2024 10:39:44 -0700 Subject: [PATCH 07/22] build(deps): Raise giflib minimum to 5.0 (#4349) Even that is quite old -- released in 2012! But it's the first version that guaranteed thread safety for error reporting. So we're finally making that our minimum and taking out the locking we did on our side. Signed-off-by: Larry Gritz --- INSTALL.md | 3 +-- src/cmake/externalpackages.cmake | 6 ++---- src/gif.imageio/gifinput.cpp | 33 +++----------------------------- 3 files changed, 6 insertions(+), 36 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 4c2114db85..40270955af 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -56,8 +56,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**. or for capturing images from a camera: * **OpenCV 4.x** (tested through 4.10) * If you want support for GIF images: - * giflib >= 4.1 (tested through 5.2; 5.0+ is strongly recommended for - stability and thread safety) + * **giflib >= 5.0** (tested through 5.2) * If you want support for HEIF/HEIC or AVIF images: * libheif >= 1.3 (1.7 required for AVIF support, 1.16 required for correct orientation support, tested through 1.17.6) diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake index dbfd17e898..71439639c1 100644 --- a/src/cmake/externalpackages.cmake +++ b/src/cmake/externalpackages.cmake @@ -162,10 +162,8 @@ checked_find_package (TBB 2017 checked_find_package (DCMTK CONFIG VERSION_MIN 3.6.1) checked_find_package (FFmpeg VERSION_MIN 4.0) -checked_find_package (GIF - VERSION_MIN 4 - RECOMMEND_MIN 5.0 - RECOMMEND_MIN_REASON "for stability and thread safety") + +checked_find_package (GIF VERSION_MIN 5.0) # For HEIF/HEIC/AVIF formats checked_find_package (Libheif VERSION_MIN 1.3 diff --git a/src/gif.imageio/gifinput.cpp b/src/gif.imageio/gifinput.cpp index e95f7096d9..45cd33cc9e 100644 --- a/src/gif.imageio/gifinput.cpp +++ b/src/gif.imageio/gifinput.cpp @@ -19,7 +19,7 @@ // for older giflib versions #ifndef GIFLIB_MAJOR -# define GIFLIB_MAJOR 4 +# error "GIFLIB 5.0 minimum required" #endif #ifndef DISPOSAL_UNSPECIFIED @@ -132,12 +132,8 @@ OIIO_EXPORT const char* gif_input_extensions[] = { "gif", NULL }; OIIO_EXPORT const char* gif_imageio_library_version() { -#if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && defined(GIFLIB_RELEASE) return "gif_lib " OIIO_STRINGIZE(GIFLIB_MAJOR) "." OIIO_STRINGIZE( GIFLIB_MINOR) "." OIIO_STRINGIZE(GIFLIB_RELEASE); -#else - return "gif_lib unknown version"; -#endif } OIIO_PLUGIN_EXPORTS_END @@ -408,20 +404,12 @@ GIFInput::seek_subimage(int subimage, int miplevel) if (!m_gif_file) { if (!ioproxy_use_or_open(m_filename)) return false; -#if GIFLIB_MAJOR >= 5 int giflib_error; m_gif_file = DGifOpen(this, readFunc, &giflib_error); if (!m_gif_file) { errorfmt("{}", GifErrorString(giflib_error)); return false; } -#else - m_gif_file = DGifOpen(this, readFunc); - if (!m_gif_file) { - errorfmt("Error opening GIF"); - return false; - } -#endif m_subimage = -1; m_canvas.resize(m_gif_file->SWidth * m_gif_file->SHeight * 4); } @@ -459,27 +447,12 @@ GIFInput::seek_subimage(int subimage, int miplevel) -static spin_mutex gif_error_mutex; - - void GIFInput::report_last_error(void) { - // N.B. Only GIFLIB_MAJOR >= 5 looks properly thread-safe, in that the - // error is guaranteed to be specific to this open file. We use a spin - // mutex to prevent a thread clash for older versions, but it still - // appears to be a global call, so we can't be absolutely sure that the - // error was for *this* file. So if you're using giflib prior to - // version 5, beware. -#if GIFLIB_MAJOR >= 5 + // GIFLIB_MAJOR >= 5 looks properly thread-safe, in that the error is + // guaranteed to be specific to this open file. errorfmt("{}", GifErrorString(m_gif_file->Error)); -#elif GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2 - spin_lock lock(gif_error_mutex); - errorfmt("{}", GifErrorString()); -#else - spin_lock lock(gif_error_mutex); - errorfmt("GIF error {}", GifLastError()); -#endif } From 4ce19d93ed731fb23525fb80afb155e8055364f2 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 22 Jul 2024 22:09:40 -0400 Subject: [PATCH 08/22] CHANGES update Signed-off-by: Larry Gritz --- CHANGES.md | 55 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 54c25b819c..c26f198970 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,11 @@ Release 2.6 (Fall 2024) -- compared to 2.5 * *Robin-map*: minimum raised to 1.2.0 [#4287](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4287) (2.6.2.0) * *Pybind11*: 2.7 minimum [#4297](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4297) (2.6.2.0) * *libtiff*: 4.0 minimum (raised from 3.9) [#4296](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4296) (2.6.2.0) +* *GIF*: 5.0 minimum for giflib (from 4.0) [#4349](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4349) (2.6.3.0) +* *ffmpeg*: 4.0 minimum (from 3.0) [#4352](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4352) (2.6.3.0) +* *OpenCV*: 4.0 minimum (~2018) [#4353](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4353) (2.6.3.0) +* *WebP*: 1.1 minimum (from 0.6.1) [#4354](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4354) (2.6.3.0) +* *PNG*: 1.6.0 minimum for libPNG (from 1.5.13) [#4355](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4355) (2.6.3.0) ### ⛰️ New features and public API changes: @@ -26,7 +31,8 @@ Release 2.6 (Fall 2024) -- compared to 2.5 - `oiiotool --cryptomatte-colors` [#4093](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4093) (2.6.0.2) - New `--buildinfo` command prints build information, including version, compiler, and all library dependencies. [#4124](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4124) (2.6.0.3) [#4150](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4150) (2.6.0.3) - - *oiiotool*: Change command line embedding for oiiotool & maketx output [#4237](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4237) (2.6.2.0) + - Change command line embedding for oiiotool & maketx output [#4237](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4237) (2.6.2.0) + - Expression evaluation improvements: `BOTTOM` refers to the image on the bottom of the stack, `IMG[expression]` is now supported (previously only numeric literals were accepted as the index), check that label/variable names [#4334](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4334) (2.6.3.0) * *Utilities*: - *iv*: Implement Directory Argument Loading for iv [#4010](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4010) (by Chaitanya Sharma) (2.6.0.1) - *iv*: Split off the current image in iv into a separate window [#4017](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4017) (by Anton Dukhovnikov) (2.6.0.1) @@ -40,13 +46,19 @@ Release 2.6 (Fall 2024) -- compared to 2.5 - Only back ImageBuf with ImageCache when passed an IC [#3986](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/3986) (2.6.0.1, 2.5.3.1) - Make ImageBuf::Iterator lazy in its making the image writable [#4033](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4033) (2.6.0.2) + - `IBA::perpixel_op()` is a new way to write IBA-like functions very + simply, only supplying the very inner part of the loop that operates on + one pixel. [#4299](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4299) + (2.6.3.0) * *New image file format support:* - - *JPEG XL*: Initial JPEG XL support for image input/output [#4055](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4055) (by Peter Kovář) + - *JPEG XL*: Initial JPEG XL support for image input/output [#4055](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4055) (by Peter Kovář) Exif and XML metadata support for JPEG XL [#4310](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4310) (by Vlad (Kuzmin) Erium) (2.6.3.0) - *R3D*: Add initial support to read R3D files. Note that this capability will only be enabled if OIIO is built with the R3D SDK installed and available to be found by the build system. [#4216](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4216) (by Peter Kovář) (2.6.2.0) * *TextureSystem*: Overload decode_wrapmode to support ustringhash [#4207](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4207) (by Chris Hellmuth) (2.6.1.0) -* *API Deprecations*: +* *API Deprecations*: (please see [the detailed deprecation list](docs/Deprecations-3.0.md)) - Various other minor deprecations of things that had been marked as - deprecated for a while in fmath.h [#4309](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4309) (2.6.2.0), typedesc.h [#4311](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4311) (2.6.2.0), simd.h [#4308](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4308) (2.6.2.0), assorted [#4234](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4234) (2.6.2.0). + deprecated for a while in fmath.h [#4309](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4309) (2.6.2.0), typedesc.h [#4311](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4311) (2.6.2.0), simd.h [#4308](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4308) (2.6.2.0), assorted [#4234](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4234) (2.6.2.0), texture.h [#4339](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4339) (2.6.3.0), imageio.h [#4312](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4312) (2.6.3.0), benchmark.h, bit.h, color.h, errorhandler.h [#4335](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4335), parmalist.h, parallel.h, strutil.h, sysutil.h, thread.h, tiffutils.h, ustring.h, type_traits.h [#4338](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4338) (2.6.3.0), imagebuf.h [#4341](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4341) (2.6.3.0), imagebufalgo.h [#4344](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4344) (2.6.3.0). + - The deprecated headers array_view.h and missing_math.h have been removed. [#4335](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4335) [#4338](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4338) (2.6.3.0) + - Make span::size() return size_t, not a signed type [#4332](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4332) (2.6.3.0) * *Build system dependency self-builders*: the cmake-based build system has been enhanced to give a report of what dependencies it found, what was missing, what was found but was a version too old for our requirement. @@ -57,6 +69,14 @@ Release 2.6 (Fall 2024) -- compared to 2.5 Additional dependencies will learn to self-build over time. [#4242](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4242) [#4294](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4294) +* The environment variable `OIIO_LIBRARY_PATH` that contains the search paths + for finding image file format plugins has been changed to be called + `OPENIMAGEIO_PLUGIN_PATH`. This is more consistent: all the "public API" + documented environment variables that are meant for users/sites to adjust + are named starting with `OPENIMAGEIO_`, whereas the prefix `OIIO_` is only + used for environment variables that are "unofficial" (undocumented, + temporary, or meant only for developers to use for debugging). [#4330](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4330) + (2.6.3.0) ### 🚀 Performance improvements: - *oiiotool*: `--mosaic` improvements to type conversion avoid unnecessary @@ -64,6 +84,8 @@ Release 2.6 (Fall 2024) -- compared to 2.5 - *simd*: Faster vint4 load/store with unsigned char conversion [#4071](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4071) (by Aras Pranckevičius) (2.6.0.2) - *perf/IBA*: Improve perf of IBA::channels in-place operation [#4088](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4088) (2.6.0.2) - *perf*: Overhaul of ColorConfig internals to solve perf issues [#3995](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/3995) (2.6.0.1) + - *perf/TS*: Reduce TextureSystem memory by slimming down internal LevelInfo size [#4337](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4337) (by Curtis Black) (2.6.3.0) + - *TS*: Have maketx/IBA::make_texture only write full metadata to the first mip level. We presume that other than resolution and encoding-related information, other metadata should not be expected to differ between MIP levels of the same image. This saves file size and memory in the IC/TS. [#4320](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4320) (2.6.3.0) ### 🐛 Fixes and feature enhancements: - *errors*: Print unretrieved global error messages upon application exit. @@ -76,6 +98,7 @@ Release 2.6 (Fall 2024) -- compared to 2.5 - *iv*: Assume iv display gamma 2.2 [#4118](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4118) (2.6.0.3) - *dds*: DDS support more DXGI formats [#4220](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4220) (by alexguirre) (2.6.2.0) - *heic*: Don't auto-transform camera-rotated images [#4142](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4142) (2.6.0.3) [#4184](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4184) (2.6.1.0) + - *heic*: Correctly set imagespec size for heif images (by Gerrard Tai) (2.6.3.0) - *iff*: Refactor iffoutput.cpp for memory safety [#4144](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4144) (2.6.0.3) - *jpeg2000*: Include the headers we need to discern version [#4073](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4073) (2.6.0.2) - *jxl*: JPEG-XL improvements [#4252](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4252) (by Vlad (Kuzmin) Erium) (2.6.2.0) @@ -97,20 +120,22 @@ Release 2.6 (Fall 2024) -- compared to 2.5 - *psd*: Various PSD files fail to load correctly [#4302](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4302) (by Jesse Yurkovich) (2.6.2.0) - *raw*: LibRaw wavelet denoise options [#4028](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4028) (by Vlad (Kuzmin) Erium) (2.6.0.1) - *raw*: Avoid buffer overrun for flip direction cases [#4100](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4100) (2.6.0.3) + - *tiff*: Fix TIFF export with EXIF data and I/O proxy [#4300](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4300) (by jreichel-nvidia) (2.6.3.0) + - *dds/psd*: Always seek to the beginning of the ioproxy during open for DDS and PSD files [#4048](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4048) (by Jesse Yurkovich) (2.6.0.1) - *ImageBuf*: Fix crash when mutable Iterator used with read-IB [#3997](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/3997) (2.6.0.1) - - *diff*: Fix issue when computing perceptual diff [#4061](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4061) (by Aura Munoz) (2.6.0.1) - - *iv*: Avoid crash with OpenGL + multi-channel images [#4087](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4087) (2.6.0.2) + - *ImageBuf*: Improve IB::nsubimages and other related fixes [#4228](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4228) (2.6.2.0) - *IBA*: IBA::to_OpenCV fails for ImageCache-backed images [#4013](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4013) (2.6.0.1) - - *dds/psd*: Always seek to the beginning of the ioproxy during open for DDS and PSD files [#4048](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4048) (by Jesse Yurkovich) (2.6.0.1) + - *diff*: Fix issue when computing perceptual diff [#4061](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4061) (by Aura Munoz) (2.6.0.1) - *fix(ImageInput)*: Only check REST arguments if the file does not exist, avoiding problems for filenames that legitimately contain a `?` character. [#4085](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4085) (by AdamMainsTL) (2.6.0.2) - *fix*: Certain int->float type conversions in TypeDesc/ParamValueList [#4132](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4132) (2.6.0.3) - *color management*: Automatically recognize some additional color space name synonyms: "srgb_texture", "lin_rec709" and "lin_ap1". Also add common permutation "srgb_tx" and "srgb texture" as additional aliases for "srgb". [#4166](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4166) - *security*: Don't use (DY)LD_LIBRARY_PATH as plugin search paths [#4245](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4245) (by Brecht Van Lommel) (2.6.2.0) - *fix*: Fix crash when no default fonts are found [#4249](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4249) (2.6.2.0) - - *TS*: Fix missing initialization in TextureOptBatch [#4226](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4226) (2.6.2.0) + - *TextureSystem*: Fix missing initialization in TextureOptBatch [#4226](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4226) (2.6.2.0) + - *iv*: Avoid crash with OpenGL + multi-channel images [#4087](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4087) (2.6.0.2) - *iv*: If OCIO env is not set or doesn't exist, have iv use built-in config [#4285](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4285) (2.6.2.0) - - *IB*: Improve IB::nsubimages and other related fixes [#4228](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4228) (2.6.2.0) - - *IC*: Simplify tile cache clearing. [#4292](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4292) (by Curtis Black) (2.6.2.0) + - *iv*: Iv should enable the ImageCache [#4326](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4326) (by Jesse Yurkovich) (2.6.3.0) + - *ImageCache*: Simplify tile cache clearing. [#4292](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4292) (by Curtis Black) (2.6.2.0) ### 🔧 Internals and developer goodies - *int*: Prevent infinite loop in bit_range_convert [#3996](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/3996) (by Jesse Yurkovich) (2.6.0.1) @@ -124,6 +149,7 @@ Release 2.6 (Fall 2024) -- compared to 2.5 - *fmath.h*: One more fast_exp fix [#4275](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4275) (2.6.2.0) - *fmt.h*: Fix build break from recent fmt change [#4227](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4227) (2.6.2.0) - *hash.h*: Mismatched pragma push/pop in hash.h [#4182](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4182) (2.6.1.0) + - *imagebf.h*: Add `ImageBuf::wrapmode_name()`, inverse of wrapmode_from_string [#4340](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4340) (2.6.3.0) - *oiioversion.h*: Coalesce redundant STRINGIZE macros -> OIIO_STRINGIZE [#4121](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4121) (2.6.0.3) - *platform.h*: Belatedly change OIIO_CONSTEXPR14 to constexpr [#4153](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4153) (2.6.0.3) - *paramlist.h*: Add ParamValueSpan::get_bool() [#4303](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4303) (2.6.2.0) @@ -139,6 +165,7 @@ Release 2.6 (Fall 2024) -- compared to 2.5 - *span.h*: Span and range checking enhancements [#4125](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4125) (2.6.0.3) - *span.h*: Make span default ctr and assignment be `= default` [#4198](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4198) (2.6.1.0) - *strutil.h*: Add `Strutil::eval_as_bool()` [#4250](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4250) (2.6.2.0) + - *strutil.h*: Add `Strutil::string_is_identifier()` [#4333](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4333) (2.6.3.0) - *sysutil.h*: Deprecate Sysutil::physical_concurrency() [#4034](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4034) (2.6.0.1) - *texture.h*: Overload decode_wrapmode to support ustringhash [#4207](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4207) (by Chris Hellmuth) (2.6.1.0) - *typedesc.h*: Allow TypeDesc to have all the right POD attributes [#4162](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4162) (by Scott Wilson) (2.6.0.3) @@ -152,6 +179,7 @@ Release 2.6 (Fall 2024) -- compared to 2.5 - *fix*: Improve error messages when a font is not found [#4284](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4284) (2.6.2.0) - *refactor*: Oiiotool break out expression eval methods into separate file [#4256](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4256) (2.6.2.0) - *refactor*: Move most of imageio_pvt.h.in to just a regular .h [#4277](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4277) (2.6.2.0) + - *refactor*: Simplify openexr includes [#4304](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4304) (2.6.3.0) ### 🏗 Build/test/CI and platform ports: * CMake build system and scripts: @@ -242,6 +270,9 @@ Release 2.6 (Fall 2024) -- compared to 2.5 - *ci*: Typo in build_libtiff.bash [#4280](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4280) (2.6.2.0) - *ci*: For Windows CI, build only release of vcpkg packages [#4282](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4282) (2.6.2.0) - *ci*: New tets: oldest, hobbled, localbuilds [#4295](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4295) (2.6.2.0) + - *ci*: Fix GHA CI after they upgraded nodejs [#4324](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4324) (2.6.3.0) + - *ci*: Sanitizer new warnings about signed/unsigned offsets in openexr [#4351](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4351) (2.6.3.0) + - *ci*: Deal with CentOS 7 EOL and disappearance of yum mirrors [#4325](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4325) (2.6.3.0) * Platform support: - *win*: Fix building failed from source on Windows [#4235](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4235) (by Vic P) (2.6.2.0) @@ -269,6 +300,7 @@ Release 2.6 (Fall 2024) -- compared to 2.5 - *docs*: Update INSTALL.md for windows [#4279](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4279) (by Mel Massadian) (2.6.2.0) - *doc*: Add missing documentation of ImageBuf locking methods [#4267](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4267) (2.6.2.0) - *doc*: Fixes to formatting and sphinx warnings [#4301](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4301) (2.6.2.0) + - *security*: Document CVE-2024-40630 resolution (2.6.3.0) ### 🏢 Project Administration - *admin*: Repo rename -- fix all URL references [#3998](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/3998) [#3999](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/3999) @@ -278,6 +310,9 @@ Release 2.6 (Fall 2024) -- compared to 2.5 - *admin*: Add a ROADMAP document [#4161](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4161) (2.6.1.0) - *docs*: Better documentation of past CVE fixes in SECURITY.md [#4238](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4238) (2.6.2.0) - *admin*: More CLA explanation and how-to links [#4318](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4318) (2.6.2.0) + - *admin*: Add deprecation updates to the RELEASING checklist [#4345](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4345) (2.6.3.0) + - *admin*: Document my git-cliff workflow for release notes [#4319](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4319) (2.6.3.0) + --- From 08afc2c71ffab8eddf456311ea4f6eb7b9d9c7cf Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 22 Jul 2024 22:27:38 -0400 Subject: [PATCH 09/22] CHANGES Signed-off-by: Larry Gritz --- CHANGES.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index c26f198970..93c34ebdae 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -317,6 +317,36 @@ Release 2.6 (Fall 2024) -- compared to 2.5 --- +Release 2.5.13.1 (July 15, 2024) -- compared to 2.5.13.0 +-------------------------------------------------------- +- fix(heic): Correctly set imagespec size for heif images. + [security advisory](https://github.com/AcademySoftwareFoundation/OpenImageIO/security/advisories/GHSA-jjm9-9m4m-c8p2) CVE-2024-40630 (by Gerrard Tai) + +Release 2.5.13.0 (July 1, 2024) -- compared to 2.5.12.0 +------------------------------------------------------- +- *fix*: Various PSD files fail to load correctly [#4302](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4302) (by Jesse Yurkovich) +- *fix*: Improve error messages when a font is not found [#4284](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4284) +- *platform.h*: In platform.h, define OIIO_DEVICE macro [#4290](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4290) +- *ci*: Typo in build_libtiff.bash [#4280](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4280) +- *docs*: Update INSTALL.md for windows [#4279](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4279) (by Mel Massadian) +- *docs*: Fixes to formatting and sphinx warnings [#4301](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4301) + + +Release 2.5.12.0 (June 1, 2024) -- compared to 2.5.11.0 +------------------------------------------------------- +- *exr*: Add IOProxy support for EXR multipart output [#4263](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4263) [#4264](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4264) (by jreichel-nvidia) +- *pnm*: Improvements to pnm plugin: support for uint16 and 32-float, "pnm:bigendian" and "pnm:pfmflip" controls for output. [#4253](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4253) (by Vlad (Kuzmin) Erium) +- *ImageBuf*: Improve behavior of IB::nsubimages and other related fixes [#4228](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4228) +- *simd.h*: Fix longstanding problem with 16-wide bitcast for 8-wide HW [#4268](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4268) +- *strutil.h*: Add Strutil::eval_as_bool [#4250](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4250) +- *tests*: Add new heif test output [#4262](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4262) +- *tests*: Fix windows quoting for test [#4271](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4271) +- *build*: More warning elimination for clang18 [#4257](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4257) +- *build*: Add appropriate compiler defines and flags for SIMD with MSVC [#4266](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4266) (by Jesse Yurkovich) +- *build*: Gcc-14 support, testing, CI [#4270](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4270) +- *docs*: Fix stray references to the old repo home [#4255](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4255) + + Release 2.5.11.0 (May 1, 2024) -- compared to 2.5.10.0 ------------------------------------------------------- - *dds*: DDS support more DXGI formats [#4220](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4220) (by alexguirre) From ee99e8a91f257a9fa76f91159057f2d21acdb5f6 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Fri, 26 Jul 2024 09:04:56 -0700 Subject: [PATCH 10/22] docs: clarify that IBA::rotate params are pixel coordinates (#4358) As suggested by Moritz Moeller Signed-off-by: Larry Gritz --- src/include/OpenImageIO/imagebufalgo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/OpenImageIO/imagebufalgo.h b/src/include/OpenImageIO/imagebufalgo.h index dd5403f348..fcc78e1aa9 100644 --- a/src/include/OpenImageIO/imagebufalgo.h +++ b/src/include/OpenImageIO/imagebufalgo.h @@ -580,8 +580,8 @@ bool OIIO_API circular_shift (ImageBuf &dst, const ImageBuf &src, /// /// Rotate the `src` image by the `angle` (in radians, with positive angles /// clockwise). When `center_x` and `center_y` are supplied, they denote the -/// center of rotation; in their absence, the rotation will be about the -/// center of the image's display window. +/// center of rotation, in pixel coordinates; in their absence, the rotation +/// will be about the center of the image's display window. /// /// Only the pixels (and channels) of `dst` that are specified by `roi` will /// be copied from the rotated `src`; the default `roi` is to alter all the From a2f044a34c70b361d4927728b67714517cfd59ed Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sun, 28 Jul 2024 22:22:01 -0700 Subject: [PATCH 11/22] build: A few cmake cleanups and minor code rearrangements (#4359) * Get rid of some obsolete cmake code. * Movement (but no change) to some parts of CMakeLists.txt, primarily to make it closer to the corresponding file in OSL to make it easy for me to diff them and port innovations back and forth between them. * Some typo/etc fixes * Remove unused OIIO_UNUSED_OK macro that's been deprecated since 2.0, and OIIO_CONSTEXPR and OIIO_CONSTEXPR14, neither of which have been needed for years. Signed-off-by: Larry Gritz --- CMakeLists.txt | 5 -- docs/Deprecations-3.0.md | 10 +++ src/cmake/compiler.cmake | 6 +- src/cmake/dependency_utils.cmake | 96 ++++++++++++------------- src/include/OpenImageIO/platform.h | 110 +++++++++++++---------------- 5 files changed, 111 insertions(+), 116 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aebb4eafd5..16398af606 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -265,11 +265,6 @@ if (NUKE_FOUND) add_subdirectory (src/nuke/txWriter) endif () -# Last minute site-specific instructions, if they exist -if (OIIO_SITE AND EXISTS "${PROJECT_SOURCE_DIR}/site/${OIIO_SITE}/cmake/sitecustom.cmake") - include ("${PROJECT_SOURCE_DIR}/site/${OIIO_SITE}/cmake/sitecustom.cmake") -endif () - # install pkgconfig file if (NOT MSVC) configure_file(src/build-scripts/OpenImageIO.pc.in "${CMAKE_BINARY_DIR}/OpenImageIO.pc" @ONLY) diff --git a/docs/Deprecations-3.0.md b/docs/Deprecations-3.0.md index bef5af6f8e..3200e3ea28 100644 --- a/docs/Deprecations-3.0.md +++ b/docs/Deprecations-3.0.md @@ -138,6 +138,16 @@ about being deprecated will be removed in the final 3.0 release. been considered deprecated since OIIO 2.3. Please use task functions that do not take a thread ID parameter. +## platform.h + +* Removed macros `OIIO_CONSTEXPR`, `OIIO_CONSTEXPR14`, and + `OIIO_CONSTEXPR_OR_CONST` and deprecated `OIIO_CONSTEXPR17` (use regular C++ + `constexpr` in place of all of these). Removed macro `OIIO_NOEXCEPT` (use + C++ `noexcept`). +* Removed macro `OIIO_UNUSED_OK`, which had been deprecated since 2.0. Marked + `OIIO_MAYBE_UNUSED` as deprecated as well, now that C++17 is the minimum, + there's no reason not to directly use the C++ attribute `[[maybe_unused]]`. + ## strutil.h * Added deprecation warnings to all the old (printf-convention) string diff --git a/src/cmake/compiler.cmake b/src/cmake/compiler.cmake index 844fce09c9..fb2b2c20ab 100644 --- a/src/cmake/compiler.cmake +++ b/src/cmake/compiler.cmake @@ -28,7 +28,7 @@ message (VERBOSE "CMAKE_CXX_COMPILE_FEATURES = ${CMAKE_CXX_COMPILE_FEATURES}") # set (CMAKE_CXX_MINIMUM 17) set (CMAKE_CXX_STANDARD 17 CACHE STRING - "C++ standard to build with (14, 17, 20, etc.) Minimum is ${CMAKE_CXX_MINIMUM}.") + "C++ standard to build with (17, 20, etc.) Minimum is ${CMAKE_CXX_MINIMUM}.") set (DOWNSTREAM_CXX_STANDARD 17 CACHE STRING "C++ minimum standard to impose on downstream clients") set (CMAKE_CXX_STANDARD_REQUIRED ON) @@ -69,13 +69,17 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lan set (CMAKE_CXX_COMPILER_ID "AppleClang") set (CMAKE_COMPILER_IS_APPLECLANG 1) string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" APPLECLANG_VERSION_STRING ${clang_full_version_string}) + set (ANY_CLANG_VERSION_STRING ${APPLECLANG_VERSION_STRING}) message (VERBOSE "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${APPLECLANG_VERSION_STRING}") elseif (CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM") set (CMAKE_COMPILER_IS_INTELCLANG 1) string (REGEX MATCH "[0-9]+(\\.[0-9]+)+" INTELCLANG_VERSION_STRING ${clang_full_version_string}) + set (ANY_CLANG_VERSION_STRING ${INTELCLANG_VERSION_STRING}) message (VERBOSE "The compiler is Intel Clang: ${CMAKE_CXX_COMPILER_ID} version ${INTELCLANG_VERSION_STRING}") else () + set (CMAKE_COMPILER_IS_GENERICCLANG 1) string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string}) + set (ANY_CLANG_VERSION_STRING ${CLANG_VERSION_STRING}) message (VERBOSE "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${CLANG_VERSION_STRING}") endif () elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel") diff --git a/src/cmake/dependency_utils.cmake b/src/cmake/dependency_utils.cmake index a1470a1c70..99504819db 100644 --- a/src/cmake/dependency_utils.cmake +++ b/src/cmake/dependency_utils.cmake @@ -74,57 +74,55 @@ endfunction () # Helper: Print a report about missing dependencies and give insructions on # how to turn on automatic local dependency building. function (print_package_notfound_report) - if (CFP_ALL_BUILD_DEPS_NOTFOUND OR CFP_ALL_BUILD_DEPS_BADVERSION) - message (STATUS) - message (STATUS "${ColorBoldYellow}=========================================================================${ColorReset}") - message (STATUS "${ColorBoldYellow}= Dependency report =${ColorReset}") - message (STATUS "${ColorBoldYellow}=========================================================================${ColorReset}") - message (STATUS) - if (CFP_EXTERNAL_BUILD_DEPS_FOUND) - message (STATUS "${ColorBoldWhite}The following dependencies found externally:${ColorReset}") - list (SORT CFP_EXTERNAL_BUILD_DEPS_FOUND CASE INSENSITIVE) - list (REMOVE_DUPLICATES CFP_EXTERNAL_BUILD_DEPS_FOUND) - foreach (_pkg IN LISTS CFP_EXTERNAL_BUILD_DEPS_FOUND) - message (STATUS " ${_pkg} ${${_pkg}_VERSION}") - endforeach () - endif () - if (CFP_ALL_BUILD_DEPS_BADVERSION) - message (STATUS "${ColorBoldWhite}The following dependencies were found but were too old:${ColorReset}") - list (SORT CFP_ALL_BUILD_DEPS_BADVERSION CASE INSENSITIVE) - list (REMOVE_DUPLICATES CFP_ALL_BUILD_DEPS_BADVERSION) - foreach (_pkg IN LISTS CFP_ALL_BUILD_DEPS_BADVERSION) - if (_pkg IN_LIST CFP_LOCALLY_BUILT_DEPS) - message (STATUS " ${_pkg} ${${_pkg}_NOT_FOUND_EXPLANATION} ${ColorMagenta}(${${_pkg}_VERSION} BUILT LOCALLY)${ColorReset}") - else () - message (STATUS " ${_pkg} ${${_pkg}_NOT_FOUND_EXPLANATION}") - endif () - endforeach () - endif () - if (CFP_ALL_BUILD_DEPS_NOTFOUND) - message (STATUS "${ColorBoldWhite}The following dependencies were not found:${ColorReset}") - list (SORT CFP_ALL_BUILD_DEPS_NOTFOUND CASE INSENSITIVE) - list (REMOVE_DUPLICATES CFP_ALL_BUILD_DEPS_NOTFOUND) - foreach (_pkg IN LISTS CFP_ALL_BUILD_DEPS_NOTFOUND) - if (_pkg IN_LIST CFP_LOCALLY_BUILT_DEPS) - message (STATUS " ${_pkg} ${_${_pkg}_version_range} ${${_pkg}_NOT_FOUND_EXPLANATION} ${ColorMagenta}(${${_pkg}_VERSION} BUILT LOCALLY)${ColorReset}") - else () - message (STATUS " ${_pkg} ${_${_pkg}_version_range} ${${_pkg}_NOT_FOUND_EXPLANATION}") - endif () - endforeach () - endif () - if (CFP_LOCALLY_BUILDABLE_DEPS_NOTFOUND OR CFP_LOCALLY_BUILDABLE_DEPS_BADVERSION) - message (STATUS) - message (STATUS "${ColorBoldWhite}For some of these, we can build them locally:${ColorReset}") - foreach (_pkg IN LISTS CFP_LOCALLY_BUILDABLE_DEPS_NOTFOUND CFP_LOCALLY_BUILDABLE_DEPS_BADVERSION) - message (STATUS " ${_pkg}") - endforeach () - message (STATUS "${ColorBoldWhite}To build them automatically if not found, build again with option:${ColorReset}") - message (STATUS " ${ColorBoldGreen}-D${PROJECT_NAME}_BUILD_MISSING_DEPS=all${ColorReset}") - endif () - message (STATUS) - message (STATUS "${ColorBoldYellow}=========================================================================${ColorReset}") + message (STATUS) + message (STATUS "${ColorBoldYellow}=========================================================================${ColorReset}") + message (STATUS "${ColorBoldYellow}= Dependency report =${ColorReset}") + message (STATUS "${ColorBoldYellow}=========================================================================${ColorReset}") + message (STATUS) + if (CFP_EXTERNAL_BUILD_DEPS_FOUND) + message (STATUS "${ColorBoldWhite}The following dependencies found externally:${ColorReset}") + list (SORT CFP_EXTERNAL_BUILD_DEPS_FOUND CASE INSENSITIVE) + list (REMOVE_DUPLICATES CFP_EXTERNAL_BUILD_DEPS_FOUND) + foreach (_pkg IN LISTS CFP_EXTERNAL_BUILD_DEPS_FOUND) + message (STATUS " ${_pkg} ${${_pkg}_VERSION}") + endforeach () + endif () + if (CFP_ALL_BUILD_DEPS_BADVERSION) + message (STATUS "${ColorBoldWhite}The following dependencies were found but were too old:${ColorReset}") + list (SORT CFP_ALL_BUILD_DEPS_BADVERSION CASE INSENSITIVE) + list (REMOVE_DUPLICATES CFP_ALL_BUILD_DEPS_BADVERSION) + foreach (_pkg IN LISTS CFP_ALL_BUILD_DEPS_BADVERSION) + if (_pkg IN_LIST CFP_LOCALLY_BUILT_DEPS) + message (STATUS " ${_pkg} ${${_pkg}_NOT_FOUND_EXPLANATION} ${ColorMagenta}(${${_pkg}_VERSION} BUILT LOCALLY)${ColorReset}") + else () + message (STATUS " ${_pkg} ${${_pkg}_NOT_FOUND_EXPLANATION}") + endif () + endforeach () + endif () + if (CFP_ALL_BUILD_DEPS_NOTFOUND) + message (STATUS "${ColorBoldWhite}The following dependencies were not found:${ColorReset}") + list (SORT CFP_ALL_BUILD_DEPS_NOTFOUND CASE INSENSITIVE) + list (REMOVE_DUPLICATES CFP_ALL_BUILD_DEPS_NOTFOUND) + foreach (_pkg IN LISTS CFP_ALL_BUILD_DEPS_NOTFOUND) + if (_pkg IN_LIST CFP_LOCALLY_BUILT_DEPS) + message (STATUS " ${_pkg} ${_${_pkg}_version_range} ${${_pkg}_NOT_FOUND_EXPLANATION} ${ColorMagenta}(${${_pkg}_VERSION} BUILT LOCALLY)${ColorReset}") + else () + message (STATUS " ${_pkg} ${_${_pkg}_version_range} ${${_pkg}_NOT_FOUND_EXPLANATION}") + endif () + endforeach () + endif () + if (CFP_LOCALLY_BUILDABLE_DEPS_NOTFOUND OR CFP_LOCALLY_BUILDABLE_DEPS_BADVERSION) message (STATUS) + message (STATUS "${ColorBoldWhite}For some of these, we can build them locally:${ColorReset}") + foreach (_pkg IN LISTS CFP_LOCALLY_BUILDABLE_DEPS_NOTFOUND CFP_LOCALLY_BUILDABLE_DEPS_BADVERSION) + message (STATUS " ${_pkg}") + endforeach () + message (STATUS "${ColorBoldWhite}To build them automatically if not found, build again with option:${ColorReset}") + message (STATUS " ${ColorBoldGreen}-D${PROJECT_NAME}_BUILD_MISSING_DEPS=all${ColorReset}") endif () + message (STATUS) + message (STATUS "${ColorBoldYellow}=========================================================================${ColorReset}") + message (STATUS) endfunction () diff --git a/src/include/OpenImageIO/platform.h b/src/include/OpenImageIO/platform.h index 7fb09b43b5..1371096a64 100644 --- a/src/include/OpenImageIO/platform.h +++ b/src/include/OpenImageIO/platform.h @@ -52,64 +52,6 @@ #include #include -// Detect which C++ standard we're using, and handy macros. -// See https://en.cppreference.com/w/cpp/compiler_support -// -// OIIO_CPLUSPLUS_VERSION : which C++ standard is compiling (14, 17, ...) -// OIIO_CONSTEXPR14 : -// OIIO_CONSTEXPR17 : -// OIIO_CONSTEXPR20 : constexpr for C++ >= the designated version, otherwise -// nothing (this is useful for things that can only be -// constexpr for particular versions or greater). -// OIIO_INLINE_CONSTEXPR : inline constexpr variables, added in C++17. For -// older C++, static constexpr. -// -// Note: oiioversion.h defines OIIO_BUILD_CPP (set to 17, 20, etc.) -// reflecting what OIIO itself was *built* with. In contrast, -// OIIO_CPLUSPLUS_VERSION defined below will be set to the right number for -// the C++ standard being compiled RIGHT NOW. These two things may be the -// same when compiling OIIO, but they may not be the same if another -// package is compiling against OIIO and using these headers (OIIO may be -// C++14 but the client package may be newer, or vice versa -- use these two -// symbols to differentiate these cases, when important). -#if (__cplusplus >= 202001L) -# define OIIO_CPLUSPLUS_VERSION 20 -# define OIIO_CONSTEXPR17 constexpr -# define OIIO_CONSTEXPR20 constexpr -# define OIIO_INLINE_CONSTEXPR inline constexpr -#elif (__cplusplus >= 201703L) || (defined(_MSC_VER) && _MSC_VER >= 1914) -# define OIIO_CPLUSPLUS_VERSION 17 -# define OIIO_CONSTEXPR17 constexpr -# define OIIO_CONSTEXPR20 /* not constexpr before C++20 */ -# define OIIO_INLINE_CONSTEXPR inline constexpr -#else -# error "This version of OIIO is meant to work only with C++17 and above" -#endif - -// DEPRECATED(2.3): use C++14 constexpr -#define OIIO_CONSTEXPR14 constexpr - -// DEPRECATED(1.8): use C++11 constexpr -#define OIIO_CONSTEXPR constexpr -#define OIIO_CONSTEXPR_OR_CONST constexpr - -// DEPRECATED(1.8): use C++11 noexcept -#define OIIO_NOEXCEPT noexcept - - -// In C++20 (and some compilers before that), __has_cpp_attribute can -// test for understand of [[attr]] tests. -#ifndef __has_cpp_attribute -# define __has_cpp_attribute(x) 0 -#endif - -// On gcc & clang, __has_attribute can test for __attribute__((attr)) -#ifndef __has_attribute -# define __has_attribute(x) 0 -#endif - - - // Detect which compiler and version we're using // Notes: @@ -227,6 +169,55 @@ #endif +// Detect which C++ standard we're using, and handy macros. +// See https://en.cppreference.com/w/cpp/compiler_support +// +// OIIO_CPLUSPLUS_VERSION : which C++ standard is compiling (14, 17, ...) +// OIIO_CONSTEXPR14 : +// OIIO_CONSTEXPR17 : +// OIIO_CONSTEXPR20 : constexpr for C++ >= the designated version, otherwise +// nothing (this is useful for things that can only be +// constexpr for particular versions or greater). +// OIIO_INLINE_CONSTEXPR : inline constexpr variables, added in C++17. For +// older C++, static constexpr. +// +// Note: oiioversion.h defines OIIO_BUILD_CPP (set to 17, 20, etc.) +// reflecting what OIIO itself was *built* with. In contrast, +// OIIO_CPLUSPLUS_VERSION defined below will be set to the right number for +// the C++ standard being compiled RIGHT NOW. These two things may be the +// same when compiling OIIO, but they may not be the same if another +// package is compiling against OIIO and using these headers (OIIO may be +// C++17 but the client package may be newer, or vice versa -- use these two +// symbols to differentiate these cases, when important). +#if (__cplusplus >= 202001L) +# define OIIO_CPLUSPLUS_VERSION 20 +# define OIIO_CONSTEXPR20 constexpr +# define OIIO_INLINE_CONSTEXPR inline constexpr +#elif (__cplusplus >= 201703L) || (defined(_MSC_VER) && _MSC_VER >= 1914) +# define OIIO_CPLUSPLUS_VERSION 17 +# define OIIO_CONSTEXPR20 /* not constexpr before C++20 */ +# define OIIO_INLINE_CONSTEXPR inline constexpr +#else +# error "This version of OIIO is meant to work only with C++17 and above" +#endif + +// DEPRECATED(3.0): use C++17 constexpr +#define OIIO_CONSTEXPR17 constexpr + + +// In C++20 (and some compilers before that), __has_cpp_attribute can +// test for understand of [[attr]] tests. +#ifndef __has_cpp_attribute +# define __has_cpp_attribute(x) 0 +#endif + +// On gcc & clang, __has_attribute can test for __attribute__((attr)) +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + + + // Pragma control // // OIIO_PRAGMA(x) make a pragma for *unquoted* x @@ -426,9 +417,6 @@ // [[maybe_unused]] attribute. #define OIIO_MAYBE_UNUSED [[maybe_unused]] -// DEPRECATED(1.9) name: -#define OIIO_UNUSED_OK OIIO_MAYBE_UNUSED - // OIIO_RESTRICT is a parameter attribute that indicates a promise that the // parameter definitely will not alias any other parameters in such a way // that creates a data dependency. Use with caution! From 8a09888f1957cd7598beb8900f1adfcbf845ed01 Mon Sep 17 00:00:00 2001 From: Anton Dukhovnikov Date: Fri, 2 Aug 2024 10:31:31 +1200 Subject: [PATCH 12/22] fix(IB): copy/paste error in the ImageBuf iterator copy constructor (#4365) Fixes a simple copy/paste error in a copy constructor where the y coordinate gets initialised twice instead of y and z. Signed-off-by: Anton Dukhovnikov --- src/libOpenImageIO/imagebuf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libOpenImageIO/imagebuf.cpp b/src/libOpenImageIO/imagebuf.cpp index a31fd320c2..6781d7ef2a 100644 --- a/src/libOpenImageIO/imagebuf.cpp +++ b/src/libOpenImageIO/imagebuf.cpp @@ -3129,7 +3129,7 @@ ImageBuf::IteratorBase::operator=(const IteratorBase& i) m_rng_zend = i.m_rng_zend; m_x = i.m_x; m_y = i.m_y; - m_y = i.m_y; + m_z = i.m_z; return *this; } From e947e79548ce4abdc6447f1be65fed40bf83c3d7 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Wed, 7 Aug 2024 11:52:01 -0700 Subject: [PATCH 13/22] feat(oiiotool): additional stack commands and --for improvement (#4348) Additional stack manipulation commands: * `--popbottom` discards the bottom-of-stack image * `--stackreverse` reverses the order of the whole stack * `--stackclear` fully empties the stack * `--stackextract ` moves the indexed item from the stack (index 0 means the top) to the top. Make `--for` work correctly in both directions: * Correct behavior if `--for` has a negative step value. * If the end value is less than the begin value and no step is supplied, assume -1 (analogous to how we usually assueme step=1 under ordinary circumstances). * Error if step is 0 (presume it will make an infinite loop). Signed-off-by: Larry Gritz --- src/doc/oiiotool.rst | 70 ++++++++++---- src/oiiotool/oiiotool.cpp | 122 ++++++++++++++++++++++--- src/oiiotool/oiiotool.h | 11 +++ testsuite/oiiotool-control/ref/out.txt | 49 ++++++++++ testsuite/oiiotool-control/run.py | 62 ++++++++++--- 5 files changed, 268 insertions(+), 46 deletions(-) diff --git a/src/doc/oiiotool.rst b/src/doc/oiiotool.rst index ed14ff5a82..47d39ae177 100644 --- a/src/doc/oiiotool.rst +++ b/src/doc/oiiotool.rst @@ -273,11 +273,12 @@ The usual programming constructs are supported: * Iteration : `--for` *variable* *range* *commands...* `--endfor` The range is a sequence of one to three comma-separated numbers: *begin*, - *end*, and *step*; *begin* and *end* (step is assumed to be 1); or just - *end* (begin assumed to be 0, step assumed to be 1). As in Python, the range - has an "exclusive end" -- when the *variable* is equal to *end*, the loop - will terminate, without actually running the commands for the *end* value - itself. + *end*, and *step*; *begin* and *end* (step is assumed to be 1 if *begin* + `<`` *end*, or -1 if *begin* `>` *end); or just *end* (begin assumed to be + 0, step assumed to be 1 or -1, depending on the relationship between *begin* + and *end*). As in Python, the range has an "exclusive end" -- when the + *variable* is equal to *end*, the loop will terminate, without actually + running the commands for the *end* value itself. Section :ref:`sec-oiiotool-control-flow-commands` contains more detailed descriptions of these commands and some examples to more clearly illustrate @@ -1023,11 +1024,12 @@ output each one to a different file, with names `sub0001.tif`, for each iteration. The range may be one, two, or three numbers separated by commas, indicating - - *end* : Iterate from 0 to *end*, incrementing by 1 each time. - - *begin* ``,`` *end* : Iterate from *begin* to *end*, incrementing - by 1 each time. + - *end* : Iterate from 0 to *end*, incrementing by 1 each iteration (or + decrementing, if *end* `<` 0). + - *begin* ``,`` *end* : Iterate from *begin* to *end*, incrementing by + 1 each iteration (or decrementing by 1, if *end* `<` *begin*). - *begin* ``,`` *end* ``,`` *step* : Iterate from *begin* to *end*, - incrementing by *step* each time. + adding *step* to the value after each iteration. Note that the *end* value is "exclusive," that is, the loop will terminate once the value is equal to end, and the loop body will @@ -1054,6 +1056,13 @@ output each one to a different file, with names `sub0001.tif`, 7 9 + $ oiiotool --for i 5,0,-1 --echo "i = {i}" --endfor + 5 + 4 + 3 + 2 + 1 + .. option:: --while commands... --endwhile If the *condition* is true, execute *commands*, and keep doing that @@ -2230,10 +2239,16 @@ current top image. :program:`oiiotool` commands that adjust the image stack ======================================================== -.. option:: --pop +.. option:: --label - Pop the image stack, discarding the current image and thereby making the - next image on the stack into the new current image. + Gives a name to (and saves) the current image at the top of the stack. + Thereafter, the label name may be used to refer to that saved image, in + the usual manner that an ordinary input image would be specified by + filename. + + The name of the label must be in the form of an "identifier" (a sequence + of alphanumeric characters and underscores, starting with a letter or + underscore). .. option:: --dup @@ -2245,16 +2260,31 @@ current top image. Swap the current image and the next one on the stack. -.. option:: --label +.. option:: --pop - Gives a name to (and saves) the current image at the top of the stack. - Thereafter, the label name may be used to refer to that saved image, in - the usual manner that an ordinary input image would be specified by - filename. + Pop the image stack, discarding the current image and thereby making the + next image on the stack into the new current image. - The name of the label must be in the form of an "identifier" (a sequence - of alphanumeric characters and underscores, starting with a letter or - underscore). +.. option:: --popbottom + + Remove and discard the bottom image from the image stack. + (Added in OIIO 3.0.) + +.. option:: --stackreverse + + Reverse the order of the entire stack, i.e. making the top be the new + bottom and the old bottom be the new top. (Added in OIIO 3.0.) + +.. option:: --stackextract + + Move the indexed item (0 for the top of the stack, 1 for the next item + down, etc.) to the top of the stack, preserving the relative order of all + other items. (Added in OIIO 3.0.) + +.. option:: --stackclear + + Remove all items from the stack, leaving it empty and with no "current" + image. (Added in OIIO 3.0.) :program:`oiiotool` commands that make entirely new images diff --git a/src/oiiotool/oiiotool.cpp b/src/oiiotool/oiiotool.cpp index a7e07b35cc..e517d6bd20 100644 --- a/src/oiiotool/oiiotool.cpp +++ b/src/oiiotool/oiiotool.cpp @@ -1234,12 +1234,30 @@ control_for(Oiiotool& ot, cspan argv) std::string variable = ot.express(argv[1]); string_view range = ot.express(argv[2]); + float val = 0, limit = 0, step = 1; + bool valid = true; auto rangevals = Strutil::extract_from_list_string(range); - if (rangevals.size() == 1) - rangevals.insert(rangevals.begin(), 0.0f); // supply missing start - if (rangevals.size() == 2) - rangevals.push_back(1.0f); // supply missing step - if (rangevals.size() != 3) { + if (rangevals.size() == 1) { + val = 0.0f; + limit = rangevals[0]; + step = limit >= 0.0f ? 1.0f : -1.0f; + } else if (rangevals.size() == 2) { + val = rangevals[0]; + limit = rangevals[1]; + step = limit >= val ? 1.0f : -1.0f; + } else if (rangevals.size() == 3) { + val = rangevals[0]; + limit = rangevals[1]; + step = rangevals[2]; + } else { + valid = false; + } + // step can't be zero or be opposite direction of val -> limit + valid &= (step != 0.0f); + if ((val < limit && step < 0.0f) || (val > limit && step > 0.0f)) + valid = false; + + if (!valid) { ot.errorfmt(argv[0], "Invalid range \"{}\"", range); return; } @@ -1249,24 +1267,22 @@ control_for(Oiiotool& ot, cspan argv) // There are two cases here: either we are hitting this --for // for the first time (need to initialize and set up the control // record), or we are re-iterating on a loop we already set up. - float val; if (ot.control_stack.empty() || ot.control_stack.top().start_arg != ot.ap.current_arg()) { // First time through the loop. Note that we recognize our first // time by the fact that the top of the control stack doesn't have // a start_arg that is this --for command. - val = rangevals[0]; ot.push_control("for", ot.ap.current_arg(), true); // Strutil::print("First for!\n"); } else { // We've started this loop already, this is at least our 2nd time // through. Just increment the variable and update the condition // for another pass through the loop. - val = ot.uservars.get_float(variable) + rangevals[2]; + val = ot.uservars.get_float(variable) + step; // Strutil::print("Repeat for!\n"); } ot.uservars.attribute(variable, val); - bool cond = val < rangevals[1]; + bool cond = step >= 0.0f ? val < limit : val > limit; ot.control_stack.top().condition = cond; ot.ap.running(ot.running()); // Strutil::print("for {} {} : {}={} cond={} (now running={})\n", variable, @@ -3439,6 +3455,16 @@ action_pop(Oiiotool& ot, cspan argv) +// --popbottom +static void +action_popbottom(Oiiotool& ot, cspan argv) +{ + OIIO_DASSERT(argv.size() == 1); + ot.popbottom(); +} + + + // --dup static void action_dup(Oiiotool& ot, cspan argv) @@ -3467,6 +3493,64 @@ action_swap(Oiiotool& ot, cspan argv) +// --stackreverse +static void +action_stackreverse(Oiiotool& ot, cspan argv) +{ + OIIO_DASSERT(argv.size() == 1); + string_view command = ot.express(argv[0]); + if (!ot.curimg) { + ot.error(command, "requires at least one loaded images"); + return; + } + if (ot.image_stack.empty()) + return; // only curimg -- reversing does nothing + ot.image_stack.push_back(ot.curimg); + std::reverse(ot.image_stack.begin(), ot.image_stack.end()); + ot.curimg = ot.image_stack.back(); + ot.image_stack.pop_back(); +} + + + +// --stackextract +static void +action_stackextract(Oiiotool& ot, cspan argv) +{ + OIIO_DASSERT(argv.size() == 2); + string_view command = ot.express(argv[0]); + int index = Strutil::stoi(ot.express(argv[1])); + if (index < 0 || index >= ot.image_stack_depth()) { + ot.errorfmt(command, "index {} out of range for stack depth {}", index, + ot.image_stack_depth()); + return; + } + if (ot.image_stack.empty()) + return; // only curimg -- extract does nothing + ot.image_stack.push_back(ot.curimg); + // Transform the index to the index of the stack data structure + index = int(ot.image_stack.size()) - 1 - index; + // Copy that item for safe keeping + ImageRecRef newtop = ot.image_stack[index]; + // Remove it from the stack + ot.image_stack.erase(ot.image_stack.begin() + size_t(index)); + // Now put it back on the top + ot.curimg = newtop; +} + + + +// --stackclear +static void +action_stackclear(Oiiotool& ot, cspan argv) +{ + OIIO_DASSERT(argv.size() == 1); + ot.image_stack.clear(); + ot.curimg = ImageRecRef(); +} + + + // --create static void action_create(Oiiotool& ot, cspan argv) @@ -6135,7 +6219,7 @@ Oiiotool::getargs(int argc, char* argv[]) ap.arg("-n", &ot.dryrun) .help("No saved output (dry run)"); ap.arg("--no-error-exit", ot.noerrexit) - .help("Do not exit upon error, try to process additional comands (danger!)"); + .help("Do not exit upon error, try to process additional commands (danger!)"); ap.arg("-a", &ot.allsubimages) .help("Do operations on all subimages/miplevels"); ap.arg("--debug", &ot.debug) @@ -6708,6 +6792,9 @@ Oiiotool::getargs(int argc, char* argv[]) .OTACTION(action_flatten); ap.separator("Image stack manipulation:"); + ap.arg("--label %s") + .help("Label the top image") + .OTACTION(action_label); ap.arg("--dup") .help("Duplicate the current image (push a copy onto the stack)") .OTACTION(action_dup); @@ -6717,9 +6804,18 @@ Oiiotool::getargs(int argc, char* argv[]) ap.arg("--pop") .help("Throw away the current image") .OTACTION(action_pop); - ap.arg("--label %s") - .help("Label the top image") - .OTACTION(action_label); + ap.arg("--popbottom") + .help("Throw away the image on the bottom of the stack") + .OTACTION(action_popbottom); + ap.arg("--stackreverse") + .help("Throw away the image on the bottom of the stack") + .OTACTION(action_stackreverse); + ap.arg("--stackextract %d:INDEX") + .help("Move an indexed stack item to the top of the stack") + .OTACTION(action_stackextract); + ap.arg("--stackclear") + .help("Remove all images from the stack, leaving it empty") + .OTACTION(action_stackclear); ap.separator("Color management:"); ap.arg("--colorconfiginfo") diff --git a/src/oiiotool/oiiotool.h b/src/oiiotool/oiiotool.h index a21a223d16..66e87255eb 100644 --- a/src/oiiotool/oiiotool.h +++ b/src/oiiotool/oiiotool.h @@ -259,6 +259,17 @@ class Oiiotool { return r; } + void popbottom() + { + if (image_stack.size()) { + // There are images on the full stack -- get rid of the bottom + image_stack.erase(image_stack.begin()); + } else { + // Nothing on the stack, so get rid of the current image + curimg = ImageRecRef(); + } + } + ImageRecRef top() { return curimg; } // How many images are on the stack? diff --git a/testsuite/oiiotool-control/ref/out.txt b/testsuite/oiiotool-control/ref/out.txt index 152a08b14f..ba8028348d 100644 --- a/testsuite/oiiotool-control/ref/out.txt +++ b/testsuite/oiiotool-control/ref/out.txt @@ -1,3 +1,38 @@ +Stack holds [0] = d.tif, [1] = c.tif, [2] = b.tif +TOP = d.tif, BOTTOM = a.tif +Stack bottom to top: + a.tif + b.tif + c.tif + d.tif +after --stackreverse: + d.tif + c.tif + b.tif + a.tif +after --stackreverse: + a.tif + b.tif + c.tif + d.tif +after --pop: + a.tif + b.tif + c.tif +after --popbottom: + b.tif + c.tif +after --stackclear: +Re-add a, b, c, d: + a.tif + b.tif + c.tif + d.tif +--stackextract 2: + a.tif + c.tif + d.tif + b.tif 42+2 = 44 42-2 = 40 42*2 = 84 @@ -114,6 +149,20 @@ Testing for i 5,10,2 (expect output 5,7,9): i = 7 i = 9 +Testing for i 10,5,-1 (expect output 10..6): + i = 10 + i = 9 + i = 8 + i = 7 + i = 6 + +Testing for i 10,5 (expect output 10..6): + i = 10 + i = 9 + i = 8 + i = 7 + i = 6 + Testing endfor without for: oiiotool ERROR: -endfor : endfor without matching for Full command line was: diff --git a/testsuite/oiiotool-control/run.py b/testsuite/oiiotool-control/run.py index 4ca8031b69..79eee9038d 100755 --- a/testsuite/oiiotool-control/run.py +++ b/testsuite/oiiotool-control/run.py @@ -14,13 +14,46 @@ redirect += " 2>&1" failureok = True +# Make some temp files +command += oiiotool ('-pattern:type=uint8 constant:color=1,0,0 2x2 3 -o a.tif ' + + '-pattern:type=uint8 constant:color=0,1,0 2x2 3 -o b.tif ' + + '-pattern:type=uint8 constant:color=0,0,1 2x2 3 -o c.tif ' + + '-pattern:type=uint8 constant:color=1,1,1 2x2 3 -o d.tif ') + +# Test TOP, BOTTOM, IMG[] +# TOP should be c.tif, BOTTOM should be a.tif +command += oiiotool ("a.tif b.tif c.tif d.tif " + + "--echo \"Stack holds [0] = {IMG[0].filename}, [1] = {IMG[1].filename}, [2] = {IMG[2].filename}\" " + + "--echo \"TOP = {TOP.filename}, BOTTOM = {BOTTOM.filename}\" " + ) +# Test --pop, --popbottom, --stackreverse, --stackclear, --stackextract +command += oiiotool ( + "a.tif b.tif c.tif d.tif " + + "--echo \"Stack bottom to top:\" " + + "--for i 0,{NIMAGES} --echo \" {IMG[NIMAGES-1-i].filename}\" --endfor " + + "--echo \"after --stackreverse:\" --stackreverse " + + "--for i 0,{NIMAGES} --echo \" {IMG[NIMAGES-1-i].filename}\" --endfor " + + "--echo \"after --stackreverse:\" --stackreverse " + + "--for i 0,{NIMAGES} --echo \" {IMG[NIMAGES-1-i].filename}\" --endfor " + + "--echo \"after --pop:\" --pop " + + "--for i 0,{NIMAGES} --echo \" {IMG[NIMAGES-1-i].filename}\" --endfor " + + "--echo \"after --popbottom:\" --popbottom " + + "--for i 0,{NIMAGES} --echo \" {IMG[NIMAGES-1-i].filename}\" --endfor " + + "--echo \"after --stackclear:\" --stackclear " + + "--for i 0,{NIMAGES} --echo \" {IMG[NIMAGES-1-i].filename}\" --endfor " + + "--echo \"Re-add a, b, c, d:\" " + + "a.tif b.tif c.tif d.tif " + + "--for i 0,{NIMAGES} --echo \" {IMG[NIMAGES-1-i].filename}\" --endfor " + + "--echo \"--stackextract 2:\" --stackextract 2 " + + "--for i 0,{NIMAGES} --echo \" {IMG[NIMAGES-1-i].filename}\" --endfor " + ) + # test expression substitution command += oiiotool ('-echo "42+2 = {42+2}" ' + '-echo "42-2 = {42-2}" ' + '-echo "42*2 = {42*2}" ' + - '-echo "42/2 = {42/2}"') - -command += oiiotool ('-echo "42<41 = {42<41}" ' + + '-echo "42/2 = {42/2}" ' + + '-echo "42<41 = {42<41}" ' + '-echo "42<42 = {42<42}" ' + '-echo "42<43 = {42<43}" ' + '-echo "42<=41 = {42<=41}" ' + @@ -40,9 +73,8 @@ '-echo "42!=43 = {42!=43}" ' + '-echo "42<=>41 = {42<=>41}" ' + '-echo "42<=>42 = {42<=>42}" ' + - '-echo "42<=>43 = {42<=>43}" ') - -command += oiiotool ('-echo "(1==2)&&(2==2) = {(1==2)&&(2==2)}" ' + + '-echo "42<=>43 = {42<=>43}" ' + + '-echo "(1==2)&&(2==2) = {(1==2)&&(2==2)}" ' + '-echo "(1==1)&&(2==2) = {(1==1)&&(2==2)}" ' + '-echo "(1==2)&&(1==2) = {(1==2)&&(1==2)}" ' + '-echo "(1==2)||(2==2) = {(1==2)||(2==2)}" ' + @@ -51,12 +83,11 @@ '-echo "not(1==1) = {not(1==1)}" ' + '-echo "not(1==2) = {not(1==2)}" ' + '-echo "!(1==1) = {!(1==1)}" ' + - '-echo "!(1==2) = {!(1==2)}"') - -command += oiiotool ('-echo "eq(foo,foo) = {eq(\'foo\',\'foo\')}" ' + + '-echo "!(1==2) = {!(1==2)}" ' + + '-echo "eq(foo,foo) = {eq(\'foo\',\'foo\')}" ' + '-echo "eq(foo,bar) = {eq(\'foo\',\'bar\')}" ' + '-echo "neq(foo,foo) = {neq(\'foo\',\'foo\')}" ' + - '-echo "neq(foo,bar) = {neq(\'foo\',\'bar\')}"') + '-echo "neq(foo,bar) = {neq(\'foo\',\'bar\')}" ') command += oiiotool ('-echo "16+5={16+5}" -echo "16-5={16-5}" -echo "16*5={16*5}"') command += oiiotool ('-echo "16/5={16/5}" -echo "16//5={16//5}" -echo "16%5={16%5}"') @@ -107,12 +138,17 @@ command += oiiotool ('-echo "Testing endwhile without while:" -endwhile -echo " "') # Test --for --endfor -command += oiiotool ('-echo "Testing for i 5 (expect output 0..4):" --for i 5 --echo " i = {i}" --endfor -echo " "') -command += oiiotool ('-echo "Testing for i 5,10 (expect output 5..9):" --for i 5,10 --echo " i = {i}" --endfor -echo " "') -command += oiiotool ('-echo "Testing for i 5,10,2 (expect output 5,7,9):" --for i 5,10,2 --echo " i = {i}" --endfor -echo " "') +command += oiiotool ( + '-echo "Testing for i 5 (expect output 0..4):" --for i 5 --echo " i = {i}" --endfor -echo " " ' + + '-echo "Testing for i 5,10 (expect output 5..9):" --for i 5,10 --echo " i = {i}" --endfor -echo " " ' + + '-echo "Testing for i 5,10,2 (expect output 5,7,9):" --for i 5,10,2 --echo " i = {i}" --endfor -echo " " ' + + '-echo "Testing for i 10,5,-1 (expect output 10..6):" --for i 10,5,-1 --echo " i = {i}" --endfor -echo " " ' + + '-echo "Testing for i 10,5 (expect output 10..6):" --for i 10,5 --echo " i = {i}" --endfor -echo " " ' + ) command += oiiotool ('-echo "Testing endfor without for:" -endfor -echo " "') command += oiiotool ('-echo "Testing for i 5,10,2,8 (bad range):" --for i 5,10,2,8 --echo " i = {i}" --endfor -echo " "') + # test sequences command += oiiotool ("../common/tahoe-tiny.tif -o copyA.1-10#.jpg") command += oiiotool ("--debug copyA.#.jpg -o copyB.#.jpg") From f578096ef7a874e286f8f502321a4b72d4d60d63 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Wed, 7 Aug 2024 11:52:46 -0700 Subject: [PATCH 14/22] int: Rename env OIIOTOOL_METADATA_HISTORY -> OPENIMAGEIO_METADATA_HISTORY (#4368) It's not just in oiiotool. This seems clearer and adheres to the env variable naming convention we chose. Reminder: This controls whether command line history gets written to output image metadata by default by oiiotool and maketx. We historically did it, but recently stopped because of security concerns. Signed-off-by: Larry Gritz --- src/doc/imageioapi.rst | 6 +++--- src/doc/oiiotool.rst | 4 ++-- src/maketx/maketx.cpp | 10 +++++----- src/oiiotool/oiiotool.cpp | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/doc/imageioapi.rst b/src/doc/imageioapi.rst index 4f0623675d..0adcba25ca 100644 --- a/src/doc/imageioapi.rst +++ b/src/doc/imageioapi.rst @@ -370,10 +370,10 @@ inside the source code. take precedence. If neither is set, the default will be 0, which means to use as many threads as there are physical cores on the machine. -``OIIOTOOL_METADATA_HISTORY`` +``OPENIMAGEIO_METADATA_HISTORY`` - If set to a nonzero integer value, `oiiotool` will by default write the - command line into the ImageHistory and Software metadata fields of any + If set to a nonzero integer value, `oiiotool` and `maketx` will by default + write the command line into the ImageHistory and Software metadata fields of any images it outputs. The default if this is not set is to only write the name and version of the software and an indecipherable hash of the command line, but not the full human-readable command line. (This was added in diff --git a/src/doc/oiiotool.rst b/src/doc/oiiotool.rst index 47d39ae177..cfda570a1e 100644 --- a/src/doc/oiiotool.rst +++ b/src/doc/oiiotool.rst @@ -1991,7 +1991,7 @@ current top image. image to potentially reveal any proprietary information that might have been present in the command line arguments. - If the `OIIOTOOL_METADATA_HISTORY` environment variable is set to a + If the `OPENIMAGEIO_METADATA_HISTORY` environment variable is set to a nonzero integer value, the `--history` option will be enabled by default, but can be disabled on the command line with `--no-history`. @@ -2002,7 +2002,7 @@ current top image. Prior to OpenImageIO 2.5.11, the full information was always written, but could be overridden with `--nosoftwareattrib`. Beginning with 2.5.11, the default changed to only write the software name and version (unless the - `OIIOTOOL_METADATA_HISTORY` environment variable is set), and require the + `OPENIMAGEIO_METADATA_HISTORY` environment variable is set), and require the new `--history` option to cause the command line arguments to be written as metadata. diff --git a/src/maketx/maketx.cpp b/src/maketx/maketx.cpp index d85b49fc8c..3feeaf4d64 100644 --- a/src/maketx/maketx.cpp +++ b/src/maketx/maketx.cpp @@ -26,8 +26,8 @@ using namespace OIIO; -#ifndef OIIOTOOL_METADATA_HISTORY_DEFAULT -# define OIIOTOOL_METADATA_HISTORY_DEFAULT 0 +#ifndef OPENIMAGEIO_METADATA_HISTORY_DEFAULT +# define OPENIMAGEIO_METADATA_HISTORY_DEFAULT 0 #endif @@ -185,12 +185,12 @@ getargs(int argc, char* argv[], ImageSpec& configspec) bool cdf = false; float cdfsigma = 1.0f / 6; int cdfbits = 8; -#if OIIOTOOL_METADATA_HISTORY_DEFAULT +#if OPENIMAGEIO_METADATA_HISTORY_DEFAULT bool metadata_history = Strutil::from_string( - getenv("OIIOTOOL_METADATA_HISTORY", "1")); + getenv("OPENIMAGEIO_METADATA_HISTORY", "1")); #else bool metadata_history = Strutil::from_string( - getenv("OIIOTOOL_METADATA_HISTORY")); + getenv("OPENIMAGEIO_METADATA_HISTORY")); #endif std::string incolorspace; std::string outcolorspace; diff --git a/src/oiiotool/oiiotool.cpp b/src/oiiotool/oiiotool.cpp index e517d6bd20..b266ea641d 100644 --- a/src/oiiotool/oiiotool.cpp +++ b/src/oiiotool/oiiotool.cpp @@ -53,8 +53,8 @@ using pvt::print_info_options; # define OIIO_UNIT_TESTS 1 #endif -#ifndef OIIOTOOL_METADATA_HISTORY_DEFAULT -# define OIIOTOOL_METADATA_HISTORY_DEFAULT 0 +#ifndef OPENIMAGEIO_METADATA_HISTORY_DEFAULT +# define OPENIMAGEIO_METADATA_HISTORY_DEFAULT 0 #endif @@ -174,12 +174,12 @@ Oiiotool::clear_options() output_dither = false; output_force_tiles = false; metadata_nosoftwareattrib = false; -#if OIIOTOOL_METADATA_HISTORY_DEFAULT +#if OPENIMAGEIO_METADATA_HISTORY_DEFAULT metadata_history = Strutil::from_string( - getenv("OIIOTOOL_METADATA_HISTORY", "1")); + getenv("OPENIMAGEIO_METADATA_HISTORY", "1")); #else metadata_history = Strutil::from_string( - getenv("OIIOTOOL_METADATA_HISTORY")); + getenv("OPENIMAGEIO_METADATA_HISTORY")); #endif diff_warnthresh = 1.0e-6f; diff_warnpercent = 0; From e031dc35fe26e48361556a7d55498b2837be281a Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Wed, 7 Aug 2024 11:53:32 -0700 Subject: [PATCH 15/22] feat(jpeg): output hint "jpeg:iptc" (#4346) JPEG output configuration hint "jpeg:iptc" (default: 1), if set to 0, will suppress IPTC block output to the file. In the process, we changed the return type of utility function encode_iptc_iim() to return true if anything was successfully encoded, false otherwise. Signed-off-by: Larry Gritz --- src/doc/builtinplugins.rst | 4 ++++ src/include/OpenImageIO/tiffutils.h | 5 +++-- src/jpeg.imageio/jpegoutput.cpp | 4 ++-- src/libOpenImageIO/iptc.cpp | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/doc/builtinplugins.rst b/src/doc/builtinplugins.rst index 1c795a739c..7fa37e62a7 100644 --- a/src/doc/builtinplugins.rst +++ b/src/doc/builtinplugins.rst @@ -1077,6 +1077,10 @@ control aspects of the writing itself: - ptr - Pointer to a ``Filesystem::IOProxy`` that will handle the I/O, for example by writing to a memory buffer. + * - ``jpeg:iptc`` + - int (1) + - If zero, will suppress writing the IPTC metadata block to the + JPEG file. * - ``jpeg:progressive`` - int - If nonzero, will write a progressive JPEG file. diff --git a/src/include/OpenImageIO/tiffutils.h b/src/include/OpenImageIO/tiffutils.h index 9d69559a31..0803634271 100644 --- a/src/include/OpenImageIO/tiffutils.h +++ b/src/include/OpenImageIO/tiffutils.h @@ -189,8 +189,9 @@ OIIO_API bool decode_iptc_iim (const void *iptc, int length, ImageSpec &spec); /// for multiple format plugins to support embedding IPTC metadata /// without having to duplicate functionality within each plugin. Note /// that IIM is actually considered obsolete and is replaced by an XML -/// scheme called XMP. -OIIO_API void encode_iptc_iim (const ImageSpec &spec, std::vector &iptc); +/// scheme called XMP. Return true if it was successful and any items +/// were encoded. +OIIO_API bool encode_iptc_iim (const ImageSpec &spec, std::vector &iptc); /// Add metadata to spec based on XMP data in an XML block. Return true /// if all is ok, false if the xml was somehow malformed. This is a diff --git a/src/jpeg.imageio/jpegoutput.cpp b/src/jpeg.imageio/jpegoutput.cpp index da1c7506d1..b845a86bea 100644 --- a/src/jpeg.imageio/jpegoutput.cpp +++ b/src/jpeg.imageio/jpegoutput.cpp @@ -249,8 +249,8 @@ JpgOutput::open(const std::string& name, const ImageSpec& newspec, // Write IPTC IIM metadata tags, if we have anything std::vector iptc; - encode_iptc_iim(m_spec, iptc); - if (iptc.size()) { + if (m_spec.get_int_attribute("jpeg:iptc", 1) + && encode_iptc_iim(m_spec, iptc)) { static char photoshop[] = "Photoshop 3.0"; std::vector head(photoshop, photoshop + strlen(photoshop) + 1); static char _8BIM[] = "8BIM"; diff --git a/src/libOpenImageIO/iptc.cpp b/src/libOpenImageIO/iptc.cpp index b65c5c2949..0f79bbe0fe 100644 --- a/src/libOpenImageIO/iptc.cpp +++ b/src/libOpenImageIO/iptc.cpp @@ -179,7 +179,7 @@ encode_iptc_iim_one_tag(int tag, string_view data, std::vector& iptc) -void +bool encode_iptc_iim(const ImageSpec& spec, std::vector& iptc) { iptc.clear(); @@ -206,6 +206,7 @@ encode_iptc_iim(const ImageSpec& spec, std::vector& iptc) encode_iptc_iim_one_tag(iimtag[i].tag, p->get_string(0), iptc); } } + return iptc.size() != 0; } From fb9d818b1791be8d694f2e2a0d352b6c5c4462a6 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Wed, 7 Aug 2024 11:53:52 -0700 Subject: [PATCH 16/22] fix(png): round dpi resolution to nearest 0.1 (#4347) Signed-off-by: Larry Gritz --- src/png.imageio/png_pvt.h | 17 ++++++++++++----- testsuite/png/ref/out-libpng15.txt | 12 ++++++------ testsuite/png/ref/out.txt | 12 ++++++------ 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/png.imageio/png_pvt.h b/src/png.imageio/png_pvt.h index 55ce5d62cf..9119e19f65 100644 --- a/src/png.imageio/png_pvt.h +++ b/src/png.imageio/png_pvt.h @@ -303,15 +303,22 @@ read_info(png_structp& sp, png_infop& ip, int& bit_depth, int& color_type, int unit; png_uint_32 resx, resy; if (png_get_pHYs(sp, ip, &resx, &resy, &unit)) { - float scale = 1; if (unit == PNG_RESOLUTION_METER) { // Convert to inches, to match most other formats - scale = 2.54 / 100.0; + float scale = 2.54f / 100.0f; + float rx = resx * scale; + float ry = resy * scale; + // Round to nearest 0.1 + rx = std::round(10.0f * rx) / 10.0f; + ry = std::round(10.0f * ry) / 10.0f; spec.attribute("ResolutionUnit", "inch"); - } else + spec.attribute("XResolution", rx); + spec.attribute("YResolution", ry); + } else { spec.attribute("ResolutionUnit", "none"); - spec.attribute("XResolution", (float)resx * scale); - spec.attribute("YResolution", (float)resy * scale); + spec.attribute("XResolution", (float)resx); + spec.attribute("YResolution", (float)resy); + } } float aspect = (float)png_get_pixel_aspect_ratio(sp, ip); diff --git a/testsuite/png/ref/out-libpng15.txt b/testsuite/png/ref/out-libpng15.txt index e8855cd272..f19f586729 100644 --- a/testsuite/png/ref/out-libpng15.txt +++ b/testsuite/png/ref/out-libpng15.txt @@ -5,8 +5,8 @@ Reading ../oiio-images/oiio-logo-no-alpha.png Comment: "Created with GIMP" DateTime: "2009:03:26 17:19:47" ResolutionUnit: "inch" - XResolution: 72.009 - YResolution: 72.009 + XResolution: 72 + YResolution: 72 oiio:ColorSpace: "sRGB" Comparing "../oiio-images/oiio-logo-no-alpha.png" and "oiio-logo-no-alpha.png" PASS @@ -17,8 +17,8 @@ Reading ../oiio-images/oiio-logo-with-alpha.png Comment: "Created with GIMP" DateTime: "2009:03:26 18:44:26" ResolutionUnit: "inch" - XResolution: 72.009 - YResolution: 72.009 + XResolution: 72 + YResolution: 72 oiio:ColorSpace: "sRGB" Comparing "../oiio-images/oiio-logo-with-alpha.png" and "oiio-logo-with-alpha.png" PASS @@ -31,8 +31,8 @@ exif.png : 64 x 64, 3 channel, uint8 png channel list: R, G, B, A ResolutionUnit: "inch" Software: "OpenImageIO 2.4.1.1dev : oiiotool -no-autopremult SLEEP_MM.png -cut 1x1+227+1211 -o kaka.png" - XResolution: 299.999 - YResolution: 299.999 + XResolution: 300 + YResolution: 300 Exif:ImageHistory: "oiiotool -no-autopremult SLEEP_MM.png -cut 1x1+227+1211 -o kaka.png" oiio:ColorSpace: "Gamma2.2" oiio:Gamma: 2.2 diff --git a/testsuite/png/ref/out.txt b/testsuite/png/ref/out.txt index 3a8ed2f5ab..730a5cdd0a 100644 --- a/testsuite/png/ref/out.txt +++ b/testsuite/png/ref/out.txt @@ -5,8 +5,8 @@ Reading ../oiio-images/oiio-logo-no-alpha.png Comment: "Created with GIMP" DateTime: "2009:03:26 17:19:47" ResolutionUnit: "inch" - XResolution: 72.009 - YResolution: 72.009 + XResolution: 72 + YResolution: 72 oiio:ColorSpace: "sRGB" Comparing "../oiio-images/oiio-logo-no-alpha.png" and "oiio-logo-no-alpha.png" PASS @@ -17,8 +17,8 @@ Reading ../oiio-images/oiio-logo-with-alpha.png Comment: "Created with GIMP" DateTime: "2009:03:26 18:44:26" ResolutionUnit: "inch" - XResolution: 72.009 - YResolution: 72.009 + XResolution: 72 + YResolution: 72 oiio:ColorSpace: "sRGB" Comparing "../oiio-images/oiio-logo-with-alpha.png" and "oiio-logo-with-alpha.png" PASS @@ -35,8 +35,8 @@ exif.png : 64 x 64, 3 channel, uint8 png channel list: R, G, B, A ResolutionUnit: "inch" Software: "OpenImageIO 2.4.1.1dev : oiiotool -no-autopremult SLEEP_MM.png -cut 1x1+227+1211 -o kaka.png" - XResolution: 299.999 - YResolution: 299.999 + XResolution: 300 + YResolution: 300 Exif:ImageHistory: "oiiotool -no-autopremult SLEEP_MM.png -cut 1x1+227+1211 -o kaka.png" oiio:ColorSpace: "Gamma2.2" oiio:Gamma: 2.2 From 3cb2acf3741778f78f2df121afeb579fac0aa729 Mon Sep 17 00:00:00 2001 From: Anton Dukhovnikov Date: Thu, 8 Aug 2024 06:58:28 +1200 Subject: [PATCH 17/22] raw: expose additional white balancing hints (#4360) The main purpose of this change is to make it possible to use OIIO for reading raw files in rawtoaces instead of calling LibRaw directly. There are the changes: - add the missing hints needed to implement all combinations of white-balancing methods and matrix methods provided by rawtoaces. - add the DNG-specific attributes The change adds this functionality: - new "raw:user_black" hint to override the default black point - new "raw:use_auto_wb" hint to force LibRaw to white balance by averaging over the whole image. - new "raw:grey_box" hint to make LibRaw to white balance by averaging over the given rectange. - new "raw:dng:XXX" attributes added to the output ImageBuf if the input image is a DNG file. The attributes consist of 2 sets of [calibration illuminant; calibration matrix, XYZ to camera RGB matrix]. Note, the current DNG standard supports up to 3 calibration illuminants, but both LibRaw and rawtoaces only use 2 currently. I have manually tested all permutations of white-balancing modes and matrix methods which are currently supported by raw to aces. The images match up to a rounding error. The current unit tests pass, but they only seem to use the default conversion settings. We may want to extend those. I'm not clear on how to do that, there are multiple reference images for different versions of LibRaw, not sure if I will have to re-generate all of them. I intend to make more changes to the raw plugin soon, may come back to updating tests during/after that. There are currently no tests using DNG files, so the new DNG-specific attributes are not covered. The code relying on those in rawtoaces works fine. I have also updated the documentation to add the new hints, however, I haven't been able to build the documentation. Signed-off-by: Anton Dukhovnikov --- src/doc/builtinplugins.rst | 25 +++++++++++- src/raw.imageio/rawinput.cpp | 74 ++++++++++++++++++++++++++++-------- 2 files changed, 82 insertions(+), 17 deletions(-) diff --git a/src/doc/builtinplugins.rst b/src/doc/builtinplugins.rst index 7fa37e62a7..5743de5890 100644 --- a/src/doc/builtinplugins.rst +++ b/src/doc/builtinplugins.rst @@ -2066,7 +2066,23 @@ options are supported: - If nonzero, will use libraw's exposure correction. (Default: 0) * - ``raw:use_camera_wb`` - int - - If 1, use libraw's camera white balance adjustment. (Default: 1) + - If 1, use libraw's camera white balance adjustment. Takes precedence + over ``raw:use_auto_wb``, ``raw:greybox``, ``raw:user_mul``. + (Default: 1) + * - ``raw:use_auto_wb`` + - int + - If 1, white balance automatically by averaging over the entire image. + Only applies if ``raw:use_camera_wb`` is not equal to 0. Takes + precedence over ``raw:greybox``, ``raw:user_mul``. + (Default: 0) + * - ``raw:greybox`` + - int[4] + - White balance by averaging over the given box. The four values are the + X and Y coordinate of the top-left corner, the width and the height. + Only applies if the size is non-zero, and ``raw:use_camera_wb`` is not + equal to 0, ``raw:use_auto_wb`` is not equal to 0. Takes + precedence over ``raw:user_mul``. + (Default: 0, 0, 0, 0; meaning no correction.) * - ``raw:use_camera_matrix`` - int - Whether to use the embedded color profile, if it's present: 0 = @@ -2074,6 +2090,10 @@ options are supported: * - ``raw:adjust_maximum_thr`` - float - If nonzero, auto-adjusting maximum value. (Default:0.0) + * - ``raw:user_black`` + - int + - If not negative, sets the camera minimum value that will be normalized to + appear 0. (Default: -1) * - ``raw:user_sat`` - int - If nonzero, sets the camera maximum value that will be normalized to @@ -2090,7 +2110,8 @@ options are supported: * - ``raw:user_mul`` - float[4] - Sets user white balance coefficients. Only applies if ``raw:use_camera_wb`` - is not equal to 0. + is not equal to 0, ``raw:use_auto_wb`` is not equal to 0, and the + ``raw:greybox`` box is zero size. * - ``raw:ColorSpace`` - string - Which color primaries to use for the returned pixel values: ``raw``, diff --git a/src/raw.imageio/rawinput.cpp b/src/raw.imageio/rawinput.cpp index 2b4f715d7a..dd75df798f 100644 --- a/src/raw.imageio/rawinput.cpp +++ b/src/raw.imageio/rawinput.cpp @@ -459,6 +459,9 @@ RawInput::open_raw(bool unpack, const std::string& name, // Turn off maximum threshold value (unless set to non-zero) m_processor->imgdata.params.adjust_maximum_thr = config.get_float_attribute("raw:adjust_maximum_thr", 0.0f); + // Set camera minimum value if "raw:user_black" is not negative + m_processor->imgdata.params.user_black + = config.get_int_attribute("raw:user_black", -1); // Set camera maximum value if "raw:user_sat" is not 0 m_processor->imgdata.params.user_sat = config.get_int_attribute("raw:user_sat", 0); @@ -502,21 +505,34 @@ RawInput::open_raw(bool unpack, const std::string& name, params.user_mul[2] = norm[2]; params.user_mul[3] = norm[3]; } else { - // Set user white balance coefficients. - // Only has effect if "raw:use_camera_wb" is equal to 0, - // i.e. we are not using the camera white balance - auto p = config.find_attribute("raw:user_mul"); - if (p && p->type() == TypeDesc(TypeDesc::FLOAT, 4)) { - m_processor->imgdata.params.user_mul[0] = p->get(0); - m_processor->imgdata.params.user_mul[1] = p->get(1); - m_processor->imgdata.params.user_mul[2] = p->get(2); - m_processor->imgdata.params.user_mul[3] = p->get(3); - } - if (p && p->type() == TypeDesc(TypeDesc::DOUBLE, 4)) { - m_processor->imgdata.params.user_mul[0] = p->get(0); - m_processor->imgdata.params.user_mul[1] = p->get(1); - m_processor->imgdata.params.user_mul[2] = p->get(2); - m_processor->imgdata.params.user_mul[3] = p->get(3); + if (config.get_int_attribute("raw:use_auto_wb", 0) == 1) { + m_processor->imgdata.params.use_auto_wb = 1; + } else { + auto p = config.find_attribute("raw:greybox"); + if (p && p->type() == TypeDesc(TypeDesc::INT, 4)) { + // p->get() didn't work for me here + m_processor->imgdata.params.greybox[0] = p->get_int_indexed(0); + m_processor->imgdata.params.greybox[1] = p->get_int_indexed(1); + m_processor->imgdata.params.greybox[2] = p->get_int_indexed(2); + m_processor->imgdata.params.greybox[3] = p->get_int_indexed(3); + } else { + // Set user white balance coefficients. + // Only has effect if "raw:use_camera_wb" is equal to 0, + // i.e. we are not using the camera white balance + auto p = config.find_attribute("raw:user_mul"); + if (p && p->type() == TypeDesc(TypeDesc::FLOAT, 4)) { + m_processor->imgdata.params.user_mul[0] = p->get(0); + m_processor->imgdata.params.user_mul[1] = p->get(1); + m_processor->imgdata.params.user_mul[2] = p->get(2); + m_processor->imgdata.params.user_mul[3] = p->get(3); + } + if (p && p->type() == TypeDesc(TypeDesc::DOUBLE, 4)) { + m_processor->imgdata.params.user_mul[0] = p->get(0); + m_processor->imgdata.params.user_mul[1] = p->get(1); + m_processor->imgdata.params.user_mul[2] = p->get(2); + m_processor->imgdata.params.user_mul[3] = p->get(3); + } + } } } @@ -1319,6 +1335,34 @@ RawInput::get_colorinfo() cspan(&(m_processor->imgdata.color.cam_xyz[0][0]), &(m_processor->imgdata.color.cam_xyz[3][3])), false, 0.f); + + if (m_processor->imgdata.idata.dng_version) { + add("raw", "dng:version", m_processor->imgdata.idata.dng_version); + + auto const& c = m_processor->imgdata.rawdata.color; + +#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0) + add("raw", "dng:baseline_exposure", c.dng_levels.baseline_exposure); +#else + add("raw", "dng:baseline_exposure", c.baseline_exposure); +#endif + + for (int i = 0; i < 2; i++) { + std::string index = std::to_string(i + 1); + add("raw", "dng:calibration_illuminant" + index, + c.dng_color[i].illuminant); + + add("raw", "dng:color_matrix" + index, + cspan(&(c.dng_color[i].colormatrix[0][0]), + &(c.dng_color[i].colormatrix[3][3])), + false, 0.f); + + add("raw", "dng:camera_calibration" + index, + cspan(&(c.dng_color[i].calibration[0][0]), + &(c.dng_color[i].calibration[3][4])), + false, 0.f); + } + } } From d2490363022d55a811f98ec86a11ae17a35d3b0a Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Wed, 7 Aug 2024 11:58:59 -0700 Subject: [PATCH 18/22] api: move OIIO::pvt::error and log_time into the exposed OIIO namespace (#4362) This is needed for the related OpenCV-related PR Signed-off-by: Larry Gritz --- src/iff.imageio/noproxy-iff_pvt.h | 4 ++-- src/include/OpenImageIO/imageio.h | 16 ++++++++++++++++ src/include/OpenImageIO/strutil.h | 4 +++- src/include/imageio_pvt.h | 18 ------------------ src/libOpenImageIO/imagebufalgo_opencv.cpp | 14 ++++++-------- src/libOpenImageIO/imageinput.cpp | 2 +- src/libOpenImageIO/imageio.cpp | 2 +- src/libOpenImageIO/imageioplugin.cpp | 20 ++++++++++---------- src/libOpenImageIO/maketexture.cpp | 4 ++-- 9 files changed, 41 insertions(+), 43 deletions(-) diff --git a/src/iff.imageio/noproxy-iff_pvt.h b/src/iff.imageio/noproxy-iff_pvt.h index 7e6dc0a4fb..de78e39d47 100644 --- a/src/iff.imageio/noproxy-iff_pvt.h +++ b/src/iff.imageio/noproxy-iff_pvt.h @@ -145,7 +145,7 @@ class IffInput final : public ImageInput { try { close(); } catch (const std::exception& e) { - OIIO::pvt::errorfmt("{}", e.what()); + OIIO::errorfmt("{}", e.what()); } } const char* format_name(void) const override { return "iff"; } @@ -228,7 +228,7 @@ class IffOutput final : public ImageOutput { try { close(); } catch (const std::exception& e) { - OIIO::pvt::errorfmt("{}", e.what()); + OIIO::errorfmt("{}", e.what()); } } const char* format_name(void) const override { return "iff"; } diff --git a/src/include/OpenImageIO/imageio.h b/src/include/OpenImageIO/imageio.h index 071d9805c0..b675c4605e 100644 --- a/src/include/OpenImageIO/imageio.h +++ b/src/include/OpenImageIO/imageio.h @@ -41,6 +41,7 @@ OIIO_NAMESPACE_BEGIN class DeepData; class ImageBuf; +class Timer; /// Type we use for stride lengths between pixels, scanlines, or image @@ -3363,7 +3364,22 @@ void debugfmt (const char* fmt, Args&&... args) Strutil::debug(fmt, std::forward(args)...); } +namespace pvt { +// For internal use - use errorfmt() below for a nicer interface. +OIIO_API void append_error(string_view message); +} + +/// error logging (mostly for OIIO internals) with `std::format` conventions. +template +inline void errorfmt(const char* fmt, Args&&... args) +{ + pvt::append_error(string_view(Strutil::fmt::format(fmt, args...))); +} +/// Internal function to log time recorded by an OIIO::timer(). It will only +/// trigger a read of the time if the "log_times" attribute is set or the +/// OPENIMAGEIO_LOG_TIMES env variable is set. +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 (); diff --git a/src/include/OpenImageIO/strutil.h b/src/include/OpenImageIO/strutil.h index d22a546481..e0c5ec302f 100644 --- a/src/include/OpenImageIO/strutil.h +++ b/src/include/OpenImageIO/strutil.h @@ -152,7 +152,9 @@ using old::format; #endif -// format_to comes from fmt library +// More things we wrap from fmt library +using ::fmt::format_args; +using ::fmt::make_format_args; using ::fmt::format_to; using ::fmt::format_to_n; diff --git a/src/include/imageio_pvt.h b/src/include/imageio_pvt.h index b6b606994c..c9befa7421 100644 --- a/src/include/imageio_pvt.h +++ b/src/include/imageio_pvt.h @@ -60,18 +60,6 @@ font_list(); -// For internal use - use error() below for a nicer interface. -void -append_error(string_view message); - -/// Use errorfmt() privately only. Formatting notation is like std::format. -template -inline void -errorfmt(const char* fmt, const Args&... args) -{ - append_error(Strutil::fmt::format(fmt, args...)); -} - // Make sure all plugins are inventoried. For internal use only. void catalog_all_plugins(std::string searchpath); @@ -123,12 +111,6 @@ parallel_convert_from_float(const float* src, void* dst, size_t nvals, OIIO_API bool check_texture_metadata_sanity(ImageSpec& spec); -/// Internal function to log time recorded by an OIIO::timer(). It will only -/// trigger a read of the time if the "log_times" attribute is set or the -/// OPENIMAGEIO_LOG_TIMES env variable is set. -OIIO_API void -log_time(string_view key, const Timer& timer, int count = 1); - /// Get the timing report from log_time entries. OIIO_API std::string timing_report(); diff --git a/src/libOpenImageIO/imagebufalgo_opencv.cpp b/src/libOpenImageIO/imagebufalgo_opencv.cpp index c95a8fd90f..1d5a37fda8 100644 --- a/src/libOpenImageIO/imagebufalgo_opencv.cpp +++ b/src/libOpenImageIO/imagebufalgo_opencv.cpp @@ -169,16 +169,14 @@ ImageBufAlgo::to_OpenCV(cv::Mat& dst, const ImageBuf& src, ROI roi, } else if (spec.format == TypeDesc(TypeDesc::DOUBLE)) { dstFormat = CV_MAKETYPE(CV_64F, chans); } else { - OIIO::pvt::errorfmt( - "to_OpenCV() doesn't know how to make a cv::Mat of {}", - spec.format); + OIIO::errorfmt("to_OpenCV() doesn't know how to make a cv::Mat of {}", + spec.format); return false; } dst.create(roi.height(), roi.width(), dstFormat); if (dst.empty()) { - OIIO::pvt::errorfmt( - "to_OpenCV() was unable to create cv::Mat of {}x{} {}", roi.width(), - roi.height(), dstSpecFormat); + OIIO::errorfmt("to_OpenCV() was unable to create cv::Mat of {}x{} {}", + roi.width(), roi.height(), dstSpecFormat); return false; } @@ -189,7 +187,7 @@ ImageBufAlgo::to_OpenCV(cv::Mat& dst, const ImageBuf& src, ROI roi, dst.ptr(), pixelsize, linestep, AutoStride); bool converted = ImageBufAlgo::copy(cvib, src); if (!converted) { - OIIO::pvt::errorfmt( + OIIO::errorfmt( "to_OpenCV() was unable to convert source {} to cv::Mat of {}", spec.format, dstSpecFormat); return false; @@ -204,7 +202,7 @@ ImageBufAlgo::to_OpenCV(cv::Mat& dst, const ImageBuf& src, ROI roi, return true; #else - OIIO::pvt::errorfmt( + OIIO::errorfmt( "to_OpenCV() not supported -- no OpenCV support at compile time"); return false; #endif diff --git a/src/libOpenImageIO/imageinput.cpp b/src/libOpenImageIO/imageinput.cpp index 0a03219c6a..a6814575bf 100644 --- a/src/libOpenImageIO/imageinput.cpp +++ b/src/libOpenImageIO/imageinput.cpp @@ -164,7 +164,7 @@ ImageInput::open(const std::string& filename, const ImageSpec* config, // error, delete the ImageInput we allocated, and return NULL. std::string err = in->geterror(); if (err.size()) - OIIO::pvt::errorfmt("{}", err); + OIIO::errorfmt("{}", err); in.reset(); } diff --git a/src/libOpenImageIO/imageio.cpp b/src/libOpenImageIO/imageio.cpp index a0a4e4e874..a78ff59947 100644 --- a/src/libOpenImageIO/imageio.cpp +++ b/src/libOpenImageIO/imageio.cpp @@ -364,7 +364,7 @@ debug(string_view message) void -pvt::log_time(string_view key, const Timer& timer, int count) +log_time(string_view key, const Timer& timer, int count) { timing_log(key, timer, count); } diff --git a/src/libOpenImageIO/imageioplugin.cpp b/src/libOpenImageIO/imageioplugin.cpp index c192035fbe..328a71664b 100644 --- a/src/libOpenImageIO/imageioplugin.cpp +++ b/src/libOpenImageIO/imageioplugin.cpp @@ -526,7 +526,7 @@ ImageOutput::create(string_view filename, Filesystem::IOProxy* ioproxy, { std::unique_ptr out; if (filename.empty()) { // Can't even guess if no filename given - OIIO::pvt::errorfmt("ImageOutput::create() called with no filename"); + OIIO::errorfmt("ImageOutput::create() called with no filename"); return out; } @@ -563,9 +563,9 @@ ImageOutput::create(string_view filename, Filesystem::IOProxy* ioproxy, const char* msg = "ImageOutput::create() could not find any ImageOutput plugins! Perhaps you need to set OIIO_LIBRARY_PATH.\n"; Strutil::print(stderr, "{}", msg); - OIIO::pvt::errorfmt("{}", msg); + OIIO::errorfmt("{}", msg); } else - OIIO::pvt::errorfmt( + OIIO::errorfmt( "OpenImageIO could not find a format writer for \"{}\". " "Is it a file format that OpenImageIO doesn't know about?\n", filename); @@ -582,7 +582,7 @@ ImageOutput::create(string_view filename, Filesystem::IOProxy* ioproxy, } if (out && ioproxy) { if (!out->supports("ioproxy")) { - OIIO::pvt::errorfmt( + OIIO::errorfmt( "ImageOutput::create called with IOProxy, but format {} does not support IOProxy", out->format_name()); out.reset(); @@ -609,7 +609,7 @@ ImageInput::create(string_view filename, bool do_open, const ImageSpec* config, // Only check REST arguments if the file does not exist if (!Filesystem::exists(filename)) { if (!Strutil::get_rest_arguments(filename, filename_stripped, args)) { - OIIO::pvt::errorfmt( + OIIO::errorfmt( "ImageInput::create() called with malformed filename"); return in; } @@ -619,7 +619,7 @@ ImageInput::create(string_view filename, bool do_open, const ImageSpec* config, filename_stripped = filename; if (filename_stripped.empty()) { // Can't even guess if no filename given - OIIO::pvt::errorfmt("ImageInput::create() called with no filename"); + OIIO::errorfmt("ImageInput::create() called with no filename"); return in; } @@ -770,18 +770,18 @@ ImageInput::create(string_view filename, bool do_open, const ImageSpec* config, = "ImageInput::create() could not find any ImageInput plugins!\n" " Perhaps you need to set OIIO_LIBRARY_PATH.\n"; Strutil::print(stderr, "{}", msg); - OIIO::pvt::errorfmt("{}", msg); + OIIO::errorfmt("{}", msg); } else if (!specific_error.empty()) { // Pass along any specific error message we got from our // best guess of the format. - OIIO::pvt::errorfmt("{}", specific_error); + OIIO::errorfmt("{}", specific_error); } else if (Filesystem::exists(filename)) - pvt::errorfmt( + OIIO::errorfmt( "OpenImageIO could not find a format reader for \"{}\". " "Is it a file format that OpenImageIO doesn't know about?\n", filename); else - OIIO::pvt::errorfmt( + OIIO::errorfmt( "Image \"{}\" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.\n", filename); OIIO_DASSERT(!in); diff --git a/src/libOpenImageIO/maketexture.cpp b/src/libOpenImageIO/maketexture.cpp index 6ea6ba3b4e..5bf2da43c6 100644 --- a/src/libOpenImageIO/maketexture.cpp +++ b/src/libOpenImageIO/maketexture.cpp @@ -615,7 +615,7 @@ write_mipmap(ImageBufAlgo::MakeTextureMode mode, std::shared_ptr& img, std::ostream& outstream, double& stat_writetime, double& stat_miptime, size_t& peak_mem) { - using OIIO::pvt::errorfmt; + using OIIO::errorfmt; using OIIO::Strutil::sync::print; // Be sure to use synchronized one bool envlatlmode = (mode == ImageBufAlgo::MakeTxEnvLatl); bool orig_was_overscan = (img->spec().x || img->spec().y || img->spec().z @@ -981,7 +981,7 @@ make_texture_impl(ImageBufAlgo::MakeTextureMode mode, const ImageBuf* input, std::string filename, std::string outputfilename, const ImageSpec& _configspec, std::ostream* outstream_ptr) { - using OIIO::pvt::errorfmt; + using OIIO::errorfmt; using OIIO::Strutil::sync::print; // Be sure to use synchronized one OIIO_ASSERT(mode >= 0 && mode < ImageBufAlgo::_MakeTxLast); double stat_readtime = 0; From 64f829febd352686538beaba10e4ca716a9403a1 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sat, 10 Aug 2024 09:07:25 -0700 Subject: [PATCH 19/22] admin: Relicense code under Apache 2.0 (#3905) Some more updates to the relicensing. At this point, less than 0.15% of the codebase remains under the original BSD-3-clause license. --- LICENSE-BSD.md | 27 --------------------------- README.md | 2 +- RELICENSING.md | 14 +++++++++++--- THIRD-PARTY.md | 8 ++++---- src/iconvert/iconvert.cpp | 2 +- src/include/OpenImageIO/platform.h | 2 +- src/libtexture/imagecache.cpp | 2 +- src/oiiotool/oiiotool.h | 2 +- src/python/py_imagebufalgo.cpp | 2 +- 9 files changed, 21 insertions(+), 40 deletions(-) delete mode 100644 LICENSE-BSD.md diff --git a/LICENSE-BSD.md b/LICENSE-BSD.md deleted file mode 100644 index de10a34492..0000000000 --- a/LICENSE-BSD.md +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2008-present by Contributors to the OpenImageIO project. -All Rights Reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index fdcaa2d03b..220a228cb8 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ For original code, we use the [Apache-2.0 license](LICENSE.md), and for documentation, the [Creative Commons Attribution 4.0 Unported License](http://creativecommons.org/licenses/by/4.0/). In 2023 we asked historical users to [relicense](RELICENSING.md) from the original BSD-3-clause -license to Apache-2.0, and over 99.75% of lines of code have been relicensed +license to Apache-2.0, and over 99.86% of lines of code have been relicensed to Apache-2.0. A small amount of code incorporated into this repository from other projects are covered by compatible [third-party open source licenses](THIRD-PARTY.md). diff --git a/RELICENSING.md b/RELICENSING.md index a8658d729a..c6390ca009 100644 --- a/RELICENSING.md +++ b/RELICENSING.md @@ -2,7 +2,11 @@ New code entering the OpenImageIO repository from July 1 2023 onward is subject to the [Apache 2.0 license](LICENSE.md). Code dating from earlier than July 1 2023 was contributed under the [BSD -3-clause license](LICENSE-BSD-3-Clause.md), unless relicensed below. +3-clause license](https://opensource.org/license/bsd-3-clause), unless +relicensed below. + +Stragglers who haven't relicensed yet, it's never too late, just sign onto the +PR: https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/3905 The following copyright holders agree that all of their contributions originally submitted to this project under the 3-Clause BSD License are hereby @@ -137,9 +141,13 @@ the Developer Certificate of Origin, version 1.1: - Damien Courtois (ix-dcourtois) - Carl Rand (crand) - Gregor Mückl (gmueckl) +- Jep Hill (jephill) +- John Haddon (johnhaddon) +... -**Prior authors, please submit a PR against this file that adds your name -above. If, at the time of your prior contributions, you were employed by a +**Prior authors, please follow the directions for adding your name to +[this PR](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/3905). +If, at the time of your prior contributions, you were employed by a company who would have owned your IP output, then please have someone from that company who is authorized to do so submit a PR to add their company’s name to the list under the statement in this file.** diff --git a/THIRD-PARTY.md b/THIRD-PARTY.md index 17f4a882bd..96e2a1523a 100644 --- a/THIRD-PARTY.md +++ b/THIRD-PARTY.md @@ -9,15 +9,15 @@ In no particular order: ------------------------------------------------------------------------- -BSD 3-Clause License +BSD 3-Clause License (https://opensource.org/license/bsd-3-clause) SPDX-License-Identifier: BSD-3-Clause * OpenImageIO prior to July 1, 2023 Code that was contributed to OpenImageIO prior to July 1 2023, and has not - yet been [relicensed](RELICENSING.md), was contributed under the [BSD - 3-clause license](LICENSE-BSD.md). Currently, this is less than 2% of the - codebase (by lines of code). + yet been [relicensed](RELICENSING.md), was contributed under the BSD + 3-clause license. Currently, less than 0.15% of the codebase (by lines of + code) remains under this license. * Gelato, Copyright (c) 2004 by NVIDIA Corp. diff --git a/src/iconvert/iconvert.cpp b/src/iconvert/iconvert.cpp index d98a2dfd49..66b513c381 100644 --- a/src/iconvert/iconvert.cpp +++ b/src/iconvert/iconvert.cpp @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenImageIO project. -// SPDX-License-Identifier: BSD-3-Clause and Apache-2.0 +// SPDX-License-Identifier: Apache-2.0 // https://github.com/AcademySoftwareFoundation/OpenImageIO diff --git a/src/include/OpenImageIO/platform.h b/src/include/OpenImageIO/platform.h index 1371096a64..f5f1101786 100644 --- a/src/include/OpenImageIO/platform.h +++ b/src/include/OpenImageIO/platform.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenImageIO project. -// SPDX-License-Identifier: BSD-3-Clause and Apache-2.0 +// SPDX-License-Identifier: Apache-2.0 // https://github.com/AcademySoftwareFoundation/OpenImageIO diff --git a/src/libtexture/imagecache.cpp b/src/libtexture/imagecache.cpp index e21ffbed24..de1afac15d 100644 --- a/src/libtexture/imagecache.cpp +++ b/src/libtexture/imagecache.cpp @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenImageIO project. -// SPDX-License-Identifier: BSD-3-Clause and Apache-2.0 +// SPDX-License-Identifier: Apache-2.0 // https://github.com/AcademySoftwareFoundation/OpenImageIO diff --git a/src/oiiotool/oiiotool.h b/src/oiiotool/oiiotool.h index 66e87255eb..48706faedb 100644 --- a/src/oiiotool/oiiotool.h +++ b/src/oiiotool/oiiotool.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenImageIO project. -// SPDX-License-Identifier: BSD-3-Clause and Apache-2.0 +// SPDX-License-Identifier: Apache-2.0 // https://github.com/AcademySoftwareFoundation/OpenImageIO diff --git a/src/python/py_imagebufalgo.cpp b/src/python/py_imagebufalgo.cpp index b5f9eb015b..22db42d338 100644 --- a/src/python/py_imagebufalgo.cpp +++ b/src/python/py_imagebufalgo.cpp @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenImageIO project. -// SPDX-License-Identifier: BSD-3-Clause and Apache-2.0 +// SPDX-License-Identifier: Apache-2.0 // https://github.com/AcademySoftwareFoundation/OpenImageIO #include "py_oiio.h" From af13eb92034fb1635a87233e4de86059067bb7b0 Mon Sep 17 00:00:00 2001 From: Basile Fraboni Date: Sun, 11 Aug 2024 16:27:27 -0700 Subject: [PATCH 20/22] api: add pvt::heapsize() and pvt::footprint() methods and image cache memory tracking (#4322) First PR of two, following @lgritz and I discussions on memory tracking in the OIIO::ImageCache. - Add two template methods and their specializations for types various to help memory tracking: ```c++ // return the total heap allocated memory held by the object and its members template inline size_t heapsize(const T& t); // return the total memory footprint including the size of the structure itself template inline size_t footprint(const T& t); ``` - Specialized for: ParamValue, ParamValueList, ImageSpec, ImageInput, ImageOutput, std::vector, std::shared_ptr, std::unique_ptr, oiio::intrusive_ptr, ImageCacheImpl related objects. - New files: - `include/memory.h` : adds base and few types specialization of heapsize and footprint. - `libtexture/imagecache_memory_pvt.h` : adds specilializations for ImageCacheImpl and related objects. - `libtexture/imagecache_memory_print.h` : adds a helper function that print a breakdown of the ImageCacheImpl total memory usage as well, as well as per image format. Note: this is slow, but gives accurate memory estimation. Related PR from Larry : https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4317 Signed-off-by: Basile Fraboni --- src/include/OpenImageIO/imagecache.h | 2 + src/include/OpenImageIO/imageio.h | 20 ++ src/include/OpenImageIO/memory.h | 117 ++++++++++++ src/include/OpenImageIO/paramlist.h | 9 +- src/include/OpenImageIO/refcnt.h | 22 +++ src/libOpenImageIO/formatspec.cpp | 13 ++ src/libOpenImageIO/imageinput.cpp | 13 ++ src/libOpenImageIO/imageoutput.cpp | 11 ++ src/libOpenImageIO/imagespec_test.cpp | 4 + src/libtexture/imagecache.cpp | 5 + src/libtexture/imagecache_memory_print.h | 234 +++++++++++++++++++++++ src/libtexture/imagecache_memory_pvt.h | 109 +++++++++++ src/libtexture/imagecache_pvt.h | 17 +- src/libutil/paramlist.cpp | 11 ++ src/libutil/paramlist_test.cpp | 46 ++--- 15 files changed, 609 insertions(+), 24 deletions(-) create mode 100644 src/include/OpenImageIO/memory.h create mode 100644 src/libtexture/imagecache_memory_print.h create mode 100644 src/libtexture/imagecache_memory_pvt.h diff --git a/src/include/OpenImageIO/imagecache.h b/src/include/OpenImageIO/imagecache.h index fedc3f3041..2cb7bb89ad 100644 --- a/src/include/OpenImageIO/imagecache.h +++ b/src/include/OpenImageIO/imagecache.h @@ -257,6 +257,8 @@ class OIIO_API ImageCache { /// all files referenced by calls to the ImageCache. (The /// array is of `ustring` or `char*`.) /// + /// - `int64 stat:cache_footprint` : + /// Total bytes used by image cache. /// - `int64 stat:cache_memory_used` : /// Total bytes used by tile cache. /// diff --git a/src/include/OpenImageIO/imageio.h b/src/include/OpenImageIO/imageio.h index b675c4605e..af233d0d0f 100644 --- a/src/include/OpenImageIO/imageio.h +++ b/src/include/OpenImageIO/imageio.h @@ -36,6 +36,7 @@ #include #include #include +#include OIIO_NAMESPACE_BEGIN @@ -1884,6 +1885,9 @@ class OIIO_API ImageInput { std::unique_ptr m_impl; void append_error(string_view message) const; // add to error message + + /// declare a friend heapsize definition + template friend size_t pvt::heapsize(const T&); }; @@ -2788,10 +2792,26 @@ class OIIO_API ImageOutput { std::unique_ptr m_impl; void append_error(string_view message) const; // add to m_errmessage + + /// declare a friend heapsize definition + template friend size_t pvt::heapsize(const T&); }; +/// Memory tracking. Specializes the base memory tracking functions from memory.h. + +// heapsize specialization for `ImageSpec` +template <> OIIO_API size_t pvt::heapsize(const ImageSpec&); + +// heapsize specialization for `ImageInput` +template <> OIIO_API size_t pvt::heapsize(const ImageInput&); + +// heapsize specialization for `ImageOutput` +template <> OIIO_API size_t pvt::heapsize(const ImageOutput&); + + + // Utility functions /// `OIIO::shutdown` prepares OpenImageIO for shutdown. Before exiting an diff --git a/src/include/OpenImageIO/memory.h b/src/include/OpenImageIO/memory.h new file mode 100644 index 0000000000..cae5f34b5e --- /dev/null +++ b/src/include/OpenImageIO/memory.h @@ -0,0 +1,117 @@ +// Copyright Contributors to the OpenImageIO project. +// SPDX-License-Identifier: Apache-2.0 +// https://github.com/AcademySoftwareFoundation/OpenImageIO + + +///////////////////////////////////////////////////////////////////////// +/// @file memory.h +/// +/// @brief Utilities for memory tracking. +///////////////////////////////////////////////////////////////////////// + + +#pragma once + +#define OPENIMAGEIO_MEMORY_H + +#include +#include +#include + +OIIO_NAMESPACE_BEGIN + +namespace pvt { + +/// Return the total heap memory allocated by `object`. +/// The template specialization can be used to give improved results for non trivial types +/// that perform heap allocation, and to include members allocations recursively. +template +inline size_t +heapsize(const T& t) +{ + return 0; +} + +/// Return the total memory footprint of `object`. If possible, including any heap +/// allocations done by any constituent parts. The default implementation just reduces +/// to sizeof(object), given that heapsize(object) would return 0. +/// The template specialization can be used to give improved results for non trivial types +/// that perform heap allocation. +template +inline size_t +footprint(const T& t) +{ + return sizeof(T) + heapsize(t); +} + +template +inline size_t +footprint(const T* t) +{ + return sizeof(T) + (t ? footprint(*t) : 0); +} + +/// Specializations for common STL types + + +// heapsize specialization for std::string +template<> +inline size_t +heapsize(const std::string& s) +{ + // accounts for small string optimization that does not + // use any heap allocations + const char* const sbegin = (const char*)&s; + const char* const send = sbegin + sizeof(std::string); + const char* const sdata = s.data(); + const bool is_small = sdata >= sbegin && sdata < send; + return is_small ? 0 : s.capacity(); +} + +// heapsize specialization for std::vector +template +inline size_t +heapsize(const std::vector& vec) +{ + size_t size = 0; + for (const T& elem : vec) + size += footprint(elem); + return size; +} + +// heapsize specialization for std::shared_ptr +template +inline size_t +heapsize(const std::shared_ptr& ref) +{ + return ref ? footprint(*ref.get()) : 0; +} + +// footprint specialization for std::shared_ptr +template +inline size_t +footprint(const std::shared_ptr& ref) +{ + return sizeof(std::shared_ptr) + heapsize(ref); +} + +// heapsize specialization for std::unique_ptr +template +inline size_t +heapsize(const std::unique_ptr& ref) +{ + return ref ? footprint(*ref.get()) : 0; +} + +// footprint specialization for std::unique_ptr +template +inline size_t +footprint(const std::unique_ptr& ref) +{ + return sizeof(std::unique_ptr) + heapsize(ref); +} + +} // namespace pvt + + +OIIO_NAMESPACE_END \ No newline at end of file diff --git a/src/include/OpenImageIO/paramlist.h b/src/include/OpenImageIO/paramlist.h index f4840fc8b2..6d278a38df 100644 --- a/src/include/OpenImageIO/paramlist.h +++ b/src/include/OpenImageIO/paramlist.h @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -276,9 +277,15 @@ class OIIO_UTIL_API ParamValue { Copy _copy = Copy(true), FromUstring _from_ustring = FromUstring(false)) noexcept; void clear_value() noexcept; -}; + /// declare a friend heapsize definition + 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). diff --git a/src/include/OpenImageIO/refcnt.h b/src/include/OpenImageIO/refcnt.h index 06dc97213c..68cacd319c 100644 --- a/src/include/OpenImageIO/refcnt.h +++ b/src/include/OpenImageIO/refcnt.h @@ -16,6 +16,7 @@ #include #include +#include OIIO_NAMESPACE_BEGIN @@ -232,4 +233,25 @@ intrusive_ptr_release(T* x) #define OIIO_REFCNT_HAS_RELEASE 1 /* intrusive_ptr::release() */ +/// Memory tracking. Specializes the base memory tracking functions from memory.h. + +// heapsize specialization for `intrusive_ptr` +namespace pvt { +template +inline size_t +heapsize(const intrusive_ptr& ref) +{ + return ref ? footprint(*ref.get()) : 0; +} + +// footprint specialization for `intrusive_ptr` +template +inline size_t +footprint(const intrusive_ptr& ref) +{ + return sizeof(intrusive_ptr) + heapsize(ref); +} +} // namespace pvt + + OIIO_NAMESPACE_END diff --git a/src/libOpenImageIO/formatspec.cpp b/src/libOpenImageIO/formatspec.cpp index 461ab88ee1..11515f6b4e 100644 --- a/src/libOpenImageIO/formatspec.cpp +++ b/src/libOpenImageIO/formatspec.cpp @@ -1251,4 +1251,17 @@ ImageSpec::set_colorspace(string_view colorspace) } + +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/imageinput.cpp b/src/libOpenImageIO/imageinput.cpp index a6814575bf..9d2d658ce7 100644 --- a/src/libOpenImageIO/imageinput.cpp +++ b/src/libOpenImageIO/imageinput.cpp @@ -1337,4 +1337,17 @@ ImageInput::check_open(const ImageSpec& spec, ROI range, uint64_t /*flags*/) return true; // all is ok } + + +template<> +size_t +pvt::heapsize(const ImageInput& input) +{ + //! TODO: change ImageInput API to add a virtual heapsize() function + //! to allow per image input override, and call that function here. + return pvt::heapsize(input.m_spec); +} + + + OIIO_NAMESPACE_END diff --git a/src/libOpenImageIO/imageoutput.cpp b/src/libOpenImageIO/imageoutput.cpp index 2d74ac205b..002429fc93 100644 --- a/src/libOpenImageIO/imageoutput.cpp +++ b/src/libOpenImageIO/imageoutput.cpp @@ -1021,4 +1021,15 @@ ImageOutput::check_open(OpenMode mode, const ImageSpec& userspec, ROI range, +template<> +size_t +pvt::heapsize(const ImageOutput& output) +{ + //! TODO: change ImageOutput API to add a virtual heapsize() function + //! to allow per image output override, and call that function here. + return pvt::heapsize(output.m_spec); +} + + + OIIO_NAMESPACE_END diff --git a/src/libOpenImageIO/imagespec_test.cpp b/src/libOpenImageIO/imagespec_test.cpp index 9450174018..3846faa92f 100644 --- a/src/libOpenImageIO/imagespec_test.cpp +++ b/src/libOpenImageIO/imagespec_test.cpp @@ -313,6 +313,8 @@ test_imagespec_from_xml() std::cout << "test_imagespec_from_xml\n"; ImageSpec spec; spec.from_xml(imagespec_xml_string); + print(" spec heapsize = {}\n", pvt::heapsize(spec)); + print(" spec footprint = {}\n", pvt::footprint(spec)); OIIO_CHECK_EQUAL(spec.nchannels, 4); OIIO_CHECK_EQUAL(spec.width, 1920); @@ -331,6 +333,8 @@ test_imagespec_from_xml() int main(int /*argc*/, char* /*argv*/[]) { + print("sizeof(ImageSpec) = {}\n", sizeof(ImageSpec)); + test_imagespec_pixels(); test_imagespec_metadata_val(); test_imagespec_attribute_from_string(); diff --git a/src/libtexture/imagecache.cpp b/src/libtexture/imagecache.cpp index de1afac15d..c048b04fd1 100644 --- a/src/libtexture/imagecache.cpp +++ b/src/libtexture/imagecache.cpp @@ -30,6 +30,8 @@ #include #include +#include "imagecache_memory_print.h" +#include "imagecache_memory_pvt.h" #include "imagecache_pvt.h" #include "imageio_pvt.h" @@ -2004,6 +2006,8 @@ ImageCacheImpl::getstats(int level) const " Failure reads followed by unexplained success:" " {} files, {} tiles\n", stats.file_retry_success, stats.tile_retry_success); + + printImageCacheMemory(out, *this); } if (level >= 2 && files.size()) { @@ -2464,6 +2468,7 @@ ImageCacheImpl::getattribute(string_view name, TypeDesc type, void* val) const if (Strutil::starts_with(name, "stat:")) { // Stats we can just grab + ATTR_DECODE("stat:cache_footprint", long long, footprint(*this)); ATTR_DECODE("stat:cache_memory_used", long long, m_mem_used); ATTR_DECODE("stat:tiles_created", int, m_stat_tiles_created); ATTR_DECODE("stat:tiles_current", int, m_stat_tiles_current); diff --git a/src/libtexture/imagecache_memory_print.h b/src/libtexture/imagecache_memory_print.h new file mode 100644 index 0000000000..1c8cdeff17 --- /dev/null +++ b/src/libtexture/imagecache_memory_print.h @@ -0,0 +1,234 @@ +// Copyright Contributors to the OpenImageIO project. +// SPDX-License-Identifier: Apache-2.0 +// https://github.com/AcademySoftwareFoundation/OpenImageIO + + +/// \file +//// Memory printing utilities specific to the ImageCacheImpl. + + +#pragma once +#define OPENIMAGEIO_IMAGECACHE_MEMORY_PRINT_H + +#include "imagecache_memory_pvt.h" + +#include + +OIIO_NAMESPACE_BEGIN + +namespace pvt { + +//// Memory tracking helper to get ImageCacheImpl statistics + +//! recorded entries per file format +enum FileFootprintEnty : uint8_t { + kMem = 0, + kCount, + kSpecMem, + kSpecCount, + kInputMem, + kInputCount, + kSubImageMem, + kSubImageCount, + kLevelInfoMem, + kLevelInfoCount, + kLevelInfoSpecMem, + kLevelInfoSpecMembMem, + kLevelInfoSpecParmsMem, + kLevelInfoSpecChanMem, + kFootprintEntrySize +}; + +typedef std::array FileFootprint; +typedef tsl::robin_map FileFootprintMap; + +struct ImageCacheFootprint { + static const ustring utotal; + static const ustring uconstant; + + // basic infos + size_t ic_mem = 0; // image cache + size_t ic_str_mem = 0, ic_str_count = 0; // std::string + size_t ic_tile_mem = 0, ic_tile_count = 0; // tile + size_t ic_thdi_mem = 0, ic_thdi_count = 0; // thread info + size_t ic_fgpt_mem = 0, ic_fgpt_count = 0; // fingerprint + + FileFootprintMap fmap; + template + void add(const size_t size, const ustring& format) + { + addInternal(size, utotal); + addInternal(size, format); + } + + template + void addInternal(const size_t size, const ustring& key) + { + std::pair insert = fmap.insert( + { key, FileFootprint() }); + FileFootprint& array = insert.first.value(); + if (insert.second) + std::fill(array.begin(), array.end(), + 0ul); // std::array has no default init to zero + + // update memory entry + array[entry] += size; + + // update memory entry counter if exists + if constexpr (entry % 2 == 0 && entry <= kLevelInfoMem) + array[entry + 1] += 1; + } +}; + +const ustring ImageCacheFootprint::utotal = ustring("total"); +const ustring ImageCacheFootprint::uconstant = ustring("constant"); + +/// Fills the parameter with a memory breakdown of the ImageCache. +inline size_t +footprint(const ImageCacheImpl& ic, ImageCacheFootprint& output) +{ + // strings + output.ic_str_count = ic.m_searchdirs.size() + 2; + output.ic_str_mem = heapsize(ic.m_searchdirs) + heapsize(ic.m_searchpath) + + heapsize(ic.m_plugin_searchpath); + + // thread info + output.ic_thdi_count = ic.m_all_perthread_info.size(); + output.ic_thdi_mem = heapsize(ic.m_all_perthread_info); + + // tile cache + output.ic_tile_count = ic.m_tilecache.size(); + for (TileCache::iterator t = ic.m_tilecache.begin(), + e = ic.m_tilecache.end(); + t != e; ++t) + output.ic_tile_mem += footprint(t->first) + footprint(t->second); + + // finger prints; we only account for references, this map does not own the files. + constexpr size_t sizeofFingerprintPair = sizeof(ustring) + + sizeof(ImageCacheFileRef); + output.ic_fgpt_count = ic.m_fingerprints.size(); + output.ic_fgpt_mem = output.ic_fgpt_count * sizeofFingerprintPair; + + // files; count the footprint of files, subimages, level infos, image inputs, image specs + for (FilenameMap::iterator t = ic.m_files.begin(), e = ic.m_files.end(); + t != e; ++t) { + // get file format ustring; files with empty file format are simply constant valued. + const ImageCacheFile& file(*t->second); + const ustring& format = !file.fileformat().empty() + ? file.fileformat() + : ImageCacheFootprint::uconstant; + + const size_t fileftp = footprint(t->first) + footprint(t->second); + output.add(fileftp, format); + + const size_t specftp = footprint(file.m_configspec); + output.add(specftp, format); + + const size_t inputftp = footprint(file.m_input); + output.add(inputftp, format); + + // subimages + for (int s = 0, send = file.subimages(); s < send; ++s) { + const ImageCacheFile::SubimageInfo& sub(file.subimageinfo(s)); + const size_t subftp = footprint(sub); + output.add(subftp, format); + + // level infos + for (const auto& level : sub.levels) { + const size_t lvlftp = footprint(level); + output.add(lvlftp, format); + + // extra infos; there are two ImageSpec structures stored in each LevelInfos, + // and they turn out to be memory heavy, so we further break that down next. + const size_t lvlspecftp = footprint(level.m_spec) + + footprint(level.nativespec); + const size_t lvlattrftp + = (level.m_spec ? footprint(level.m_spec->extra_attribs) + : 0) + + footprint(level.nativespec.extra_attribs); + const size_t lvlchanftp + = (level.m_spec ? footprint(level.m_spec->channelnames) : 0) + + footprint(level.nativespec.channelnames); + output.add(lvlspecftp, format); + output.add(2 * sizeof(ImageSpec), + format); + output.add(lvlattrftp, format); + output.add(lvlchanftp, format); + } + } + } + + // update total memory + output.ic_mem += output.ic_str_mem; + output.ic_mem += output.ic_tile_mem; + output.ic_mem += output.ic_thdi_mem; + output.ic_mem += output.fmap.find(ImageCacheFootprint::utotal)->second[kMem]; + output.ic_mem += output.ic_fgpt_mem; + + return output.ic_mem; +} + +inline void +printImageCacheMemory(std::ostream& out, const ImageCacheImpl& ic) +{ + // get memory data + pvt::ImageCacheFootprint data; + pvt::footprint(ic, data); + + // print image cache memory usage + print(out, " Cache : {}\n", Strutil::memformat(data.ic_mem)); + print(out, " Strings : {}, count : {}\n", + Strutil::memformat(data.ic_str_mem), data.ic_str_count); + print(out, " Thread info : {}, count : {}\n", + Strutil::memformat(data.ic_thdi_mem), data.ic_thdi_count); + print(out, " Fingerprints : {}, count : {}\n", + Strutil::memformat(data.ic_fgpt_mem), data.ic_fgpt_count); + print(out, " Tiles : {}, count : {}\n", + Strutil::memformat(data.ic_tile_mem), data.ic_tile_count); + print(out, " Files : {}, count : {}\n", + Strutil::memformat(data.fmap[ImageCacheFootprint::utotal][kMem]), + data.fmap[ImageCacheFootprint::utotal][kCount]); + + // print file formats memory usage + for (pvt::FileFootprintMap::const_iterator t = data.fmap.begin(), + e = data.fmap.end(); + t != e; ++t) { + if (t.key() == ImageCacheFootprint::utotal) + continue; + print(out, " Format '{}' : {}, count : {}\n", t->first, + Strutil::memformat(t.value()[kMem]), t.value()[kCount]); + if (t.value()[kInputMem] > 0ul) + print(out, " Image inputs : {}, count : {}\n", + Strutil::memformat(t.value()[kInputMem]), + t.value()[kInputCount]); + if (t.value()[kSpecMem] > 0ul) + print(out, " Image specs : {}, count : {}\n", + Strutil::memformat(t.value()[kSpecMem]), + t.value()[kSpecCount]); + if (t.value()[kSubImageMem] > 0ul) + print(out, " Subimages : {}, count : {}\n", + Strutil::memformat(t.value()[kSubImageMem]), + t.value()[kSubImageCount]); + if (t.value()[kLevelInfoMem] > 0ul) + print(out, " Level infos : {}, count : {}\n", + Strutil::memformat(t.value()[kLevelInfoMem]), + t.value()[kLevelInfoCount]); + if (t.value()[kLevelInfoSpecMem] > 0ul) + print(out, " Image specs : {}, count : {}\n", + Strutil::memformat(t.value()[kLevelInfoSpecMem]), + t.value()[kLevelInfoCount] * 2); + if (t.value()[kLevelInfoSpecMembMem] > 0ul) + print(out, " Members : {}\n", + Strutil::memformat(t.value()[kLevelInfoSpecMembMem])); + if (t.value()[kLevelInfoSpecParmsMem] > 0ul) + print(out, " Extra attributes : {}\n", + Strutil::memformat(t.value()[kLevelInfoSpecParmsMem])); + if (t.value()[kLevelInfoSpecChanMem] > 0ul) + print(out, " Channel names : {}\n", + Strutil::memformat(t.value()[kLevelInfoSpecChanMem])); + } +} + +} // namespace pvt + +OIIO_NAMESPACE_END \ No newline at end of file diff --git a/src/libtexture/imagecache_memory_pvt.h b/src/libtexture/imagecache_memory_pvt.h new file mode 100644 index 0000000000..10ee4ee8b9 --- /dev/null +++ b/src/libtexture/imagecache_memory_pvt.h @@ -0,0 +1,109 @@ +// Copyright Contributors to the OpenImageIO project. +// SPDX-License-Identifier: Apache-2.0 +// https://github.com/AcademySoftwareFoundation/OpenImageIO + + +/// \file +//// Memory tracking utilities specific to the ImageCacheImpl. + + +#pragma once +#define OPENIMAGEIO_IMAGECACHE_MEMORY_PVT_H + +#include + +#include "imagecache_pvt.h" + +OIIO_NAMESPACE_BEGIN + +namespace pvt { + +// heapsize specialization for ImageCacheFile::LevelInfo +template<> +inline size_t +heapsize(const ImageCacheFile::LevelInfo& lvl) +{ + size_t size = heapsize(lvl.polecolor); + size += heapsize(lvl.m_spec); + size += heapsize(lvl.nativespec); + if (lvl.tiles_read) { + const size_t total_tiles = lvl.nxtiles * lvl.nytiles * lvl.nztiles; + const size_t bitfield_size = round_to_multiple(total_tiles, 64) / 64; + size += sizeof(atomic_ll) * bitfield_size; + } + return size; +} + +// heapsize specialization for ImageCacheFile::SubimageInfo +template<> +inline size_t +heapsize(const ImageCacheFile::SubimageInfo& sub) +{ + size_t size = heapsize(sub.levels); + size += heapsize(sub.average_color); + size += (sub.minwh ? sub.n_mip_levels * sizeof(int) : 0); + size += (sub.Mlocal ? sizeof(Imath::M44f) : 0); + return size; +} + +// heapsize specialization for ImageCacheFile +template<> +inline size_t +heapsize(const ImageCacheFile& file) +{ + size_t size = heapsize(file.m_subimages); + size += heapsize(file.m_configspec); + size += heapsize(file.m_input); + size += heapsize(file.m_mipreadcount); + size += heapsize(file.m_udim_lookup); + return size; +} + +// heapsize specialization for ImageCacheTile +template<> +inline size_t +heapsize(const ImageCacheTile& tile) +{ + return tile.memsize(); +} + +// heapsize specialization for ImageCachePerThreadInfo +template<> +inline size_t +heapsize(const ImageCachePerThreadInfo& info) +{ + /// TODO: this should take into account the two last tiles, if their refcount is zero. + constexpr size_t sizeofPair = sizeof(ustring) + sizeof(ImageCacheFile*); + return info.m_thread_files.size() * sizeofPair; +} + +// heapsize specialization for ImageCacheImpl +template<> +inline size_t +heapsize(const ImageCacheImpl& ic) +{ + size_t size = 0; + // strings + size += heapsize(ic.m_searchpath) + heapsize(ic.m_plugin_searchpath) + + heapsize(ic.m_searchdirs); + // thread info + size += heapsize(ic.m_all_perthread_info); + // tile cache + for (TileCache::iterator t = ic.m_tilecache.begin(), + e = ic.m_tilecache.end(); + t != e; ++t) + size += footprint(t->first) + footprint(t->second); + // files + for (FilenameMap::iterator t = ic.m_files.begin(), e = ic.m_files.end(); + t != e; ++t) + size += footprint(t->first) + footprint(t->second); + // finger prints; we only account for references, this map does not own the files. + constexpr size_t sizeofFingerprintPair = sizeof(ustring) + + sizeof(ImageCacheFileRef); + size += ic.m_fingerprints.size() * sizeofFingerprintPair; + return size; +} + +} // namespace pvt + +OIIO_NAMESPACE_END \ No newline at end of file diff --git a/src/libtexture/imagecache_pvt.h b/src/libtexture/imagecache_pvt.h index d0d353fce1..262ee99ca1 100644 --- a/src/libtexture/imagecache_pvt.h +++ b/src/libtexture/imagecache_pvt.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,7 @@ namespace pvt { struct TileID; class ImageCacheImpl; class ImageCachePerThreadInfo; +struct ImageCacheFootprint; const char* texture_format_name(TexFormat f); @@ -466,6 +468,12 @@ class OIIO_API ImageCacheFile final : public RefCnt { friend class ImageCacheImpl; friend class TextureSystemImpl; friend struct SubimageInfo; + + /// Memory tracking. Specializes the base memory tracking functions from memory.h. + /// declare a friend heapsize definition + template friend inline size_t heapsize(const T&); + /// declare a friend image cache footprint definition + friend inline size_t footprint(const ImageCacheImpl&, ImageCacheFootprint&); }; @@ -1197,7 +1205,9 @@ class ImageCacheImpl final : public ImageCache { spin_mutex m_fingerprints_mutex; ///< Protect m_fingerprints FingerprintMap m_fingerprints; ///< Map fingerprints to files - TileCache m_tilecache; ///< Our in-memory tile cache + /// FIXME: if unordered_map_concurrent had const iterators, + /// m_tilecache wouldn't need to be mutable + mutable TileCache m_tilecache; ///< Our in-memory tile cache TileID m_tile_sweep_id; ///< Sweeper for "clock" paging algorithm spin_mutex m_tile_sweep_mutex; ///< Ensure only one in check_max_mem @@ -1236,6 +1246,11 @@ class ImageCacheImpl final : public ImageCache { // done it with nobody else interfering. } while (llstat->compare_exchange_strong(*llnewval, *lloldval)); } + + /// declare a friend heapsize definition + template friend inline size_t heapsize(const T&); + /// declare a friend image cache footprint definition + friend inline size_t footprint(const ImageCacheImpl&, ImageCacheFootprint&); }; diff --git a/src/libutil/paramlist.cpp b/src/libutil/paramlist.cpp index c3edb9cedb..8439a56ba2 100644 --- a/src/libutil/paramlist.cpp +++ b/src/libutil/paramlist.cpp @@ -383,6 +383,17 @@ 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 { diff --git a/src/libutil/paramlist_test.cpp b/src/libutil/paramlist_test.cpp index fbd4e9555d..6531de20a6 100644 --- a/src/libutil/paramlist_test.cpp +++ b/src/libutil/paramlist_test.cpp @@ -274,14 +274,30 @@ test_from_string() +void +populate_pvl(ParamValueList& pl) +{ + pl["foo"] = 42; + pl["pi"] = float(M_PI); + pl["bar"] = "barbarbar?"; + pl["bar2"] = std::string("barbarbar?"); + pl["bar3"] = ustring("barbarbar?"); + pl["bar4"] = string_view("barbarbar?"); + pl["red"] = Imath::Color3f(1.0f, 0.0f, 0.0f); + pl["xy"] = Imath::V3f(0.5f, 0.5f, 0.0f); + pl["Tx"] = Imath::M44f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 42, 0, 0, 1); +} + + + static void test_paramlist() { std::cout << "test_paramlist\n"; ParamValueList pl; - pl.emplace_back("foo", int(42)); - pl.emplace_back("pi", float(M_PI)); - pl.emplace_back("bar", "barbarbar?"); + populate_pvl(pl); + print("ParamValueList pl heapsize is: {}\n", pvt::heapsize(pl)); + print("ParamValueList pl footprint is: {}\n", pvt::footprint(pl)); OIIO_CHECK_EQUAL(pl.get_int("foo"), 42); OIIO_CHECK_EQUAL(pl.get_int("pi", 4), 4); // should fail int @@ -344,15 +360,7 @@ test_delegates() { std::cout << "test_delegates\n"; ParamValueList pl; - pl["foo"] = 42; - pl["pi"] = float(M_PI); - pl["bar"] = "barbarbar?"; - pl["bar2"] = std::string("barbarbar?"); - pl["bar3"] = ustring("barbarbar?"); - pl["bar4"] = string_view("barbarbar?"); - pl["red"] = Imath::Color3f(1.0f, 0.0f, 0.0f); - pl["xy"] = Imath::V3f(0.5f, 0.5f, 0.0f); - pl["Tx"] = Imath::M44f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 42, 0, 0, 1); + populate_pvl(pl); OIIO_CHECK_EQUAL(pl["absent"].get(), 0); OIIO_CHECK_EQUAL(pl["absent"].type(), TypeUnknown); @@ -402,15 +410,7 @@ test_paramlistspan() { std::cout << "test_paramlistspan\n"; ParamValueList pvlist; - pvlist.emplace_back("foo", int(42)); - pvlist.emplace_back("pi", float(M_PI)); - pvlist.emplace_back("bar", "barbarbar?"); - pvlist["bar2"] = std::string("barbarbar?"); - pvlist["bar3"] = ustring("barbarbar?"); - pvlist["bar4"] = string_view("barbarbar?"); - pvlist["red"] = Imath::Color3f(1.0f, 0.0f, 0.0f); - pvlist["xy"] = Imath::V3f(0.5f, 0.5f, 0.0f); - pvlist["Tx"] = Imath::M44f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 42, 0, 0, 1); + populate_pvl(pvlist); ParamValueSpan pl(pvlist); OIIO_CHECK_EQUAL(pl.get_int("foo"), 42); @@ -526,7 +526,9 @@ test_implied_construction() int main(int /*argc*/, char* /*argv*/[]) { - std::cout << "ParamValue size = " << sizeof(ParamValue) << "\n"; + print("sizeof(ParamValue) is: {}\n", sizeof(ParamValue)); + print("sizeof(ParamValueList) is: {}\n", sizeof(ParamValueList)); + test_value_types(); test_from_string(); test_paramlist(); From fb26ed86edcd88483c7428a9cf3da2fb780a5794 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 12 Aug 2024 10:53:32 -0700 Subject: [PATCH 21/22] deps: Make OCIO 2.2+ a required dependency (#4367) Make OCIO a hard dependency, at least version 2.2. Revise and improve the OCIO "auto-build" scripts. Remove OCIO 1.x testsuite reference output. No longer need FindOpenColorIO.cmake module As part of this, I split the CI "oldest/hobbled" test into two different tests: * oldest -- test against the oldest supported versions of all dependencies. * hobbled -- test against most optional dependencies missing and optional features disabled. --------- Signed-off-by: Larry Gritz --- .github/workflows/ci.yml | 37 +- INSTALL.md | 3 +- src/build-scripts/build_opencolorio.bash | 4 +- src/build-scripts/ci-build.bash | 2 +- src/build-scripts/ci-startup.bash | 1 - src/cmake/Config.cmake.in | 1 + src/cmake/build_OpenColorIO.cmake | 17 +- src/cmake/externalpackages.cmake | 22 +- src/cmake/modules/FindOpenColorIO.cmake | 138 - src/cmake/testing.cmake | 14 +- src/iv/imageviewer.cpp | 17 +- src/iv/imageviewer.h | 6 - src/iv/ivgl_ocio.cpp | 8 +- src/iv/ivgl_ocio.h | 26 +- src/iv/ivmain.cpp | 14 +- src/libOpenImageIO/CMakeLists.txt | 3 +- src/libOpenImageIO/color_ocio.cpp | 184 +- .../OpenColorIO/nuke-default/config.ocio | 191 - .../nuke-default/luts/alexalogc.spi1d | 4107 - .../nuke-default/luts/cineon.spi1d | 4107 - .../nuke-default/luts/panalog.spi1d | 4107 - .../nuke-default/luts/ploglin.spi1d | 4107 - .../nuke-default/luts/rec709.spi1d | 4107 - .../nuke-default/luts/redlog.spi1d | 4107 - .../OpenColorIO/nuke-default/luts/slog.spi1d | 4107 - .../OpenColorIO/nuke-default/luts/srgb.spi1d | 4107 - .../OpenColorIO/nuke-default/luts/srgbf.spi1d | 65567 ---------------- .../nuke-default/luts/viperlog.spi1d | 4107 - .../common/OpenColorIO/nuke-default/make.py | 489 - .../common/OpenColorIO/ocio-v2_demo.ocio | 534 - .../oiiotool-color/ref/out-ocio1.1.0.txt | 62 - .../oiiotool-color/ref/out-ocio1.1.0b.txt | 62 - testsuite/oiiotool-color/ref/out-ocio22.txt | 58 - testsuite/oiiotool-color/ref/out.txt | 7 +- testsuite/oiiotool-color/run.py | 21 +- .../ref/out-noocio-python3.txt | 30 - .../ref/out-ocio11-python3.txt | 30 - .../ref/out-ocio21-python3.txt | 30 - .../python-colorconfig/ref/out-ocio22.txt | 30 - testsuite/python-colorconfig/ref/out.txt | 37 +- testsuite/runtest.py | 16 +- 41 files changed, 104 insertions(+), 104520 deletions(-) delete mode 100644 src/cmake/modules/FindOpenColorIO.cmake delete mode 100644 testsuite/common/OpenColorIO/nuke-default/config.ocio delete mode 100644 testsuite/common/OpenColorIO/nuke-default/luts/alexalogc.spi1d delete mode 100644 testsuite/common/OpenColorIO/nuke-default/luts/cineon.spi1d delete mode 100644 testsuite/common/OpenColorIO/nuke-default/luts/panalog.spi1d delete mode 100644 testsuite/common/OpenColorIO/nuke-default/luts/ploglin.spi1d delete mode 100644 testsuite/common/OpenColorIO/nuke-default/luts/rec709.spi1d delete mode 100644 testsuite/common/OpenColorIO/nuke-default/luts/redlog.spi1d delete mode 100644 testsuite/common/OpenColorIO/nuke-default/luts/slog.spi1d delete mode 100644 testsuite/common/OpenColorIO/nuke-default/luts/srgb.spi1d delete mode 100644 testsuite/common/OpenColorIO/nuke-default/luts/srgbf.spi1d delete mode 100644 testsuite/common/OpenColorIO/nuke-default/luts/viperlog.spi1d delete mode 100755 testsuite/common/OpenColorIO/nuke-default/make.py delete mode 100644 testsuite/common/OpenColorIO/ocio-v2_demo.ocio delete mode 100644 testsuite/oiiotool-color/ref/out-ocio1.1.0.txt delete mode 100644 testsuite/oiiotool-color/ref/out-ocio1.1.0b.txt delete mode 100644 testsuite/oiiotool-color/ref/out-ocio22.txt delete mode 100644 testsuite/python-colorconfig/ref/out-noocio-python3.txt delete mode 100644 testsuite/python-colorconfig/ref/out-ocio11-python3.txt delete mode 100644 testsuite/python-colorconfig/ref/out-ocio21-python3.txt delete mode 100644 testsuite/python-colorconfig/ref/out-ocio22.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ea0ac8a8c..40a2cfff30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,6 +94,7 @@ jobs: container: aswf/ci-osl:2022 vfxyear: 2022 cxx_std: 17 + opencolorio_ver: v2.2.1 python_ver: 3.9 # simd: "avx2,f16c" fmt_ver: 7.1.3 @@ -104,7 +105,7 @@ jobs: FREETYPE_VERSION=VER-2-13-0 # For icc, use fp-model precise to eliminate needless LSB errors # that make test results differ from other platforms. - - desc: icx/C++17 py3.9 exr3.1 ocio2.1 qt5.15 + - desc: icx/C++17 py3.9 exr3.1 ocio2.2 qt5.15 nametag: linux-vfx2022-icx runner: ubuntu-latest container: aswf/ci-osl:2022 @@ -112,10 +113,14 @@ jobs: cc_compiler: icx cxx_compiler: icpx cxx_std: 17 + opencolorio_ver: v2.3.2 python_ver: 3.9 - simd: "avx2,f16c" pybind11_ver: v2.9.0 + simd: "avx2,f16c" setenvs: export USE_OPENVDB=0 + OPENCOLORIO_CXX=g++ + # OCIO doesn't build with icx, so we have to force the ocio build + # to use g++. - desc: sanitizers nametag: sanitizer runner: ubuntu-latest @@ -124,6 +129,7 @@ jobs: cc_compiler: clang cxx_compiler: clang++ cxx_std: 17 + opencolorio_ver: v2.3.2 python_ver: 3.9 setenvs: export SANITIZE=address,undefined OIIO_CMAKE_FLAGS="-DSANITIZE=address,undefined -DUSE_PYTHON=0" @@ -150,15 +156,15 @@ jobs: simd: "avx2,f16c" fmt_ver: 10.1.1 pybind11_ver: v2.12.0 - - desc: oldest gcc9.3/C++17 py3.7 exr-3.1 no-sse no-ocio - # Oldest versions of the dependencies that we can muster, and various - # things disabled (no SSE, OCIO, or OpenCV, don't embed plugins). + - desc: oldest gcc9.3/C++17 py3.7 exr-3.1 + # Oldest versions of the dependencies that we support. nametag: linux-oldest runner: ubuntu-latest container: aswf/ci-osl:2021 vfxyear: 2021 cxx_std: 17 fmt_ver: 7.0.1 + opencolorio_ver: v2.2.1 openexr_ver: v3.1.0 pybind11_ver: v2.7.0 python_ver: 3.7 @@ -166,18 +172,19 @@ jobs: PTEX_VERSION=v2.3.2 WEBP_VERSION=v1.1.0 depcmds: sudo rm -rf /usr/local/include/OpenEXR - - desc: hobbled gcc9.3/C++17 py3.7 exr-3.1 no-sse no-ocio + - desc: hobbled gcc9.3/C++17 py3.7 exr-3.1 no-sse # Use the oldest supported versions of required dependencies, and - # disable most optional dependencies and features (no SSE, OCIO, - # or OpenCV, don't embed plugins). + # disable most optional dependencies and features (no SSE or + # OpenCV, don't embed plugins). nametag: linux-disabled runner: ubuntu-latest container: aswf/ci-osl:2021 vfxyear: 2021 cxx_std: 17 fmt_ver: 7.0.1 + opencolorio_ver: v2.2.1 openexr_ver: v3.1.0 - pybind11_ver: v2.7.0 + pybind11_ver: v2.4.2 python_ver: 3.7 simd: 0 setenvs: export EMBEDPLUGINS=0 @@ -185,7 +192,6 @@ jobs: PTEX_VERSION=v2.3.2 WEBP_VERSION=v1.1.0 USE_JPEGTURBO=0 - USE_OPENCOLORIO=0 USE_OPENCV=0 FREETYPE_VERSION=VER-2-10-0 depcmds: sudo rm -rf /usr/local/include/OpenEXR @@ -220,6 +226,7 @@ jobs: CMAKE_CXX_STANDARD: ${{matrix.cxx_std}} USE_SIMD: ${{matrix.simd}} FMT_VERSION: ${{matrix.fmt_ver}} + OPENCOLORIO_VERSION: ${{matrix.opencolorio_ver}} OPENEXR_VERSION: ${{matrix.openexr_ver}} PYBIND11_VERSION: ${{matrix.pybind11_ver}} PYTHON_VERSION: ${{matrix.python_ver}} @@ -308,6 +315,7 @@ jobs: cxx_compiler: g++-12 cxx_std: 17 fmt_ver: 10.1.1 + opencolorio_ver: v2.3.2 openexr_ver: v3.2.4 pybind11_ver: v2.12.0 python_ver: "3.10" @@ -315,7 +323,6 @@ jobs: setenvs: export LIBJPEGTURBO_VERSION=3.0.1 LIBRAW_VERSION=0.21.2 LIBTIFF_VERSION=v4.6.0 - OPENCOLORIO_VERSION=v2.3.2 OPENJPEG_VERSION=v2.4.0 PTEX_VERSION=v2.4.2 PUGIXML_VERSION=v1.14 @@ -329,6 +336,7 @@ jobs: cxx_compiler: g++-14 cxx_std: 20 fmt_ver: master + opencolorio_ver: main openexr_ver: main pybind11_ver: master python_ver: "3.12" @@ -336,7 +344,6 @@ jobs: setenvs: export LIBJPEGTURBO_VERSION=main LIBRAW_VERSION=master LIBTIFF_VERSION=master - OPENCOLORIO_VERSION=main OPENJPEG_VERSION=master PTEX_VERSION=main PUGIXML_VERSION=master @@ -376,12 +383,12 @@ jobs: cc_compiler: clang cxx_std: 20 fmt_ver: 10.1.1 + opencolorio_ver: v2.2.1 openexr_ver: v3.1.13 pybind11_ver: v2.12.0 python_ver: 3.8 simd: avx2,f16c setenvs: export LLVM_VERSION=14.0.0 - OPENCOLORIO_VERSION=v2.1.2 USE_OPENVDB=0 # The installed OpenVDB has a TLS conflict with Python 3.8 - desc: debug gcc9/C++17, sse4.2, exr3.1 @@ -425,7 +432,8 @@ jobs: OIIO_CMAKE_FLAGS=-DUSE_PYTHON=0 LLVM_VERSION=17.0.6 LLVM_DISTRO_NAME=ubuntu-22.04 SKIP_SYSTEM_DEPS_INSTALL=1 QT_VERSION=0 - OpenImageIO_BUILD_MISSING_DEPS=none + xOpenImageIO_BUILD_MISSING_DEPS=missing + OpenImageIO_OPTIONAL_DEPS=ALL runs-on: ${{ matrix.runner }} env: @@ -434,6 +442,7 @@ jobs: CMAKE_CXX_STANDARD: ${{matrix.cxx_std}} USE_SIMD: ${{matrix.simd}} FMT_VERSION: ${{matrix.fmt_ver}} + OPENCOLORIO_VERSION: ${{matrix.opencolorio_ver}} OPENEXR_VERSION: ${{matrix.openexr_ver}} PYBIND11_VERSION: ${{matrix.pybind11_ver}} PYTHON_VERSION: ${{matrix.python_ver}} diff --git a/INSTALL.md b/INSTALL.md index 40270955af..91bf97d707 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -23,6 +23,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**. * **Imath >= 3.1** (tested through 3.1.x and main) * **OpenEXR >= 3.1** (tested through 3.2 and main) * **libTIFF >= 4.0** (tested through 4.6) + * **OpenColorIO >= 2.2** (tested through 2.3) * libjpeg >= 8 (tested through jpeg9e), or **libjpeg-turbo >= 2.1** (tested through 3.0) * **[fmtlib](https://github.com/fmtlib/fmt) >= 7.0** (tested through 10.2). @@ -66,8 +67,6 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**. * DCMTK >= 3.6.1 (tested through 3.6.8) * If you want support for WebP images: * **WebP >= 1.1** (tested through 1.4) - * If you want support for OpenColorIO color transformations: - * OpenColorIO >= 1.1 (tested through 2.3; 2.0+ is recommended) * If you want support for Ptex: * Ptex >= 2.3.1 (probably works for older; tested through 2.4.2) * If you want to be able to do font rendering into images: diff --git a/src/build-scripts/build_opencolorio.bash b/src/build-scripts/build_opencolorio.bash index ef37c121ad..b5018bc13c 100755 --- a/src/build-scripts/build_opencolorio.bash +++ b/src/build-scripts/build_opencolorio.bash @@ -11,7 +11,7 @@ set -ex # Which OCIO to retrieve, how to build it OPENCOLORIO_REPO=${OPENCOLORIO_REPO:=https://github.com/AcademySoftwareFoundation/OpenColorIO.git} -OPENCOLORIO_VERSION=${OPENCOLORIO_VERSION:=v2.2.1} +OPENCOLORIO_VERSION=${OPENCOLORIO_VERSION:=v2.3.2} # Where to install the final results LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext} @@ -19,6 +19,7 @@ OPENCOLORIO_SOURCE_DIR=${OPENCOLORIO_SOURCE_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO} OPENCOLORIO_BUILD_DIR=${OPENCOLORIO_BUILD_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO-build} OPENCOLORIO_INSTALL_DIR=${OPENCOLORIO_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist} OPENCOLORIO_BUILD_TYPE=${OPENCOLORIO_BUILD_TYPE:=Release} +OPENCOLORIO_CXX=${OPENCOLORIO_CXX:=g++} OPENCOLORIO_CXX_FLAGS=${OPENCOLORIO_CXX_FLAGS:="-Wno-unused-function -Wno-deprecated-declarations -Wno-cast-qual -Wno-write-strings"} # Just need libs: OPENCOLORIO_BUILDOPTS="-DOCIO_BUILD_APPS=OFF -DOCIO_BUILD_NUKE=OFF \ @@ -46,6 +47,7 @@ git checkout ${OPENCOLORIO_VERSION} --force time cmake -S . -B ${OPENCOLORIO_BUILD_DIR} \ -DCMAKE_BUILD_TYPE=${OPENCOLORIO_BUILD_TYPE} \ -DCMAKE_INSTALL_PREFIX=${OPENCOLORIO_INSTALL_DIR} \ + -DCMAKE_CXX_COMPILER=${OPENCOLORIO_CXX} \ -DCMAKE_CXX_FLAGS="${OPENCOLORIO_CXX_FLAGS}" \ ${OPENCOLORIO_BUILDOPTS} time cmake --build ${OPENCOLORIO_BUILD_DIR} --config Release --target install diff --git a/src/build-scripts/ci-build.bash b/src/build-scripts/ci-build.bash index e5dfaf6c3f..fa5857abaf 100755 --- a/src/build-scripts/ci-build.bash +++ b/src/build-scripts/ci-build.bash @@ -43,7 +43,7 @@ cmake -S $OIIO_SRC_DIR -B $OIIO_BUILD_DIR -G "$CMAKE_GENERATOR" \ $OIIO_CMAKE_FLAGS -DVERBOSE=1 # Save a copy of the generated files for debugging broken CI builds. -mkdir ${OIIO_BUILD_DIR}/cmake-save || /bin/true +mkdir ${OIIO_BUILD_DIR}/cmake-save || true cp -r ${OIIO_BUILD_DIR}/CMake* ${OIIO_BUILD_DIR}/*.cmake ${OIIO_BUILD_DIR}/cmake-save : ${BUILDTARGET:=install} diff --git a/src/build-scripts/ci-startup.bash b/src/build-scripts/ci-startup.bash index bb49fd3311..527f29d594 100755 --- a/src/build-scripts/ci-startup.bash +++ b/src/build-scripts/ci-startup.bash @@ -44,7 +44,6 @@ export LD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib64:$LD_LIBRARY_PATH export DYLD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib:$DYLD_LIBRARY_PATH -# export OCIO="$PWD/testsuite/common/OpenColorIO/nuke-default/config.ocio" export TESTSUITE_CLEANUP_ON_SUCCESS=${TESTSUITE_CLEANUP_ON_SUCCESS:=1} # For CI, default to building missing dependencies automatically diff --git a/src/cmake/Config.cmake.in b/src/cmake/Config.cmake.in index 30d4e3a5d2..2620994b38 100644 --- a/src/cmake/Config.cmake.in +++ b/src/cmake/Config.cmake.in @@ -21,6 +21,7 @@ if (NOT @BUILD_SHARED_LIBS@) # INTERFACE_LINK_LIBRARIES. If the project does not know about PNG target, it will cause # configuration error about unknown targets being linked in. find_dependency(TIFF) + find_dependency(OpenColorIO) if (@JPEG_FOUND@) find_dependency(JPEG) endif() diff --git a/src/cmake/build_OpenColorIO.cmake b/src/cmake/build_OpenColorIO.cmake index 5905eb597a..6e772245f0 100644 --- a/src/cmake/build_OpenColorIO.cmake +++ b/src/cmake/build_OpenColorIO.cmake @@ -15,6 +15,14 @@ set_cache (OpenColorIO_BUILD_SHARED_LIBS ON # it all work with the static dependencies, it just makes things complicated # downstream. +# Clear variables from the failed find_package +unset (OPENCOLORIO_LIBRARY) +unset (OPENCOLORIO_INCLUDE_DIR) +unset (FIND_PACKAGE_MESSAGE_DETAILS_OpenColorIO) +unset (OPENCOLORIO_VERSION_MAJOR) +unset (OPENCOLORIO_VERSION_MINOR) +unset (OpenColorIO_DIR) + string (MAKE_C_IDENTIFIER ${OpenColorIO_BUILD_VERSION} OpenColorIO_VERSION_IDENT) build_dependency_with_cmake(OpenColorIO @@ -35,8 +43,8 @@ build_dependency_with_cmake(OpenColorIO -D OCIO_INSTALL_EXT_PACKAGES=MISSING # Give the library a custom name and symbol namespace so it can't # conflict with any others in the system or linked into the same app. - -D OCIO_NAMESPACE=${PROJ_NAMESPACE_V}_OpenColorIO - -D OCIO_LIBNAME_SUFFIX=_v${OpenColorIO_VERSION_IDENT}_${PROJ_NAMESPACE_V} + # -D OCIO_NAMESPACE=${OpenColorIO_VERSION_IDENT}_${PROJ_NAME} + -D OCIO_LIBNAME_SUFFIX=_v${OpenColorIO_VERSION_IDENT}_${PROJ_NAME} ) # Set some things up that we'll need for a subsequent find_package to work @@ -46,8 +54,9 @@ set (OpenColorIO_ROOT ${OpenColorIO_LOCAL_INSTALL_DIR}) set (OpenColorIO_DIR ${OpenColorIO_LOCAL_INSTALL_DIR}) # Signal to caller that we need to find again at the installed location -set (OpenColorIO_REFIND TRUE) -set (OpenColorIO_REFIND_ARGS CONFIG) +# set (OpenColorIO_REFIND TRUE) +# set (OpenColorIO_REFIND_ARGS CONFIG) +find_package (OpenColorIO ${OpenColorIO_BUILD_VERSION} EXACT CONFIG REQUIRED) if (OpenColorIO_BUILD_SHARED_LIBS) install_local_dependency_libs (OpenColorIO OpenColorIO) diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake index 71439639c1..f4fe8320ea 100644 --- a/src/cmake/externalpackages.cmake +++ b/src/cmake/externalpackages.cmake @@ -129,23 +129,13 @@ checked_find_package (Freetype VERSION_MIN 2.10.0 DEFINITIONS USE_FREETYPE=1 ) -checked_find_package (OpenColorIO - VERSION_MIN 1.1 +checked_find_package (OpenColorIO REQUIRED + VERSION_MIN 2.2 VERSION_MAX 2.9 - NO_FP_RANGE_CHECK - DEFINITIONS USE_OCIO=1 USE_OPENCOLORIO=1 - ) -if (OpenColorIO_FOUND) - option (OIIO_DISABLE_BUILTIN_OCIO_CONFIGS - "For deveoper debugging/testing ONLY! Disable OCIO 2.2 builtin configs." OFF) - if (OIIO_DISABLE_BUILTIN_OCIO_CONFIGS OR "$ENV{OIIO_DISABLE_BUILTIN_OCIO_CONFIGS}") - add_compile_definitions(OIIO_DISABLE_BUILTIN_OCIO_CONFIGS) - endif () - if (NOT OPENCOLORIO_INCLUDES) - get_target_property(OPENCOLORIO_INCLUDES OpenColorIO::OpenColorIO INTERFACE_INCLUDE_DIRECTORIES) - endif () -else () - set (OpenColorIO_FOUND 0) + PREFER_CONFIG + ) +if (NOT OPENCOLORIO_INCLUDES) + get_target_property(OPENCOLORIO_INCLUDES OpenColorIO::OpenColorIO INTERFACE_INCLUDE_DIRECTORIES) endif () include_directories(BEFORE ${OPENCOLORIO_INCLUDES}) diff --git a/src/cmake/modules/FindOpenColorIO.cmake b/src/cmake/modules/FindOpenColorIO.cmake deleted file mode 100644 index 474813917b..0000000000 --- a/src/cmake/modules/FindOpenColorIO.cmake +++ /dev/null @@ -1,138 +0,0 @@ -# Copyright Contributors to the OpenImageIO project. -# SPDX-License-Identifier: Apache-2.0 -# https://github.com/AcademySoftwareFoundation/OpenImageIO - -# Module to find OpenColorIO -# -# This module will first look into the directories hinted by the variables: -# - OpenColorIO_ROOT -# -# This module defines the following targets: -# -# - OpenColorIO::OpenColorIO -# -# Old style CMake, this module also defines the following variables: -# -# OpenColorIO_FOUND - True if OpenColorIO was found. -# OPENCOLORIO_INCLUDES - where to find OpenColorIO.h -# OPENCOLORIO_LIBRARIES - list of libraries to link against when using OpenColorIO -# OPENCOLORIO_DEFINITIONS - Definitions needed when using OpenColorIO -# -# Hints and overrides: -# -# - OPENCOLORIO_INTERFACE_LINK_LIBRARIES - override for interface link -# libraries on the OpenColorIO::OpenColorIO target. -# - OPENCOLORIO_NO_CONFIG - if ON, this module will be used even if an -# OCIO >= 2.1 cmake config is found. If OFF (the default), a config file -# will be preferred if found. -# -# OpenColorIO 2.1 exports proper cmake config files on its own. -# Once OCIO 2.1 is our new minimum, this FindOpenColorIO.cmake will -# eventually be deprecated and disappear. -# - -if (NOT OPENCOLORIO_NO_CONFIG) - find_package(OpenColorIO CONFIG) -endif () - -if (TARGET OpenColorIO::OpenColorIO) - if (OPENCOLORIO_INTERFACE_LINK_LIBRARIES) - set_target_properties(OpenColorIO::OpenColorIO PROPERTIES - INTERFACE_LINK_LIBRARIES "${OPENCOLORIO_INTERFACE_LINK_LIBRARIES}") - endif () - -else () -# vvvv the rest is if no OCIO exported config file is found - -include (FindPackageHandleStandardArgs) -include (FindPackageMessage) - -find_path (OPENCOLORIO_INCLUDE_DIR - OpenColorIO/OpenColorIO.h - HINTS - ${OPENCOLORIO_INCLUDE_PATH} - ENV OPENCOLORIO_INCLUDE_PATH - PATHS - /sw/include - /opt/local/include - DOC "The directory where OpenColorIO/OpenColorIO.h resides") - -if (EXISTS "${OPENCOLORIO_INCLUDE_DIR}/OpenColorIO/OpenColorABI.h") - # Search twice, because this symbol changed between OCIO 1.x and 2.x - file(STRINGS "${OPENCOLORIO_INCLUDE_DIR}/OpenColorIO/OpenColorABI.h" TMP - REGEX "^#define OCIO_VERSION_STR[ \t].*$") - if (NOT TMP) - file(STRINGS "${OPENCOLORIO_INCLUDE_DIR}/OpenColorIO/OpenColorABI.h" TMP - REGEX "^#define OCIO_VERSION[ \t].*$") - endif () - string (REGEX MATCHALL "([0-9]+)\\.([0-9]+)\\.[0-9]+" OPENCOLORIO_VERSION ${TMP}) - set (OPENCOLORIO_VERSION_MAJOR ${CMAKE_MATCH_1}) - set (OPENCOLORIO_VERSION_MINOR ${CMAKE_MATCH_2}) -endif () - -find_library (OPENCOLORIO_LIBRARY - NAMES - OpenColorIO - OpenColorIO_${OPENCOLORIO_VERSION_MAJOR}_${OPENCOLORIO_VERSION_MINOR} - HINTS - ${OPENCOLORIO_LIBRARY_PATH} - ENV OPENCOLORIO_LIBRARY_PATH - PATHS - /usr/lib64 - /usr/local/lib64 - /sw/lib - /opt/local/lib - DOC "The OCIO library") - -find_package_handle_standard_args (OpenColorIO - REQUIRED_VARS OPENCOLORIO_INCLUDE_DIR OPENCOLORIO_LIBRARY - FOUND_VAR OpenColorIO_FOUND - VERSION_VAR OPENCOLORIO_VERSION - ) - -if (OpenColorIO_FOUND) - set (OpenColorIO_VERSION ${OPENCOLORIO_VERSION}) - set (OPENCOLORIO_INCLUDES ${OPENCOLORIO_INCLUDE_DIR}) - set (OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBRARY}) - set (OPENCOLORIO_DEFINITIONS "") - if (NOT TARGET OpenColorIO::OpenColorIO) - add_library(OpenColorIO::OpenColorIO UNKNOWN IMPORTED) - set_target_properties(OpenColorIO::OpenColorIO PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OPENCOLORIO_INCLUDES}") - - set_property(TARGET OpenColorIO::OpenColorIO APPEND PROPERTY - IMPORTED_LOCATION "${OPENCOLORIO_LIBRARIES}") - if (OPENCOLORIO_INTERFACE_LINK_LIBRARIES) - set_target_properties(OpenColorIO::OpenColorIO PROPERTIES - INTERFACE_LINK_LIBRARIES "${OPENCOLORIO_INTERFACE_LINK_LIBRARIES}") - endif () - if (LINKSTATIC) - target_compile_definitions(OpenColorIO::OpenColorIO - INTERFACE "-DOpenColorIO_STATIC") - endif() - endif () - if (NOT TARGET OpenColorIO::OpenColorIOHeaders) - add_library(OpenColorIO::OpenColorIOHeaders INTERFACE IMPORTED) - set_target_properties(OpenColorIO::OpenColorIOHeaders PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OPENCOLORIO_INCLUDES}") - endif () -endif () - -if (OpenColorIO_FOUND AND LINKSTATIC) - # Is this necessary? - set (OPENCOLORIO_DEFINITIONS "OpenColorIO_STATIC") - find_library (TINYXML_LIBRARY NAMES tinyxml) - if (TINYXML_LIBRARY) - set (OPENCOLORIO_LIBRARIES "${OPENCOLORIO_LIBRARIES};${TINYXML_LIBRARY}" CACHE STRING "" FORCE) - endif () - find_library (YAML_LIBRARY NAMES yaml-cpp) - if (YAML_LIBRARY) - set (OPENCOLORIO_LIBRARIES "${OPENCOLORIO_LIBRARIES};${YAML_LIBRARY}" CACHE STRING "" FORCE) - endif () - find_library (LCMS2_LIBRARY NAMES lcms2) - if (LCMS2_LIBRARY) - set (OPENCOLORIO_LIBRARIES "${OPENCOLORIO_LIBRARIES};${LCMS2_LIBRARY}" CACHE STRING "" FORCE) - endif () -endif () - -endif() diff --git a/src/cmake/testing.cmake b/src/cmake/testing.cmake index 49ffa8af09..cf348a3cee 100644 --- a/src/cmake/testing.cmake +++ b/src/cmake/testing.cmake @@ -69,17 +69,9 @@ macro (oiio_add_tests) set (_test_disabled 1) endif () endforeach () - if (OpenColorIO_VERSION VERSION_GREATER_EQUAL 2.2 - AND NOT (OIIO_DISABLE_BUILTIN_OCIO_CONFIGS OR "$ENV{OIIO_DISABLE_BUILTIN_OCIO_CONFIGS}")) - # For OCIO 2.2+, have the testsuite use the default built-in config - list (APPEND _ats_ENVIRONMENT "OCIO=ocio://default" - "OIIO_TESTSUITE_OCIOCONFIG=ocio://default") - else () - # For OCIO 2.1 and earlier, have the testsuite use one we have in - # the testsuite directory. - list (APPEND _ats_ENVIRONMENT "OCIO=../common/OpenColorIO/nuke-default/config.ocio" - "OIIO_TESTSUITE_OCIOCONFIG=../common/OpenColorIO/nuke-default/config.ocio") - endif () + # For OCIO 2.2+, have the testsuite use the default built-in config + list (APPEND _ats_ENVIRONMENT "OCIO=ocio://default" + "OIIO_TESTSUITE_OCIOCONFIG=ocio://default") if (_test_disabled) message (STATUS "Skipping test(s) ${_ats_UNPARSED_ARGUMENTS} because of disabled ${_ats_ENABLEVAR}") elseif (_ats_IMAGEDIR AND NOT EXISTS ${_ats_testdir}) diff --git a/src/iv/imageviewer.cpp b/src/iv/imageviewer.cpp index 8aa7aac13e..a22c5eae81 100644 --- a/src/iv/imageviewer.cpp +++ b/src/iv/imageviewer.cpp @@ -111,12 +111,10 @@ ImageViewer::ImageViewer(bool use_ocio, const std::string& image_color_space, , m_fullscreen(false) , m_default_gamma(1) , m_darkPalette(false) -#ifdef HAS_OCIO_2 , m_useOCIO(use_ocio) , m_ocioColourSpace(image_color_space) , m_ocioDisplay(display) , m_ocioView(view) -#endif // HAS_OCIO_2 { readSettings(false); @@ -139,11 +137,7 @@ ImageViewer::ImageViewer(bool use_ocio, const std::string& image_color_space, slideDuration_ms = 5000; slide_loop = true; -#ifdef HAS_OCIO_2 glwin = new IvGL_OCIO(this, *this); -#else - glwin = new IvGL(this, *this); -#endif glwin->setPalette(m_palette); glwin->resize(m_default_width, m_default_height); @@ -462,7 +456,7 @@ ImageViewer::createActions() SLOT(setSlideShowDuration(int))); } -#ifdef HAS_OCIO_2 + void ImageViewer::createOCIOMenus(QMenu* parent) @@ -606,7 +600,6 @@ ImageViewer::ocioDisplayViewAction() } } -#endif // HAS_OCIO_2 void ImageViewer::createMenus() @@ -694,9 +687,7 @@ ImageViewer::createMenus() viewMenu->addMenu(channelMenu); viewMenu->addMenu(colormodeMenu); -#ifdef HAS_OCIO_2 createOCIOMenus(viewMenu); -#endif viewMenu->addMenu(expgamMenu); menuBar()->addMenu(viewMenu); @@ -1046,14 +1037,8 @@ void ImageViewer::moveToNewWindow() { if (m_images.size()) { -#ifdef HAS_OCIO_2 ImageViewer* imageViewer = new ImageViewer(m_useOCIO, m_ocioColourSpace, m_ocioDisplay, m_ocioView); -#else - std::string dummy; - ImageViewer* imageViewer = new ImageViewer(false, dummy, dummy, dummy); -#endif - imageViewer->show(); imageViewer->rawcolor(rawcolor()); imageViewer->add_image(m_images[m_current_image]->name()); diff --git a/src/iv/imageviewer.h b/src/iv/imageviewer.h index d7dc8ef1d1..f1c0622547 100644 --- a/src/iv/imageviewer.h +++ b/src/iv/imageviewer.h @@ -244,12 +244,10 @@ class ImageViewer final : public QMainWindow { void rawcolor(bool val) { m_rawcolor = val; } bool rawcolor() const { return m_rawcolor; } -#ifdef HAS_OCIO_2 bool useOCIO() { return m_useOCIO; } const std::string& ocioColorSpace() { return m_ocioColourSpace; } const std::string& ocioDisplay() { return m_ocioDisplay; } const std::string& ocioView() { return m_ocioView; } -#endif // HAS_OCIO_2 private slots: void open(); ///< Dialog to open new image from file @@ -310,11 +308,9 @@ private slots: void showPixelviewWindow(); ///< View closeup pixel view void editPreferences(); ///< Edit viewer preferences -#ifdef HAS_OCIO_2 void useOCIOAction(bool checked); void ocioColorSpaceAction(); void ocioDisplayViewAction(); -#endif // HAS_OCIO_2 private: void createActions(); @@ -427,7 +423,6 @@ private slots: friend class IvPreferenceWindow; friend bool image_progress_callback(void* opaque, float done); -#ifdef HAS_OCIO_2 friend class IvGL_OCIO; void createOCIOMenus(QMenu* parent); @@ -444,7 +439,6 @@ private slots: std::string m_ocioColourSpace; std::string m_ocioDisplay; std::string m_ocioView; -#endif // HAS_OCIO_2 }; diff --git a/src/iv/ivgl_ocio.cpp b/src/iv/ivgl_ocio.cpp index d85439573c..0997fb6e4c 100644 --- a/src/iv/ivgl_ocio.cpp +++ b/src/iv/ivgl_ocio.cpp @@ -7,7 +7,6 @@ #include -#ifdef HAS_OCIO_2 IvGL_OCIO::IvGL_OCIO(QWidget* parent, ImageViewer& viewer) : IvGL(parent, viewer) @@ -360,15 +359,15 @@ IvGL_OCIO::allocate_all_textures(unsigned start_index) unsigned height = 0; GpuShaderDesc::TextureType channel = GpuShaderDesc::TEXTURE_RGB_CHANNEL; Interpolation interpolation = INTERP_LINEAR; -# ifdef HAS_OCIO_2_3 +#if OCIO_VERSION_HEX >= MAKE_OCIO_VERSION_HEX(2, 3, 0) GpuShaderCreator::TextureDimensions dimensions = GpuShaderCreator::TextureDimensions::TEXTURE_2D; m_shader_desc->getTexture(idx, textureName, samplerName, width, height, channel, dimensions, interpolation); -# else +#else m_shader_desc->getTexture(idx, textureName, samplerName, width, height, channel, interpolation); -# endif +#endif if (!textureName || !*textureName || !samplerName || !*samplerName || width == 0) { @@ -407,6 +406,5 @@ IvGL_OCIO::use_all_textures() } } -#endif // HAS_OCIO_2 //OIIO_PRAGMA_WARNING_POP diff --git a/src/iv/ivgl_ocio.h b/src/iv/ivgl_ocio.h index 38468b9b6a..ca4639c2b7 100644 --- a/src/iv/ivgl_ocio.h +++ b/src/iv/ivgl_ocio.h @@ -6,23 +6,14 @@ #ifndef OPENIMAGEIO_IVGL_OCIO_H #define OPENIMAGEIO_IVGL_OCIO_H -#ifdef USE_OCIO -# include -# if OCIO_VERSION_MAJOR >= 2 -# define HAS_OCIO_2 -# if OCIO_VERSION_MAJOR == 2 -# if OCIO_VERSION_MINOR >= 3 -# define HAS_OCIO_2_3 -# endif -# endif -# endif -#endif - -#ifdef HAS_OCIO_2 -# include "ivgl.h" - -# include -# include +#include + +#define MAKE_OCIO_VERSION_HEX(maj, min, patch) \ + (((maj) << 24) | ((min) << 16) | (patch)) + +#include "ivgl.h" + +#include using namespace OIIO; @@ -104,5 +95,4 @@ class IvGL_OCIO : public IvGL { Interpolation interpolation); }; -#endif // HAS_OCIO_2 #endif // OPENIMAGEIO_IVGL_OCIO_H diff --git a/src/iv/ivmain.cpp b/src/iv/ivmain.cpp index 0b17831aa3..a9c1181f55 100644 --- a/src/iv/ivmain.cpp +++ b/src/iv/ivmain.cpp @@ -58,7 +58,6 @@ getargs(int argc, char* argv[]) ap.arg("--rawcolor") .help("Do not automatically transform to RGB"); -#ifdef HAS_OCIO_2 ap.arg("--display") .help("OCIO display") .metavar("STRING") @@ -74,7 +73,6 @@ getargs(int argc, char* argv[]) .metavar("STRING") .defaultval("") .action(ArgParse::store()); -#endif ap.parse(argc, (const char**)argv); return ap; @@ -110,28 +108,18 @@ main(int argc, char* argv[]) // Q_INIT_RESOURCE(iv); QApplication app(argc, argv); -#ifdef HAS_OCIO_2 std::string color_space = ap["image-color-space"].as_string(""); std::string display = ap["display"].as_string(""); std::string view = ap["view"].as_string(""); // std::string look = ap["look"].as_string(""); bool use_ocio = color_space != "" && display != "" && view != ""; - -#ifdef OCIO_HAS_BUILTIN_CONFIGS std::string ocioenv = Sysutil::getenv("OCIO"); - if (ocioenv.empty() || !Filesystem::exists(ocioenv)) { + if (ocioenv.empty() || !Filesystem::exists(ocioenv)) setenv("OCIO", "ocio://default", 1); - } -#endif ImageViewer* mainWin = new ImageViewer(use_ocio, color_space, display, view); -#else - std::string dummy; - ImageViewer* mainWin = new ImageViewer(false, dummy, dummy, dummy); -#endif - mainWin->show(); diff --git a/src/libOpenImageIO/CMakeLists.txt b/src/libOpenImageIO/CMakeLists.txt index 7a76509f5b..fc3ab80512 100644 --- a/src/libOpenImageIO/CMakeLists.txt +++ b/src/libOpenImageIO/CMakeLists.txt @@ -137,7 +137,6 @@ target_include_directories (OpenImageIO ${OPENEXR_INCLUDES} PRIVATE ${ROBINMAP_INCLUDES} - ${OPENIMAGEIO_OPENCOLORIO_INCLUDES} ) target_include_directories (OpenImageIO SYSTEM PUBLIC ${OpenCV_INCLUDES}) @@ -158,7 +157,7 @@ target_link_libraries (OpenImageIO ${OPENIMAGEIO_OPENEXR_TARGETS} ${OpenCV_LIBRARIES} ${format_plugin_libs} # Add all the target link libraries from the plugins - $ + OpenColorIO::OpenColorIO $ $ $ diff --git a/src/libOpenImageIO/color_ocio.cpp b/src/libOpenImageIO/color_ocio.cpp index 38e8d39525..dd48db4985 100644 --- a/src/libOpenImageIO/color_ocio.cpp +++ b/src/libOpenImageIO/color_ocio.cpp @@ -24,19 +24,13 @@ #define MAKE_OCIO_VERSION_HEX(maj, min, patch) \ (((maj) << 24) | ((min) << 16) | (patch)) -#ifdef USE_OCIO -# include -# if OCIO_VERSION_HEX >= MAKE_OCIO_VERSION_HEX(2, 0, 0) -# define OCIO_v2 1 -# endif -# if OCIO_VERSION_HEX >= MAKE_OCIO_VERSION_HEX(2, 2, 0) \ - && !defined(OIIO_DISABLE_BUILTIN_OCIO_CONFIGS) -# define OCIO_HAS_BUILTIN_CONFIGS 1 -# endif -namespace OCIO = OCIO_NAMESPACE; -#else -# define OCIO_VERSION_HEX 0 +#include + +#define OCIO_v2 1 +#ifndef OIIO_DISABLE_BUILTIN_OCIO_CONFIGS +# define OCIO_HAS_BUILTIN_CONFIGS 1 #endif +namespace OCIO = OCIO_NAMESPACE; OIIO_NAMESPACE_BEGIN @@ -63,9 +57,7 @@ static bool colordebug = Strutil::stoi(Sysutil::getenv("OIIO_DEBUG_COLOR")) static int disable_ocio = Strutil::stoi(Sysutil::getenv("OIIO_DISABLE_OCIO")); static int disable_builtin_configs = Strutil::stoi( Sysutil::getenv("OIIO_DISABLE_BUILTIN_OCIO_CONFIGS")); -#ifdef USE_OCIO static OCIO::ConstConfigRcPtr ocio_current_config; -#endif @@ -151,11 +143,7 @@ typedef tsl::robin_map