Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
963d07d531 | ||
|
|
ecbeda622f | ||
|
|
a6345e095e | ||
|
|
8e470c7616 | ||
|
|
d8810c5365 | ||
|
|
d631f92721 | ||
|
|
7f71282027 | ||
|
|
4f981ba3b7 | ||
|
|
d0a77b9f2f | ||
|
|
292b6ac1c1 | ||
|
|
f8969b894a | ||
|
|
871e88c857 | ||
|
|
dcf48e1f80 | ||
|
|
94be07fbce | ||
|
|
1d0e570a49 | ||
|
|
be2c4e3198 | ||
|
|
5ba33f3886 | ||
|
|
bfa4ba5f2e |
+1
-1
@@ -6,7 +6,7 @@ AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
|
||||
@@ -106,7 +106,7 @@ jobs:
|
||||
CMAKE_CXX_STANDARD: 17
|
||||
PYTHON_VERSION: 3.7
|
||||
USE_SIMD: avx2,f16c
|
||||
OPENEXR_BRANCH: v2.5.0
|
||||
OPENEXR_VERSION: v2.5.0
|
||||
run: |
|
||||
source src/build-scripts/ci-startup.bash
|
||||
source src/build-scripts/gh-installdeps-centos.bash
|
||||
@@ -150,7 +150,7 @@ jobs:
|
||||
CXX: g++-8
|
||||
CMAKE_CXX_STANDARD: 17
|
||||
USE_SIMD: avx
|
||||
OPENEXR_BRANCH: v2.5.0
|
||||
OPENEXR_VERSION: v2.5.0
|
||||
run: |
|
||||
source src/build-scripts/ci-startup.bash
|
||||
source src/build-scripts/gh-installdeps.bash
|
||||
@@ -172,8 +172,8 @@ jobs:
|
||||
CXX: g++-10
|
||||
CMAKE_CXX_STANDARD: 17
|
||||
USE_SIMD: avx2,f16c
|
||||
OPENEXR_BRANCH: v2.5.0
|
||||
PYBIND11_VERSION: 2.5.0
|
||||
OPENEXR_VERSION: v2.5.0
|
||||
PYBIND11_VERSION: v2.5.0
|
||||
LIBRAW_BRANCH: 0.20.0
|
||||
MY_CMAKE_FLAGS: -DBUILD_FMT_VERSION=7.0.1
|
||||
run: |
|
||||
@@ -202,10 +202,10 @@ jobs:
|
||||
CXX: g++-10
|
||||
CMAKE_CXX_STANDARD: 17
|
||||
USE_SIMD: avx2,f16c
|
||||
OPENEXR_BRANCH: master
|
||||
OPENEXR_VERSION: master
|
||||
OCIO_BRANCH: master
|
||||
LIBTIFF_BRANCH: master
|
||||
PYBIND11_BRANCH: master
|
||||
PYBIND11_VERSION: master
|
||||
LIBRAW_BRANCH: master
|
||||
MY_CMAKE_FLAGS: -DBUILD_FMT_VERSION=master
|
||||
run: |
|
||||
@@ -241,7 +241,7 @@ jobs:
|
||||
USE_OPENCOLORIO: 0
|
||||
USE_OPENCV: 0
|
||||
EMBEDPLUGINS: 0
|
||||
OPENEXR_BRANCH: v2.2.0
|
||||
OPENEXR_VERSION: v2.2.0
|
||||
MY_CMAKE_FLAGS: -DBUILD_FMT_VERSION=6.1.2
|
||||
run: |
|
||||
source src/build-scripts/ci-startup.bash
|
||||
@@ -291,7 +291,7 @@ jobs:
|
||||
env:
|
||||
PYTHON_VERSION: 3.6
|
||||
CMAKE_GENERATOR: "Visual Studio 16 2019"
|
||||
OPENEXR_BRANCH: v2.4.1
|
||||
OPENEXR_VERSION: v2.4.1
|
||||
SKIP_TESTS: 1
|
||||
run: |
|
||||
source src/build-scripts/ci-startup.bash
|
||||
@@ -315,7 +315,7 @@ jobs:
|
||||
env:
|
||||
PYTHON_VERSION: 3.6
|
||||
CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
|
||||
OPENEXR_BRANCH: v2.4.1
|
||||
OPENEXR_VERSION: v2.4.1
|
||||
SKIP_TESTS: 1
|
||||
#MY_CMAKE_FLAGS: -DUSE_PYTHON=0
|
||||
USE_NINJA: 0
|
||||
@@ -370,7 +370,7 @@ jobs:
|
||||
LLVM_VERSION: 9.0.0
|
||||
CMAKE_CXX_STANDARD: 14
|
||||
USE_SIMD: avx2,f16c
|
||||
OPENEXR_BRANCH: v2.4.1
|
||||
OPENEXR_VERSION: v2.4.1
|
||||
OCIO_BRANCH: 1c624651b7
|
||||
# Pick an OCIO commit that includes a warning fix we need for clang
|
||||
run: |
|
||||
+47
-13
@@ -5,12 +5,26 @@ New minimum dependencies:
|
||||
* openjpeg >= 2.0 (if JPEG-2000 support is desired) #2555 (2.2.2)
|
||||
|
||||
New major features and public API changes:
|
||||
* New IOProxy support: ImageInput and ImageOutput now have direct API level
|
||||
support for IOProxy in their `open()` and `create()` calls, as well as a
|
||||
new `set_ioproxy()` method in these classes. ImageBuf similarly can specify
|
||||
a proxy upon construction for reading, and for writing via a
|
||||
`set_write_ioproxy()` method that applies to subsequent `write` call.
|
||||
#2434 (2.2.0), #2477 (2.2.1).
|
||||
* Improved IOProxy support:
|
||||
- ImageInput and ImageOutput now have direct API level support for IOProxy
|
||||
in their `open()` and `create()` calls, as well as a new `set_ioproxy()`
|
||||
method in these classes. #2434 (2.2.0)
|
||||
- ImageBuf can now specify a proxy upon construction for reading, and for
|
||||
writing via a `set_write_ioproxy()` method that applies to subsequent
|
||||
`write` call. #2477 (2.2.1).
|
||||
- DPX input now supports IOProxy. #2659 #2665 (2.2.5)
|
||||
- ImageCache (and ImageBuf backed by ImageCache) entries that use IOProxy
|
||||
are careful not to fully "close" their proxies when trying to reclaim
|
||||
space in the file cache (that would be bad, since the proxy can't be
|
||||
re-opened). #2666 (2.2.5)
|
||||
* Improved support for multi-subimage files:
|
||||
- oiiotool: Nearly all operations now allow an optional `:subimages=...`
|
||||
modifier that restricts the operation to be performed on only a subset
|
||||
of named or indexed subimages. See docs for details. #2582
|
||||
- Python `ImageBuf.write()` variety added that takes an open
|
||||
`ImageOutput`. This is the key to writing a multi-subimage file (such
|
||||
as a multi-part OpenEXR) using the Python ImageBuf interface. #2640
|
||||
(2.2.4)
|
||||
* Python bindings:
|
||||
- Python bindings have been added for missing ParamValue constructors.
|
||||
We previously exposed the PV constructors from just a plain int, float,
|
||||
@@ -21,7 +35,7 @@ New major features and public API changes:
|
||||
numpy arrays (previously they had to be tuples). #2437 (2.1.11/2.2.0)
|
||||
- `ImageBufAlgo.color_range_check()` is now available to the Python
|
||||
bindings (was previously only C++). #2602 (2.2.3)
|
||||
- Add a version of `ImageBuf.write()` that takes an open `ImageOutput`.
|
||||
- New variety of `ImageBuf.write()` that takes an open `ImageOutput`.
|
||||
This is the key to writing a multi-subimage file (such as a multi-part
|
||||
OpenEXR) using the Python ImageBuf interface. #2640 (2.2.4)
|
||||
* ImageBuf:
|
||||
@@ -39,10 +53,6 @@ New major features and public API changes:
|
||||
- New `max()` and `min()` functions take the pixel-by-pixel maximum
|
||||
or minimum of two images. #2470 (2.2.1)
|
||||
* ColorConfig: add OCIO "role" accessors. #2548
|
||||
* oiiotool subimage support:
|
||||
- Nearly all operations now allow an optional `:subimages=...`
|
||||
modifier that restricts the operation to be performed on only a subset
|
||||
of named or indexed subimages. See docs for details. #2582
|
||||
* Low-res I/O of images to terminals that support full color and Unicode
|
||||
characters. Just output to a file ending in ".term", and it will convert
|
||||
(on certain terminals) to an image displayed directly in the terminal.
|
||||
@@ -99,6 +109,7 @@ Fixes and feature enhancements:
|
||||
#2487. (2.1.12/2.2.1)
|
||||
- Fix `resize()` to avoid a crash / stack overflow in certain cases of
|
||||
very big images and very large filter kernels. #2643 (2.2.4)
|
||||
- Minor improvements to ImageBuf error formatting. #2653 (2.2.5)
|
||||
* ImageCache / TextureSystem / maketx:
|
||||
- New IC/TS attribute "trust_file_extensions", if nonzero, is a promise
|
||||
that all files can be counted on for their formats to match their
|
||||
@@ -120,6 +131,12 @@ Fixes and feature enhancements:
|
||||
parameters correctly. #2475 (2.1.12)
|
||||
* Fix: iinfo return code now properly indicates failures for files that
|
||||
can't be opened. #2511 (2.2.2/2.1.13)
|
||||
* DPX:
|
||||
- IOProxy reading is now supported. #2659 (2.2.5)
|
||||
* HDR files:
|
||||
- Improve performance when reading HDR files out of order (when combined
|
||||
with ImageCache, observed to speed up out-of-order HDR reading by 18x).
|
||||
#2662 (2.2.5)
|
||||
* JPEG:
|
||||
- Fix resolution unit metadata that was not propery set in JPEG output.
|
||||
#2516 (2.2.2/2.1.13)
|
||||
@@ -133,6 +150,11 @@ Fixes and feature enhancements:
|
||||
"worldtoscreen" and vice versa. #2609 (2.2.4)
|
||||
* PNG:
|
||||
- Fix loss of 'config' info upon close/reopen. #2549 (2.2.2)
|
||||
- Add output configuration hint "png:filter" to control PNG filter
|
||||
options. #2650 (2.2.5)
|
||||
- Improved propagation of PNG write errors. #2655 (2.2.5)
|
||||
- Tell libpng to turn off sRGB profile check, which has a known problem of
|
||||
false positives. #2655 (2.2.5)
|
||||
* Raw images:
|
||||
- Support for new Canon .cr3 file, but only if you build against
|
||||
libraw >= 0.20.0 developer snapshot. #2484 (2.2.1) #2613 (2.2.4)
|
||||
@@ -235,8 +257,10 @@ Developer goodies / internals:
|
||||
but not force a termination. #2435 (2.1.11/2.2.0)
|
||||
* Internals: Replaced most uses of `boost::thread_specific_ptr` with C++11
|
||||
`thread_local`. #2431 (2.2.0)
|
||||
* Python: Fixed a bug that lost certain string arguments, especially when
|
||||
passing a TypeDesc as its string equivalent. #2587 (2.1.16/2.2.3)
|
||||
* Python:
|
||||
- Fixed a bug that lost certain string arguments, especially when passing
|
||||
a TypeDesc as its string equivalent. #2587 (2.1.16/2.2.3)
|
||||
- Fixed broken bindings of ImageSpec.erase_attribute. #2654 (2.2.5)
|
||||
* oiiotool: Big overhaul and simplification of internals. #2586 #2589 (2.2.3)
|
||||
|
||||
Build/test system improvements and platform ports:
|
||||
@@ -279,6 +303,8 @@ Build/test system improvements and platform ports:
|
||||
downloaded and inspected (or used to create new reference output).
|
||||
#2606 (2.2.4)
|
||||
- CI Mac tests switch to Python 3.8. (2.2.4)
|
||||
- Windows CI switched from using Vcpkg to building its own dependencies.
|
||||
#2663 (2.2.5)
|
||||
* Dependency version support:
|
||||
- Pybind11 is no longer auto-downloaded. It is assumed to be
|
||||
pre-installed. A script `src/build-scripts/build_pybind11.bash` is
|
||||
@@ -298,6 +324,10 @@ Build/test system improvements and platform ports:
|
||||
- Support for Qt 5.15. #2605 (2.2.3)
|
||||
- Fixes to support OpenColorIO 2.0. #2636 (2.2.4)
|
||||
- Build against more recent versions of fmtlib. #2639 (2.2.4)
|
||||
- Included scripts to download and build libtiff #2543 (2.1.13/2.2.2),
|
||||
PugiXML #2648 (2.2.4), zlib, libpng, libjpeg-turbo. #2663 (2.2.5)
|
||||
* Add a build_libtiff.bash script to make it easy to build the libtiff
|
||||
dependency. #2543 (2.1.13/2.2.2)
|
||||
* Progress on support for using Conan for dependency installation. This is
|
||||
experimental, it can't yet build all dependencies. Work in progress.
|
||||
#2461 (2.2.1)
|
||||
@@ -332,6 +362,8 @@ Build/test system improvements and platform ports:
|
||||
* Moved headers that are not part of OIIO's supported public API, but that
|
||||
still must be installed to be transitively included, do a "detail"
|
||||
subdirectory. #2648 (2.2.4)
|
||||
* Fix many Mingw compiler warnings. #2657 (2.2.5)
|
||||
* Fix Windows extended length / long paths when opening files. #2662 (2.2.5)
|
||||
|
||||
Notable documentation changes:
|
||||
* Many enhancements in the ImageBuf chapter. #2460 (2.1.11/2.2.0)
|
||||
@@ -412,6 +444,8 @@ Release 2.1.14 (1 May 2020) -- compared to 2.1.13
|
||||
* Fix some problems with the docs. #2541
|
||||
* `AttrDelegate::as_vec<>` returns the whole attribute as a std::vector.
|
||||
#2528
|
||||
* Add a build_libtiff.bash script to make it easy to build the libtiff
|
||||
dependency. #2543
|
||||
|
||||
Release 2.1.13 (1 Apr 2020) -- compared to 2.1.12
|
||||
-------------------------------------------------
|
||||
|
||||
+3
-3
@@ -3,16 +3,16 @@
|
||||
# https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md
|
||||
|
||||
cmake_minimum_required (VERSION 3.12)
|
||||
project (OpenImageIO VERSION 2.2.4.0
|
||||
project (OpenImageIO VERSION 2.2.5.0
|
||||
HOMEPAGE_URL "https://openimageio.org"
|
||||
LANGUAGES CXX C)
|
||||
set (PROJ_NAME OIIO) # short name, caps
|
||||
string (TOLOWER ${PROJ_NAME} PROJ_NAME_LOWER) # short name lower case
|
||||
string (TOUPPER ${PROJ_NAME} PROJ_NAME_UPPER) # short name upper case
|
||||
set (PROJECT_VERSION_RELEASE_TYPE "dev") # "dev", "betaX", "RCY", ""
|
||||
set (PROJECT_VERSION_RELEASE_TYPE "beta2") # "dev", "betaX", "RCY", ""
|
||||
set (${PROJECT_NAME}_VERSION_RELEASE_TYPE ${PROJECT_VERSION_RELEASE_TYPE})
|
||||
set (PROJECT_AUTHORS "Contributors to the OpenImageIO project")
|
||||
set (${PROJECT_NAME}_SUPPORTED_RELEASE 0) # Change to 1 after release branch
|
||||
set (${PROJECT_NAME}_SUPPORTED_RELEASE 1) # Change to 1 after release branch
|
||||
|
||||
# If the user wants to use Conan to build dependencies, they will have done
|
||||
# this prior to the cmake config:
|
||||
|
||||
@@ -20,7 +20,9 @@ lg@openimageio.org
|
||||
* Basileios Anastasatos
|
||||
* Bastien Montagne
|
||||
* Ben De Luca
|
||||
* Biswapriyo Nath
|
||||
* Blair Tennessy
|
||||
* Blazej Floch
|
||||
* Brecht Van Lommel
|
||||
* Brent Davis
|
||||
* Brian Hall
|
||||
@@ -45,6 +47,7 @@ lg@openimageio.org
|
||||
* Dinko Galetik
|
||||
* Dominik Bartkiewicz
|
||||
* Duncan Chan
|
||||
* Dustin Rodrigues
|
||||
* Edgar Velazquez-Armendariz
|
||||
* Eloi Du Bois
|
||||
* Elvic Liang
|
||||
@@ -62,10 +65,12 @@ lg@openimageio.org
|
||||
* Henri Fousse
|
||||
* Harry Mallon
|
||||
* Hugh Macdonald
|
||||
* Imarz
|
||||
* Irena Damsky
|
||||
* Ismael Cortes
|
||||
* Jep Hill
|
||||
* Jeph Alapat
|
||||
* Jens Lindgren
|
||||
* Jeremy Rose
|
||||
* Jeremy Selan
|
||||
* Jim Hourihan
|
||||
@@ -121,6 +126,7 @@ lg@openimageio.org
|
||||
* Philip Nemec
|
||||
* Pino Toscano
|
||||
* Puneet Jain
|
||||
* Radu Arjocu
|
||||
* Ramon Montoya
|
||||
* Ray Molenkamp
|
||||
* Richard Shaw
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
|
||||
### Required dependencies -- OIIO will not build at all without these
|
||||
|
||||
* C++11 (also builds with C++14 and C++17)
|
||||
* Compilers: gcc 4.8.2 - 10.1, clang 3.3 - 10.0, MSVS 2015 - 2019,
|
||||
* Compilers: gcc 4.8.2 - 10.2, clang 3.3 - 10.0, MSVS 2015 - 2019,
|
||||
icc version 13 or higher
|
||||
* CMake >= 3.12 (tested through 3.18)
|
||||
* OpenEXR >= 2.0 (recommended: 2.2 or higher; tested through 2.5)
|
||||
|
||||
@@ -318,6 +318,14 @@ else ifeq (${platform}, macosx)
|
||||
MY_CMAKE_FLAGS += \
|
||||
-DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
|
||||
USE_LIBCPLUSPLUS := 0
|
||||
else ifeq (${COMPILER}, gcc9)
|
||||
MY_CMAKE_FLAGS += \
|
||||
-DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9
|
||||
USE_LIBCPLUSPLUS := 0
|
||||
else ifeq (${COMPILER}, gcc10)
|
||||
MY_CMAKE_FLAGS += \
|
||||
-DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10
|
||||
USE_LIBCPLUSPLUS := 0
|
||||
else ifeq (${COMPILER},clang7)
|
||||
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=/usr/local/opt/llvm@7/bin/clang \
|
||||
-DCMAKE_CXX_COMPILER=/usr/local/llvm@7/bin/clang++
|
||||
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Utility script to download and build libjpeg-turbo
|
||||
#
|
||||
# Copyright Contributors to the OpenImageIO project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/OpenImageIO/oiio
|
||||
|
||||
# Exit the whole script if any command fails.
|
||||
set -ex
|
||||
|
||||
# Repo and branch/tag/commit of libjpeg-turbo to download if we don't have it yet
|
||||
LIBJPEGTURBO_REPO=${LIBJPEGTURBO_REPO:=https://github.com/libjpeg-turbo/libjpeg-turbo.git}
|
||||
LIBJPEGTURBO_VERSION=${LIBJPEGTURBO_VERSION:=2.0.5}
|
||||
|
||||
# Where to put libjpeg-turbo repo source (default to the ext area)
|
||||
LIBJPEGTURBO_SRC_DIR=${LIBJPEGTURBO_SRC_DIR:=${PWD}/ext/libjpeg-turbo}
|
||||
# Temp build area (default to a build/ subdir under source)
|
||||
LIBJPEGTURBO_BUILD_DIR=${LIBJPEGTURBO_BUILD_DIR:=${LIBJPEGTURBO_SRC_DIR}/build}
|
||||
# Install area for libjpeg-turbo (default to ext/dist)
|
||||
LIBJPEGTURBO_INSTALL_DIR=${LIBJPEGTURBO_INSTALL_DIR:=${PWD}/ext/dist}
|
||||
#LIBJPEGTURBO_CONFIG_OPTS=${LIBJPEGTURBO_CONFIG_OPTS:=}
|
||||
|
||||
pwd
|
||||
echo "libjpeg-turbo install dir will be: ${LIBJPEGTURBO_INSTALL_DIR}"
|
||||
|
||||
mkdir -p ./ext
|
||||
pushd ./ext
|
||||
|
||||
# Clone libjpeg-turbo project from GitHub and build
|
||||
if [[ ! -e ${LIBJPEGTURBO_SRC_DIR} ]] ; then
|
||||
echo "git clone ${LIBJPEGTURBO_REPO} ${LIBJPEGTURBO_SRC_DIR}"
|
||||
git clone ${LIBJPEGTURBO_REPO} ${LIBJPEGTURBO_SRC_DIR}
|
||||
fi
|
||||
cd ${LIBJPEGTURBO_SRC_DIR}
|
||||
echo "git checkout ${LIBJPEGTURBO_VERSION} --force"
|
||||
git checkout ${LIBJPEGTURBO_VERSION} --force
|
||||
|
||||
mkdir -p ${LIBJPEGTURBO_BUILD_DIR}
|
||||
cd ${LIBJPEGTURBO_BUILD_DIR}
|
||||
time cmake --config Release \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=${LIBJPEGTURBO_INSTALL_DIR} \
|
||||
${LIBJPEGTURBO_CONFIG_OPTS} ..
|
||||
time cmake --build . --config Release --target install
|
||||
|
||||
ls -R ${LIBJPEGTURBO_INSTALL_DIR}
|
||||
popd
|
||||
|
||||
|
||||
# Set up paths. These will only affect the caller if this script is
|
||||
# run with 'source' rather than in a separate shell.
|
||||
export JPEGTurbo_ROOT=$LIBJPEGTURBO_INSTALL_DIR
|
||||
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Utility script to download and build libpng
|
||||
#
|
||||
# Copyright Contributors to the OpenImageIO project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/OpenImageIO/oiio
|
||||
|
||||
# Exit the whole script if any command fails.
|
||||
set -ex
|
||||
|
||||
# Repo and branch/tag/commit of libpng to download if we don't have it yet
|
||||
LIBPNG_REPO=${LIBPNG_REPO:=https://github.com/glennrp/libpng.git}
|
||||
LIBPNG_VERSION=${LIBPNG_VERSION:=v1.6.35}
|
||||
|
||||
# Where to put libpng repo source (default to the ext area)
|
||||
LIBPNG_SRC_DIR=${LIBPNG_SRC_DIR:=${PWD}/ext/libpng}
|
||||
# Temp build area (default to a build/ subdir under source)
|
||||
LIBPNG_BUILD_DIR=${LIBPNG_BUILD_DIR:=${LIBPNG_SRC_DIR}/build}
|
||||
# Install area for libpng (default to ext/dist)
|
||||
LIBPNG_INSTALL_DIR=${LIBPNG_INSTALL_DIR:=${PWD}/ext/dist}
|
||||
#LIBPNG_CONFIG_OPTS=${LIBPNG_CONFIG_OPTS:=}
|
||||
|
||||
pwd
|
||||
echo "libpng install dir will be: ${LIBPNG_INSTALL_DIR}"
|
||||
|
||||
mkdir -p ./ext
|
||||
pushd ./ext
|
||||
|
||||
# Clone libpng project from GitHub and build
|
||||
if [[ ! -e ${LIBPNG_SRC_DIR} ]] ; then
|
||||
echo "git clone ${LIBPNG_REPO} ${LIBPNG_SRC_DIR}"
|
||||
git clone ${LIBPNG_REPO} ${LIBPNG_SRC_DIR}
|
||||
fi
|
||||
cd ${LIBPNG_SRC_DIR}
|
||||
echo "git checkout ${LIBPNG_VERSION} --force"
|
||||
git checkout ${LIBPNG_VERSION} --force
|
||||
|
||||
mkdir -p ${LIBPNG_BUILD_DIR}
|
||||
cd ${LIBPNG_BUILD_DIR}
|
||||
time cmake --config Release \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=${LIBPNG_INSTALL_DIR} \
|
||||
-DPNG_EXECUTABLES=OFF \
|
||||
-DPNG_TESTS=OFF \
|
||||
${LIBPNG_CONFIG_OPTS} ..
|
||||
time cmake --build . --config Release --target install
|
||||
|
||||
ls -R ${LIBPNG_INSTALL_DIR}
|
||||
popd
|
||||
|
||||
|
||||
# Set up paths. These will only affect the caller if this script is
|
||||
# run with 'source' rather than in a separate shell.
|
||||
export PNG_ROOT=$LIBPNG_INSTALL_DIR
|
||||
|
||||
@@ -8,10 +8,11 @@ set -ex
|
||||
LIBTIFF_REPO=${LIBTIFF_REPO:=https://gitlab.com/libtiff/libtiff.git}
|
||||
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
|
||||
LIBTIFF_BUILD_DIR=${LIBTIFF_BUILD_DIR:=${LOCAL_DEPS_DIR}/libtiff}
|
||||
LIBTIFF_INSTALL_DIR=${LIBTIFF_INSTALL_DIR:=${LOCAL_DEPS_DIR}/libtiff/dist}
|
||||
LIBTIFF_VERSION=${LIBTIFF_VERSION:=4.1.0}
|
||||
LIBTIFF_BRANCH=${LIBTIFF_BRANCH:=v${LIBTIFF_VERSION}}
|
||||
LIBTIFF_CXX_FLAGS=${LIBTIFF_CXX_FLAGS:="-Wno-unused-function -Wno-deprecated-declarations -Wno-cast-qual -Wno-write-strings"}
|
||||
LIBTIFF_INSTALL_DIR=${LIBTIFF_INSTALL_DIR:=${PWD}/ext/dist}
|
||||
LIBTIFF_VERSION=${LIBTIFF_VERSION:=v4.1.0}
|
||||
if [[ `uname` == `Linux` ]] ; then
|
||||
LIBTIFF_CXX_FLAGS=${LIBTIFF_CXX_FLAGS:="-O3 -Wno-unused-function -Wno-deprecated-declarations -Wno-cast-qual -Wno-write-strings"}
|
||||
fi
|
||||
LIBTIFF_BUILDOPTS="${LIBTIFF_BUILDOPTS}"
|
||||
BASEDIR=`pwd`
|
||||
pwd
|
||||
@@ -27,11 +28,15 @@ if [[ ! -e libtiff ]] ; then
|
||||
fi
|
||||
cd libtiff
|
||||
|
||||
echo "git checkout ${LIBTIFF_BRANCH} --force"
|
||||
git checkout ${LIBTIFF_BRANCH} --force
|
||||
echo "git checkout ${LIBTIFF_VERSION} --force"
|
||||
git checkout ${LIBTIFF_VERSION} --force
|
||||
mkdir -p build
|
||||
cd build
|
||||
time cmake --config Release -DCMAKE_INSTALL_PREFIX=${LIBTIFF_INSTALL_DIR} -DCMAKE_CXX_FLAGS="${LIBTIFF_CXX_FLAGS}" ${LIBTIFF_BUILDOPTS} ..
|
||||
time cmake --config Release \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=${LIBTIFF_INSTALL_DIR} \
|
||||
-DCMAKE_CXX_FLAGS="${LIBTIFF_CXX_FLAGS}" \
|
||||
${LIBTIFF_BUILDOPTS} ..
|
||||
time cmake --build . --config Release --target install
|
||||
popd
|
||||
|
||||
|
||||
@@ -7,14 +7,13 @@ set -ex
|
||||
|
||||
# Which OpenEXR to retrieve, how to build it
|
||||
OPENEXR_REPO=${OPENEXR_REPO:=https://github.com/openexr/openexr.git}
|
||||
OPENEXR_VERSION=${OPENEXR_VERSION:=2.4.1}
|
||||
OPENEXR_BRANCH=${OPENEXR_BRANCH:=v${OPENEXR_VERSION}}
|
||||
OPENEXR_VERSION=${OPENEXR_VERSION:=v2.4.1}
|
||||
|
||||
# Where to install the final results
|
||||
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
|
||||
OPENEXR_SOURCE_DIR=${OPENEXR_SOURCE_DIR:=${LOCAL_DEPS_DIR}/openexr}
|
||||
OPENEXR_BUILD_DIR=${OPENEXR_BUILD_DIR:=${LOCAL_DEPS_DIR}/openexr-build}
|
||||
OPENEXR_INSTALL_DIR=${OPENEXR_INSTALL_DIR:=${LOCAL_DEPS_DIR}/openexr-install}
|
||||
OPENEXR_INSTALL_DIR=${OPENEXR_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
|
||||
OPENEXR_BUILD_TYPE=${OPENEXR_BUILD_TYPE:=Release}
|
||||
CMAKE_GENERATOR=${CMAKE_GENERATOR:="Unix Makefiles"}
|
||||
OPENEXR_CMAKE_FLAGS=${OPENEXR_CMAKE_FLAGS:=""}
|
||||
@@ -22,7 +21,7 @@ OPENEXR_CXX_FLAGS=${OPENEXR_CXX_FLAGS:=""}
|
||||
BASEDIR=$PWD
|
||||
|
||||
pwd
|
||||
echo "Building OpenEXR ${OPENEXR_BRANCH}"
|
||||
echo "Building OpenEXR ${OPENEXR_VERSION}"
|
||||
echo "EXR build dir will be: ${OPENEXR_BUILD_DIR}"
|
||||
echo "EXR install dir will be: ${OPENEXR_INSTALL_DIR}"
|
||||
echo "CMAKE_PREFIX_PATH is ${CMAKE_PREFIX_PATH}"
|
||||
@@ -42,9 +41,9 @@ mkdir -p ${OPENEXR_INSTALL_DIR} && true
|
||||
mkdir -p ${OPENEXR_BUILD_DIR} && true
|
||||
|
||||
pushd ${OPENEXR_SOURCE_DIR}
|
||||
git checkout ${OPENEXR_BRANCH} --force
|
||||
git checkout ${OPENEXR_VERSION} --force
|
||||
|
||||
if [[ ${OPENEXR_BRANCH} == "v2.2.0" ]] || [[ ${OPENEXR_BRANCH} == "v2.2.1" ]] ; then
|
||||
if [[ ${OPENEXR_VERSION} == "v2.2.0" ]] || [[ ${OPENEXR_VERSION} == "v2.2.1" ]] ; then
|
||||
mkdir -p ${OPENEXR_BUILD_DIR}/IlmBase && true
|
||||
mkdir -p ${OPENEXR_BUILD_DIR}/OpenEXR && true
|
||||
cd ${OPENEXR_BUILD_DIR}/IlmBase
|
||||
@@ -62,7 +61,7 @@ if [[ ${OPENEXR_BRANCH} == "v2.2.0" ]] || [[ ${OPENEXR_BRANCH} == "v2.2.1" ]] ;
|
||||
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
|
||||
${OPENEXR_CMAKE_FLAGS} ${OPENEXR_SOURCE_DIR}/OpenEXR
|
||||
time cmake --build . --target install --config ${OPENEXR_BUILD_TYPE}
|
||||
elif [[ ${OPENEXR_BRANCH} == "v2.3.0" ]] ; then
|
||||
elif [[ ${OPENEXR_VERSION} == "v2.3.0" ]] ; then
|
||||
# Simplified setup for 2.3+
|
||||
cd ${OPENEXR_BUILD_DIR}
|
||||
cmake --config ${OPENEXR_BUILD_TYPE} -G "$CMAKE_GENERATOR" \
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# Copyright Contributors to the OpenImageIO project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/imageworks/OpenShadingLanguage
|
||||
# https://github.com/OpenImageIO/oiio
|
||||
|
||||
# Exit the whole script if any command fails.
|
||||
set -ex
|
||||
|
||||
@@ -7,8 +7,7 @@ set -ex
|
||||
|
||||
# Repo and branch/tag/commit of pybind11 to download if we don't have it yet
|
||||
PYBIND11_REPO=${PYBIND11_REPO:=https://github.com/pybind/pybind11.git}
|
||||
PYBIND11_VERSION=${PYBIND11_VERSION:=2.4.3}
|
||||
PYBIND11_BRANCH=${PYBIND11_BRANCH:=v${PYBIND11_VERSION}}
|
||||
PYBIND11_VERSION=${PYBIND11_VERSION:=v2.4.3}
|
||||
|
||||
# Where to put pybind11 repo source (default to the ext area)
|
||||
PYBIND11_SRC_DIR=${PYBIND11_SRC_DIR:=${PWD}/ext/pybind11}
|
||||
@@ -35,8 +34,8 @@ if [[ ! -e ${PYBIND11_SRC_DIR} ]] ; then
|
||||
git clone ${PYBIND11_REPO} ${PYBIND11_SRC_DIR}
|
||||
fi
|
||||
cd ${PYBIND11_SRC_DIR}
|
||||
echo "git checkout ${PYBIND11_BRANCH} --force"
|
||||
git checkout ${PYBIND11_BRANCH} --force
|
||||
echo "git checkout ${PYBIND11_VERSION} --force"
|
||||
git checkout ${PYBIND11_VERSION} --force
|
||||
|
||||
mkdir -p ${PYBIND11_BUILD_DIR}
|
||||
cd ${PYBIND11_BUILD_DIR}
|
||||
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Utility script to download and build zlib
|
||||
#
|
||||
# Copyright Contributors to the OpenImageIO project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/OpenImageIO/oiio
|
||||
|
||||
# Exit the whole script if any command fails.
|
||||
set -ex
|
||||
|
||||
# Repo and branch/tag/commit of zlib to download if we don't have it yet
|
||||
ZLIB_REPO=${ZLIB_REPO:=https://github.com/madler/zlib.git}
|
||||
ZLIB_VERSION=${ZLIB_VERSION:=v1.2.11}
|
||||
|
||||
# Where to put zlib repo source (default to the ext area)
|
||||
ZLIB_SRC_DIR=${ZLIB_SRC_DIR:=${PWD}/ext/zlib}
|
||||
# Temp build area (default to a build/ subdir under source)
|
||||
ZLIB_BUILD_DIR=${ZLIB_BUILD_DIR:=${ZLIB_SRC_DIR}/build}
|
||||
# Install area for zlib (default to ext/dist)
|
||||
ZLIB_INSTALL_DIR=${ZLIB_INSTALL_DIR:=${PWD}/ext/dist}
|
||||
#ZLIB_CONFIG_OPTS=${ZLIB_CONFIG_OPTS:=}
|
||||
|
||||
pwd
|
||||
echo "zlib install dir will be: ${ZLIB_INSTALL_DIR}"
|
||||
|
||||
mkdir -p ./ext
|
||||
pushd ./ext
|
||||
|
||||
# Clone zlib project from GitHub and build
|
||||
if [[ ! -e ${ZLIB_SRC_DIR} ]] ; then
|
||||
echo "git clone ${ZLIB_REPO} ${ZLIB_SRC_DIR}"
|
||||
git clone ${ZLIB_REPO} ${ZLIB_SRC_DIR}
|
||||
fi
|
||||
cd ${ZLIB_SRC_DIR}
|
||||
echo "git checkout ${ZLIB_VERSION} --force"
|
||||
git checkout ${ZLIB_VERSION} --force
|
||||
|
||||
mkdir -p ${ZLIB_BUILD_DIR} && true
|
||||
cd ${ZLIB_BUILD_DIR}
|
||||
time cmake --config Release \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=${ZLIB_INSTALL_DIR} \
|
||||
${ZLIB_CONFIG_OPTS} ..
|
||||
time cmake --build . --config Release --target install
|
||||
|
||||
ls -R ${ZLIB_INSTALL_DIR}
|
||||
popd
|
||||
|
||||
|
||||
# Set up paths. These will only affect the caller if this script is
|
||||
# run with 'source' rather than in a separate shell.
|
||||
export ZLIB_ROOT=$ZLIB_INSTALL_DIR
|
||||
|
||||
@@ -40,17 +40,16 @@ if [[ "$BUILDTARGET" != "none" ]] ; then
|
||||
time cmake --build . --target ${BUILDTARGET:=install} --config ${CMAKE_BUILD_TYPE}
|
||||
fi
|
||||
popd
|
||||
#make $MAKEFLAGS VERBOSE=1 $BUILD_FLAGS config
|
||||
#make $MAKEFLAGS $PAR_MAKEFLAGS $BUILD_FLAGS $BUILDTARGET
|
||||
|
||||
#echo "OpenImageIO_ROOT $OpenImageIO_ROOT"
|
||||
#ls -R -l "$OpenImageIO_ROOT"
|
||||
|
||||
if [[ "${SKIP_TESTS:=0}" == "0" ]] ; then
|
||||
$OpenImageIO_ROOT/bin/oiiotool --help || true
|
||||
TESTSUITE_CLEANUP_ON_SUCCESS=1
|
||||
echo "Parallel test " ${CTEST_PARALLEL_LEVEL}
|
||||
make $BUILD_FLAGS test
|
||||
# make $BUILD_FLAGS test
|
||||
pushd build/$PLATFORM
|
||||
ctest -C ${CMAKE_BUILD_TYPE} -E broken --force-new-ctest-process --output-on-failure
|
||||
popd
|
||||
fi
|
||||
|
||||
if [[ "$BUILDTARGET" == clang-format ]] ; then
|
||||
|
||||
@@ -14,6 +14,7 @@ fi
|
||||
# DEP_DIR="$PWD/ext/dist"
|
||||
DEP_DIR="$PWD/dist/$PLATFORM"
|
||||
mkdir -p "$DEP_DIR"
|
||||
mkdir -p ext && true
|
||||
INT_DIR="build/$PLATFORM"
|
||||
VCPKG_INSTALLATION_ROOT=/c/vcpkg
|
||||
|
||||
@@ -32,60 +33,77 @@ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DEP_DIR/lib:$VCPKG_INSTALLATION_ROOT/i
|
||||
ls -l "C:/Program Files (x86)/Microsoft Visual Studio/*/Enterprise/VC/Tools/MSVC" && true
|
||||
ls -l "C:/Program Files (x86)/Microsoft Visual Studio" && true
|
||||
|
||||
vcpkg list
|
||||
vcpkg update
|
||||
|
||||
# vcpkg install zlib:x64-windows
|
||||
vcpkg install tiff:x64-windows
|
||||
vcpkg install libpng:x64-windows
|
||||
vcpkg install giflib:x64-windows
|
||||
vcpkg install freetype:x64-windows
|
||||
# vcpkg install openexr:x64-windows
|
||||
# vcpkg install libjpeg-turbo:x64-windows
|
||||
########################################################################
|
||||
# Dependency method #1: Use vcpkg (disabled)
|
||||
#
|
||||
# Currently we are not using this, but here it is for reference:
|
||||
#
|
||||
# vcpkg list
|
||||
# vcpkg update
|
||||
#
|
||||
# # vcpkg install zlib:x64-windows
|
||||
# vcpkg install tiff:x64-windows
|
||||
# vcpkg install libpng:x64-windows
|
||||
# vcpkg install giflib:x64-windows
|
||||
# vcpkg install freetype:x64-windows
|
||||
# # vcpkg install openexr:x64-windows
|
||||
# # vcpkg install libjpeg-turbo:x64-windows
|
||||
#
|
||||
# vcpkg install libraw:x64-windows
|
||||
# vcpkg install openjpeg:x64-windows
|
||||
# vcpkg install libsquish:x64-windows
|
||||
# # vcpkg install ffmpeg:x64-windows # takes FOREVER!
|
||||
# # vcpkg install webp:x64-windows # No such vcpkg package?a
|
||||
#
|
||||
# #echo "$VCPKG_INSTALLATION_ROOT"
|
||||
# #ls "$VCPKG_INSTALLATION_ROOT"
|
||||
# #echo "$VCPKG_INSTALLATION_ROOT/installed/x64-windows"
|
||||
# #ls "$VCPKG_INSTALLATION_ROOT/installed/x64-windows"
|
||||
# #echo "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
|
||||
# #ls "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
|
||||
# #echo "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
|
||||
# #ls "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
|
||||
#
|
||||
# # export PATH="$PATH:$DEP_DIR/bin:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
|
||||
# export PATH="$DEP_DIR/lib:$DEP_DIR/bin:$PATH:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
|
||||
# export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib:$DEP_DIR/lib:$DEP_DIR/bin"
|
||||
#
|
||||
# echo "All VCPkg installs:"
|
||||
# vcpkg list
|
||||
#
|
||||
########################################################################
|
||||
|
||||
vcpkg install libraw:x64-windows
|
||||
vcpkg install openjpeg:x64-windows
|
||||
vcpkg install libsquish:x64-windows
|
||||
# vcpkg install ffmpeg:x64-windows # takes FOREVER!
|
||||
# vcpkg install webp:x64-windows # No such vcpkg package?a
|
||||
|
||||
echo "$VCPKG_INSTALLATION_ROOT"
|
||||
ls "$VCPKG_INSTALLATION_ROOT"
|
||||
echo "$VCPKG_INSTALLATION_ROOT/installed/x64-windows"
|
||||
ls "$VCPKG_INSTALLATION_ROOT/installed/x64-windows"
|
||||
echo "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
|
||||
ls "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
|
||||
echo "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
|
||||
ls "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
|
||||
########################################################################
|
||||
# Dependency method #2: Build from source ourselves
|
||||
#
|
||||
#
|
||||
|
||||
src/build-scripts/build_zlib.bash
|
||||
export ZLIB_ROOT=$PWD/ext/dist
|
||||
|
||||
src/build-scripts/build_libpng.bash
|
||||
export PNG_ROOT=$PWD/ext/dist
|
||||
|
||||
src/build-scripts/build_libtiff.bash
|
||||
export TIFF_ROOT=$PWD/ext/dist
|
||||
|
||||
LIBJPEGTURBO_CONFIG_OPTS=-DWITH_SIMD=OFF
|
||||
# ^^ because we're too lazy to build nasm
|
||||
src/build-scripts/build_libjpeg-turbo.bash
|
||||
export JPEGTurbo_ROOT=$PWD/ext/dist
|
||||
|
||||
source src/build-scripts/build_pybind11.bash
|
||||
#export pybind11_ROOT=$PWD/ext/dist
|
||||
|
||||
echo "All VCPkg installs:"
|
||||
vcpkg list
|
||||
|
||||
# curl --location https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-4.2.1-win64-shared.zip -o ffmpeg-libs.zip
|
||||
# unzip ffmpeg-libs.zip
|
||||
curl --location https://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-4.2.1-win64-dev.zip -o ffmpeg-dev.zip
|
||||
unzip ffmpeg-dev.zip
|
||||
ls
|
||||
ls -R *ffmpeg*
|
||||
FFmpeg_ROOT=$PWD/ffmpeg-4.2.1-win64-dev
|
||||
|
||||
echo "CMAKE_PREFIX_PATH = $CMAKE_PREFIX_PATH"
|
||||
|
||||
mkdir ext
|
||||
|
||||
# ZLib
|
||||
pushd ext
|
||||
git clone -b v1.2.11 https://github.com/madler/zlib.git
|
||||
cd zlib
|
||||
mkdir -p $INT_DIR
|
||||
cd $INT_DIR
|
||||
cmake ../.. -G "$CMAKE_GENERATOR" -DCMAKE_CONFIGURATION_TYPES="$CMAKE_BUILD_TYPE" -DCMAKE_PREFIX_PATH="$DEP_DIR" -DCMAKE_INSTALL_PREFIX="$DEP_DIR"
|
||||
cmake --build . --config $CMAKE_BUILD_TYPE --target install
|
||||
popd
|
||||
export MY_CMAKE_FLAGS="$MY_CMAKE_FLAGS -DZLIB_LIBRARY=$DEP_DIR/lib/zlib.lib"
|
||||
export OPENEXR_CMAKE_FLAGS="$OPENEXR_CMAKE_FLAGS -DZLIB_LIBRARY=$DEP_DIR/lib/zlib.lib"
|
||||
|
||||
source src/build-scripts/build_pybind11.bash
|
||||
|
||||
OPENEXR_CXX_FLAGS=" /W1 /EHsc /DWIN32=1 "
|
||||
#OPENEXR_BUILD_TYPE=$CMAKE_BUILD_TYPE
|
||||
@@ -102,10 +120,6 @@ echo "DEP_DIR $DEP_DIR :"
|
||||
ls -R -l "$DEP_DIR"
|
||||
|
||||
|
||||
# export PATH="$PATH:$DEP_DIR/bin:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
|
||||
export PATH="$DEP_DIR/lib:$DEP_DIR/bin:$PATH:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib:$DEP_DIR/lib:$DEP_DIR/bin"
|
||||
|
||||
src/build-scripts/install_test_images.bash
|
||||
|
||||
ls /c/hostedtoolcache/windows/Python
|
||||
|
||||
@@ -223,40 +223,40 @@ CineonInput::open(const std::string& name, ImageSpec& newspec)
|
||||
// per-file attribs
|
||||
#define CINEON_SET_ATTRIB_S(x, n, s) m_spec.attribute(s, m_cin.header.x(n))
|
||||
#define CINEON_SET_ATTRIB(x, n) CINEON_SET_ATTRIB_S(x, n, "cineon:" #x)
|
||||
#define CINEON_SET_ATTRIB_BYTE(x) \
|
||||
if (m_cin.header.x() != 0xFF) \
|
||||
#define CINEON_SET_ATTRIB_BYTE(x) \
|
||||
if (m_cin.header.x() != 0xFF) \
|
||||
CINEON_SET_ATTRIB(x, )
|
||||
#define CINEON_SET_ATTRIB_INT(x) \
|
||||
if (static_cast<unsigned int>(m_cin.header.x()) != 0xFFFFFFFF) \
|
||||
#define CINEON_SET_ATTRIB_INT(x) \
|
||||
if (static_cast<unsigned int>(m_cin.header.x()) != 0xFFFFFFFF) \
|
||||
CINEON_SET_ATTRIB(x, )
|
||||
#define CINEON_SET_ATTRIB_FLOAT(x) \
|
||||
if (!std::isinf(m_cin.header.x())) \
|
||||
#define CINEON_SET_ATTRIB_FLOAT(x) \
|
||||
if (!std::isinf(m_cin.header.x())) \
|
||||
CINEON_SET_ATTRIB(x, )
|
||||
#define CINEON_SET_ATTRIB_COORDS(x) \
|
||||
m_cin.header.x(floats); \
|
||||
if (!std::isinf(floats[0]) && !std::isinf(floats[1]) \
|
||||
&& !(floats[0] == 0. && floats[1] == 0.)) \
|
||||
#define CINEON_SET_ATTRIB_COORDS(x) \
|
||||
m_cin.header.x(floats); \
|
||||
if (!std::isinf(floats[0]) && !std::isinf(floats[1]) \
|
||||
&& !(floats[0] == 0. && floats[1] == 0.)) \
|
||||
m_spec.attribute("cineon:" #x, TypeDesc(TypeDesc::FLOAT, 2), &floats[0])
|
||||
#define CINEON_SET_ATTRIB_STR(X, x) \
|
||||
if (m_cin.header.x[0] && m_cin.header.x[0] != char(-1)) \
|
||||
#define CINEON_SET_ATTRIB_STR(X, x) \
|
||||
if (m_cin.header.x[0] && m_cin.header.x[0] != char(-1)) \
|
||||
m_spec.attribute("cineon:" #X, m_cin.header.x)
|
||||
|
||||
// per-element attribs
|
||||
#define CINEON_SET_ATTRIB_N(x, a, t, c) \
|
||||
for (int i = 0; i < m_cin.header.NumberOfElements(); i++) { \
|
||||
c(x) a[i] = m_cin.header.x(i); \
|
||||
} \
|
||||
m_spec.attribute("cineon:" #x, \
|
||||
TypeDesc(TypeDesc::t, m_cin.header.NumberOfElements()), \
|
||||
#define CINEON_SET_ATTRIB_N(x, a, t, c) \
|
||||
for (int i = 0; i < m_cin.header.NumberOfElements(); i++) { \
|
||||
c(x) a[i] = m_cin.header.x(i); \
|
||||
} \
|
||||
m_spec.attribute("cineon:" #x, \
|
||||
TypeDesc(TypeDesc::t, m_cin.header.NumberOfElements()), \
|
||||
&a)
|
||||
#define CINEON_CHECK_ATTRIB_FLOAT(x) if (!std::isinf(m_cin.header.x(i)))
|
||||
#define CINEON_SET_ATTRIB_FLOAT_N(x) \
|
||||
#define CINEON_SET_ATTRIB_FLOAT_N(x) \
|
||||
CINEON_SET_ATTRIB_N(x, floats, FLOAT, CINEON_CHECK_ATTRIB_FLOAT)
|
||||
#define CINEON_CHECK_ATTRIB_INT(x) if (m_cin.header.x(i) != 0xFFFFFFFF)
|
||||
#define CINEON_SET_ATTRIB_INT_N(x) \
|
||||
#define CINEON_SET_ATTRIB_INT_N(x) \
|
||||
CINEON_SET_ATTRIB_N(x, ints, UINT32, CINEON_CHECK_ATTRIB_INT)
|
||||
#define CINEON_CHECK_ATTRIB_BYTE(x) if (m_cin.header.x(i) != 0xFF)
|
||||
#define CINEON_SET_ATTRIB_BYTE_N(x) \
|
||||
#define CINEON_SET_ATTRIB_BYTE_N(x) \
|
||||
CINEON_SET_ATTRIB_N(x, ints, UINT32, CINEON_CHECK_ATTRIB_BYTE)
|
||||
|
||||
CINEON_SET_ATTRIB_STR(Version, version);
|
||||
|
||||
@@ -141,8 +141,8 @@ DDSInput::open(const std::string& name, ImageSpec& newspec)
|
||||
// due to struct packing, we may get a corrupt header if we just load the
|
||||
// struct from file; to adress that, read every member individually
|
||||
// save some typing
|
||||
#define RH(memb) \
|
||||
if (!fread(&m_dds.memb, sizeof(m_dds.memb), 1)) \
|
||||
#define RH(memb) \
|
||||
if (!fread(&m_dds.memb, sizeof(m_dds.memb), 1)) \
|
||||
return false
|
||||
|
||||
RH(fourCC);
|
||||
|
||||
@@ -1187,6 +1187,14 @@ control aspects of the writing itself:
|
||||
- Compression level for zip/deflate compression, on a scale from 0
|
||||
(fastest, minimal compression) to 9 (slowest, maximal compression).
|
||||
The default is 6. PNG compression is always lossless.
|
||||
* - ``png:filter``
|
||||
- int
|
||||
- Controls the "row filters" that prepare the image for optimal
|
||||
compression. The default is 0 (``PNG_NO_FILTERS``), but other values
|
||||
(which may be "or-ed" or summed to combine their effects) are 8
|
||||
(``PNG_FILTER_NONE``), 16 (``PNG_FILTER_SUB``), 32
|
||||
(``PNG_FILTER_UP``), 64 (``PNG_FILTER_AVG``), or 128
|
||||
(``PNG_FILTER_PAETH``).
|
||||
* - ``oiio:ioproxy``
|
||||
- ptr
|
||||
- Pointer to a ``Filesystem::IOProxy`` that will handle the I/O, for
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
#include <memory>
|
||||
|
||||
#include <OpenEXR/ImfTimeCode.h> //For TimeCode support
|
||||
|
||||
@@ -24,6 +25,10 @@ public:
|
||||
DPXInput() { init(); }
|
||||
virtual ~DPXInput() { close(); }
|
||||
virtual const char* format_name(void) const override { return "dpx"; }
|
||||
virtual int supports(string_view feature) const override
|
||||
{
|
||||
return (feature == "ioproxy");
|
||||
}
|
||||
virtual bool valid_file(const std::string& filename) const override;
|
||||
virtual bool open(const std::string& name, ImageSpec& newspec) override;
|
||||
virtual bool open(const std::string& name, ImageSpec& newspec,
|
||||
@@ -35,6 +40,11 @@ public:
|
||||
void* data) override;
|
||||
virtual bool read_native_scanlines(int subimage, int miplevel, int ybegin,
|
||||
int yend, int z, void* data) override;
|
||||
virtual bool set_ioproxy(Filesystem::IOProxy* ioproxy) override
|
||||
{
|
||||
m_io = ioproxy;
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_subimage;
|
||||
@@ -43,6 +53,9 @@ private:
|
||||
std::vector<unsigned char> m_userBuf;
|
||||
bool m_rawcolor;
|
||||
std::vector<unsigned char> m_decodebuf; // temporary decode buffer
|
||||
std::unique_ptr<Filesystem::IOProxy> m_io_local;
|
||||
Filesystem::IOProxy* m_io = nullptr;
|
||||
int64_t m_io_offset = 0;
|
||||
|
||||
/// Reset everything to initial state
|
||||
///
|
||||
@@ -50,12 +63,13 @@ private:
|
||||
{
|
||||
m_subimage = -1;
|
||||
if (m_stream) {
|
||||
m_stream->Close();
|
||||
delete m_stream;
|
||||
m_stream = nullptr;
|
||||
m_dpx.SetInStream(nullptr);
|
||||
}
|
||||
m_userBuf.clear();
|
||||
m_rawcolor = false;
|
||||
m_io = nullptr;
|
||||
}
|
||||
|
||||
/// Helper function - retrieve string for libdpx characteristic
|
||||
@@ -103,18 +117,19 @@ OIIO_PLUGIN_EXPORTS_END
|
||||
bool
|
||||
DPXInput::valid_file(const std::string& filename) const
|
||||
{
|
||||
InStream* stream = new InStream();
|
||||
if (!stream)
|
||||
Filesystem::IOProxy* io
|
||||
= new Filesystem::IOFile(filename, Filesystem::IOProxy::Mode::Read);
|
||||
std::unique_ptr<Filesystem::IOProxy> io_uptr(io);
|
||||
if (!io || io->mode() != Filesystem::IOProxy::Mode::Read)
|
||||
return false;
|
||||
bool ok = false;
|
||||
if (stream->Open(filename.c_str())) {
|
||||
dpx::Reader dpx;
|
||||
dpx.SetInStream(stream);
|
||||
ok = dpx.ReadHeader();
|
||||
stream->Close();
|
||||
}
|
||||
delete stream;
|
||||
return ok;
|
||||
|
||||
std::unique_ptr<InStream> stream_uptr(new InStream(io));
|
||||
if (!stream_uptr)
|
||||
return false;
|
||||
|
||||
dpx::Reader dpx;
|
||||
dpx.SetInStream(stream_uptr.get());
|
||||
return dpx.ReadHeader(); // IOFile is automatically closed when destructed
|
||||
}
|
||||
|
||||
|
||||
@@ -122,9 +137,19 @@ DPXInput::valid_file(const std::string& filename) const
|
||||
bool
|
||||
DPXInput::open(const std::string& name, ImageSpec& newspec)
|
||||
{
|
||||
// open the image
|
||||
m_stream = new InStream();
|
||||
if (!m_stream->Open(name.c_str())) {
|
||||
if (!m_io) {
|
||||
// If no proxy was supplied, create a file reader
|
||||
m_io = new Filesystem::IOFile(name, Filesystem::IOProxy::Mode::Read);
|
||||
m_io_local.reset(m_io);
|
||||
}
|
||||
if (!m_io || m_io->mode() != Filesystem::IOProxy::Mode::Read) {
|
||||
errorf("Could not open file \"%s\"", name);
|
||||
return false;
|
||||
}
|
||||
m_io_offset = m_io->tell();
|
||||
|
||||
m_stream = new InStream(m_io);
|
||||
if (!m_stream) {
|
||||
errorf("Could not open file \"%s\"", name);
|
||||
return false;
|
||||
}
|
||||
@@ -154,6 +179,9 @@ DPXInput::open(const std::string& name, ImageSpec& newspec,
|
||||
m_rawcolor = config.get_int_attribute("dpx:RawColor")
|
||||
|| config.get_int_attribute("dpx:RawData") // deprecated
|
||||
|| config.get_int_attribute("oiio:RawColor");
|
||||
auto ioparam = config.find_attribute("oiio:ioproxy", TypeDesc::PTR);
|
||||
if (ioparam)
|
||||
m_io = ioparam->get<Filesystem::IOProxy*>();
|
||||
return open(name, newspec);
|
||||
}
|
||||
|
||||
@@ -371,24 +399,24 @@ DPXInput::seek_subimage(int subimage, int miplevel)
|
||||
// set without checking for bogus attributes
|
||||
#define DPX_SET_ATTRIB_N(x) DPX_SET_ATTRIB(x, subimage)
|
||||
// set with checking for bogus attributes
|
||||
#define DPX_SET_ATTRIB_BYTE(x) \
|
||||
if (m_dpx.header.x() != 0xFF) \
|
||||
#define DPX_SET_ATTRIB_BYTE(x) \
|
||||
if (m_dpx.header.x() != 0xFF) \
|
||||
DPX_SET_ATTRIB(x, )
|
||||
#define DPX_SET_ATTRIB_INT_N(x) \
|
||||
if (m_dpx.header.x(subimage) != 0xFFFFFFFF) \
|
||||
#define DPX_SET_ATTRIB_INT_N(x) \
|
||||
if (m_dpx.header.x(subimage) != 0xFFFFFFFF) \
|
||||
DPX_SET_ATTRIB(x, subimage)
|
||||
#define DPX_SET_ATTRIB_INT(x) \
|
||||
if (m_dpx.header.x() != 0xFFFFFFFF) \
|
||||
#define DPX_SET_ATTRIB_INT(x) \
|
||||
if (m_dpx.header.x() != 0xFFFFFFFF) \
|
||||
DPX_SET_ATTRIB(x, )
|
||||
#define DPX_SET_ATTRIB_FLOAT_N(x) \
|
||||
if (!std::isnan(m_dpx.header.x(subimage))) \
|
||||
#define DPX_SET_ATTRIB_FLOAT_N(x) \
|
||||
if (!std::isnan(m_dpx.header.x(subimage))) \
|
||||
DPX_SET_ATTRIB(x, subimage)
|
||||
#define DPX_SET_ATTRIB_FLOAT(x) \
|
||||
if (!std::isnan(m_dpx.header.x())) \
|
||||
#define DPX_SET_ATTRIB_FLOAT(x) \
|
||||
if (!std::isnan(m_dpx.header.x())) \
|
||||
DPX_SET_ATTRIB(x, )
|
||||
// see comment above Copyright, Software and DocumentName
|
||||
#define DPX_SET_ATTRIB_STR(X, x) \
|
||||
if (m_dpx.header.x[0] && m_dpx.header.x[0] != char(-1)) \
|
||||
#define DPX_SET_ATTRIB_STR(X, x) \
|
||||
if (m_dpx.header.x[0] && m_dpx.header.x[0] != char(-1)) \
|
||||
m_spec.attribute("dpx:" #X, m_dpx.header.x)
|
||||
|
||||
DPX_SET_ATTRIB_INT(EncryptKey);
|
||||
@@ -548,6 +576,18 @@ DPXInput::seek_subimage(int subimage, int miplevel)
|
||||
bool
|
||||
DPXInput::close()
|
||||
{
|
||||
if (m_io_local) {
|
||||
// If we allocated our own ioproxy, close it.
|
||||
m_io_local.reset();
|
||||
m_io = nullptr;
|
||||
}
|
||||
// N.B. If we were passed an ioproxy from the user (m_io != nullptr, but
|
||||
// m_io_local was not set), don't actually close it, it belongs to the
|
||||
// caller. And in the case of an ImageCache file, it's possible that the
|
||||
// IC won't close this ImageInput until after the owner of the IOProxy
|
||||
// destroyed it. So don't mess with it here in close() at all, because
|
||||
// we just can't be sure if it's still alive or not.
|
||||
|
||||
init(); // Reset to initial state
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,11 +41,12 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <OpenImageIO/filesystem.h>
|
||||
|
||||
|
||||
/*!
|
||||
* \class InStream
|
||||
* \brief Input Stream for reading files
|
||||
* \brief Input Stream abstract class for reading
|
||||
*/
|
||||
class InStream
|
||||
{
|
||||
@@ -63,29 +64,16 @@ class InStream
|
||||
kEnd //!< end of the file
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Constructor
|
||||
*/
|
||||
InStream();
|
||||
|
||||
*/
|
||||
InStream(OIIO::Filesystem::IOProxy* io) : m_io(io) { }
|
||||
|
||||
/*!
|
||||
* \brief Destructor
|
||||
*/
|
||||
virtual ~InStream();
|
||||
virtual ~InStream() = default;
|
||||
|
||||
/*!
|
||||
* \brief Open file
|
||||
* \param fn File name
|
||||
* \return success true/false
|
||||
*/
|
||||
virtual bool Open(const char * fn);
|
||||
|
||||
/*!
|
||||
* \brief Close file
|
||||
*/
|
||||
virtual void Close();
|
||||
|
||||
/*!
|
||||
* \brief Rewind file pointer to beginning of file
|
||||
*/
|
||||
@@ -122,8 +110,24 @@ class InStream
|
||||
*/
|
||||
virtual bool Seek(long offset, Origin origin);
|
||||
|
||||
/*!
|
||||
* \brief Tells the current position in the file
|
||||
* \return The current file position on success, or -1 on failure
|
||||
*/
|
||||
virtual long Tell();
|
||||
|
||||
/*!
|
||||
* \brief Tells the current position in the file
|
||||
* \return True if the stream is valid (exists and is opened), or false otherwise
|
||||
*/
|
||||
virtual bool IsValid() const { return m_io && m_io->opened(); }
|
||||
|
||||
protected:
|
||||
FILE *fp;
|
||||
/*!
|
||||
* This is a weak pointer, so opening and closing is done by the caller. Therefore, be
|
||||
* carefull to delete this object after `m_io` is deleted externally
|
||||
*/
|
||||
OIIO::Filesystem::IOProxy* m_io;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Copyright (c) 2009, Patrick A. Palmer.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
@@ -19,110 +19,67 @@
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <OpenImageIO/filesystem.h>
|
||||
// Alterations:
|
||||
// Copyright Contributors to the OpenImageIO project.
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// https://github.com/OpenImageIO/oiio
|
||||
|
||||
#include "DPXStream.h"
|
||||
|
||||
|
||||
InStream::InStream() : fp(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
InStream::~InStream()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool InStream::Open(const char *f)
|
||||
{
|
||||
if (this->fp)
|
||||
this->Close();
|
||||
if ((this->fp = OIIO::Filesystem::fopen(f, "rb")) == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void InStream::Close()
|
||||
{
|
||||
if (this->fp)
|
||||
{
|
||||
::fclose(this->fp);
|
||||
this->fp = 0;
|
||||
}
|
||||
}
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
void InStream::Rewind()
|
||||
{
|
||||
if (this->fp)
|
||||
::rewind(fp);
|
||||
if (IsValid())
|
||||
m_io->seek(0);
|
||||
}
|
||||
|
||||
|
||||
bool InStream::Seek(long offset, Origin origin)
|
||||
{
|
||||
int o = 0;
|
||||
switch (origin)
|
||||
{
|
||||
case kCurrent:
|
||||
o = SEEK_CUR;
|
||||
break;
|
||||
case kEnd:
|
||||
o = SEEK_END;
|
||||
break;
|
||||
case kStart:
|
||||
o = SEEK_SET;
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->fp == 0)
|
||||
return false;
|
||||
return (::fseek(this->fp, offset, o) == 0);
|
||||
if (!IsValid())
|
||||
return false;
|
||||
|
||||
int ioOrigin;
|
||||
switch (origin) {
|
||||
case kStart: ioOrigin = SEEK_SET; break;
|
||||
case kCurrent: ioOrigin = SEEK_CUR; break;
|
||||
case kEnd: ioOrigin = SEEK_END; break;
|
||||
default: ioOrigin = SEEK_SET; break;
|
||||
}
|
||||
|
||||
return m_io->seek(offset, ioOrigin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t InStream::Read(void *buf, const size_t size)
|
||||
{
|
||||
if (this->fp == 0)
|
||||
return 0;
|
||||
return ::fread(buf, 1, size, this->fp);
|
||||
return IsValid() ? m_io->read(buf, size) : false;
|
||||
}
|
||||
|
||||
|
||||
size_t InStream::ReadDirect(void *buf, const size_t size)
|
||||
{
|
||||
return this->Read(buf, size);
|
||||
return Read(buf, size);
|
||||
}
|
||||
|
||||
|
||||
bool InStream::EndOfFile() const
|
||||
bool InStream::EndOfFile() const
|
||||
{
|
||||
if (this->fp == 0)
|
||||
return true;
|
||||
return ::feof(this->fp);
|
||||
return IsValid() ? (size_t(m_io->tell()) >= m_io->size()) : true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
long InStream::Tell()
|
||||
{
|
||||
return IsValid() ? m_io->tell() : -1;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ private:
|
||||
FILE* m_fd; ///< The open file handle
|
||||
int m_subimage; ///< What subimage are we looking at?
|
||||
int m_next_scanline; ///< Next scanline to read
|
||||
std::vector<int64_t>
|
||||
m_scanline_offsets; ///< Cached scanline offsets for random access
|
||||
std::string rgbe_error; ///< Buffer for RGBE library error msgs
|
||||
|
||||
void init()
|
||||
@@ -53,6 +55,7 @@ private:
|
||||
m_fd = NULL;
|
||||
m_subimage = -1;
|
||||
m_next_scanline = 0;
|
||||
m_scanline_offsets.clear();
|
||||
rgbe_error.clear();
|
||||
}
|
||||
};
|
||||
@@ -151,6 +154,8 @@ HdrInput::seek_subimage(int subimage, int miplevel)
|
||||
|
||||
m_subimage = subimage;
|
||||
m_next_scanline = 0;
|
||||
m_scanline_offsets.clear();
|
||||
m_scanline_offsets.push_back(Filesystem::ftell(m_fd));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -164,23 +169,21 @@ HdrInput::read_native_scanline(int subimage, int miplevel, int y, int /*z*/,
|
||||
if (!seek_subimage(subimage, miplevel))
|
||||
return false;
|
||||
|
||||
if (m_next_scanline > y) {
|
||||
// User is trying to read an earlier scanline than the one we're
|
||||
// up to. Easy fix: close the file and re-open.
|
||||
ImageSpec dummyspec;
|
||||
int subimage = current_subimage();
|
||||
int miplevel = current_miplevel();
|
||||
if (!close() || !open(m_filename, dummyspec)
|
||||
|| !seek_subimage(subimage, miplevel))
|
||||
return false; // Somehow, the re-open failed
|
||||
assert(m_next_scanline == 0 && current_subimage() == subimage
|
||||
&& current_miplevel() == miplevel);
|
||||
if (m_next_scanline != y) {
|
||||
// For random access, use cached file offsets of scanlines. This avoids
|
||||
// re-reading the same pixels many times over.
|
||||
m_next_scanline = std::min((size_t)y, m_scanline_offsets.size() - 1);
|
||||
Filesystem::fseek(m_fd, m_scanline_offsets[m_next_scanline], SEEK_SET);
|
||||
}
|
||||
|
||||
while (m_next_scanline <= y) {
|
||||
// Keep reading until we're read the scanline we really need
|
||||
// Keep reading until we've read the scanline we really need
|
||||
int r = RGBE_ReadPixels_RLE(m_fd, (float*)data, m_spec.width, 1,
|
||||
rgbe_error);
|
||||
++m_next_scanline;
|
||||
if ((size_t)m_next_scanline == m_scanline_offsets.size()) {
|
||||
m_scanline_offsets.push_back(Filesystem::ftell(m_fd));
|
||||
}
|
||||
if (r != RGBE_RETURN_SUCCESS) {
|
||||
errorf("%s", rgbe_error);
|
||||
return false;
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
///
|
||||
/// OIIO_ASSERT_MSG(condition,msg,...) lets you add formatted output (a la
|
||||
/// printf) to the failure message.
|
||||
#define OIIO_ASSERT(x) \
|
||||
(OIIO_LIKELY(x) \
|
||||
? ((void)0) \
|
||||
: (std::fprintf(stderr, "%s:%u: %s: Assertion '%s' failed.\n", \
|
||||
__FILE__, __LINE__, OIIO_PRETTY_FUNCTION, #x), \
|
||||
#define OIIO_ASSERT(x) \
|
||||
(OIIO_LIKELY(x) \
|
||||
? ((void)0) \
|
||||
: (std::fprintf(stderr, "%s:%u: %s: Assertion '%s' failed.\n", \
|
||||
__FILE__, __LINE__, OIIO_PRETTY_FUNCTION, #x), \
|
||||
OIIO_ABORT_IF_DEBUG))
|
||||
#define OIIO_ASSERT_MSG(x, msg, ...) \
|
||||
(OIIO_LIKELY(x) \
|
||||
@@ -70,22 +70,22 @@
|
||||
/// DASSERT and DASSERT_MSG also are considered deprecated for the namespace
|
||||
/// reasons.
|
||||
#ifndef ASSERT
|
||||
# define ASSERT(x) \
|
||||
(OIIO_LIKELY(x) \
|
||||
? ((void)0) \
|
||||
: (std::fprintf(stderr, "%s:%u: %s: Assertion '%s' failed.\n", \
|
||||
__FILE__, __LINE__, OIIO_PRETTY_FUNCTION, #x), \
|
||||
# define ASSERT(x) \
|
||||
(OIIO_LIKELY(x) \
|
||||
? ((void)0) \
|
||||
: (std::fprintf(stderr, "%s:%u: %s: Assertion '%s' failed.\n", \
|
||||
__FILE__, __LINE__, OIIO_PRETTY_FUNCTION, #x), \
|
||||
abort()))
|
||||
#endif
|
||||
|
||||
#ifndef ASSERT_MSG
|
||||
# define ASSERT_MSG(x, msg, ...) \
|
||||
(OIIO_LIKELY(x) \
|
||||
? ((void)0) \
|
||||
: (std::fprintf(stderr, \
|
||||
"%s:%u: %s: Assertion '%s' failed: " msg "\n", \
|
||||
__FILE__, __LINE__, OIIO_PRETTY_FUNCTION, #x, \
|
||||
__VA_ARGS__), \
|
||||
# define ASSERT_MSG(x, msg, ...) \
|
||||
(OIIO_LIKELY(x) \
|
||||
? ((void)0) \
|
||||
: (std::fprintf(stderr, \
|
||||
"%s:%u: %s: Assertion '%s' failed: " msg "\n", \
|
||||
__FILE__, __LINE__, OIIO_PRETTY_FUNCTION, #x, \
|
||||
__VA_ARGS__), \
|
||||
abort()))
|
||||
#endif
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ public:
|
||||
bool seek (int64_t offset, int origin) {
|
||||
return seek ((origin == SEEK_SET ? offset : 0) +
|
||||
(origin == SEEK_CUR ? offset+tell() : 0) +
|
||||
(origin == SEEK_END ? size() : 0));
|
||||
(origin == SEEK_END ? offset+int64_t(size()) : 0));
|
||||
}
|
||||
|
||||
#if OIIO_VERSION >= 20101
|
||||
|
||||
@@ -733,7 +733,7 @@ inline OIIO_HOSTDEVICE float sign (float x)
|
||||
|
||||
|
||||
template <typename IN_TYPE, typename OUT_TYPE>
|
||||
OIIO_FORCEINLINE OIIO_HOSTDEVICE OUT_TYPE bit_cast (const IN_TYPE in) {
|
||||
OIIO_FORCEINLINE OIIO_HOSTDEVICE OUT_TYPE bit_cast (const IN_TYPE& in) {
|
||||
// NOTE: this is the only standards compliant way of doing this type of casting,
|
||||
// luckily the compilers we care about know how to optimize away this idiom.
|
||||
static_assert(sizeof(IN_TYPE) == sizeof(OUT_TYPE),
|
||||
|
||||
@@ -1422,7 +1422,7 @@ bool OIIO_API polar_to_complex (ImageBuf &dst, const ImageBuf &src,
|
||||
|
||||
|
||||
|
||||
enum OIIO_API NonFiniteFixMode
|
||||
enum NonFiniteFixMode
|
||||
{
|
||||
NONFINITE_NONE = 0, ///< Do not alter the pixels (but do count the
|
||||
///< number of nonfinite pixels in *pixelsFixed,
|
||||
@@ -1824,7 +1824,7 @@ bool OIIO_API repremult (ImageBuf &dst, const ImageBuf &src,
|
||||
|
||||
|
||||
|
||||
enum OIIO_API MakeTextureMode {
|
||||
enum MakeTextureMode {
|
||||
MakeTxTexture, MakeTxShadow, MakeTxEnvLatl,
|
||||
MakeTxEnvLatlFromLightProbe,
|
||||
MakeTxBumpWithSlopes,
|
||||
|
||||
@@ -335,14 +335,14 @@ void OIIO_API to_lower (std::string &a);
|
||||
void OIIO_API to_upper (std::string &a);
|
||||
|
||||
/// Return an all-upper case version of `a` (locale-independent).
|
||||
inline std::string OIIO_API lower (string_view a) {
|
||||
inline std::string lower (string_view a) {
|
||||
std::string result(a);
|
||||
to_lower(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Return an all-upper case version of `a` (locale-independent).
|
||||
inline std::string OIIO_API upper (string_view a) {
|
||||
inline std::string upper (string_view a) {
|
||||
std::string result(a);
|
||||
to_upper(result);
|
||||
return result;
|
||||
|
||||
+115
-115
@@ -96,135 +96,135 @@ static OIIO::pvt::UnitTestFailureCounter unit_test_failures;
|
||||
/// prints an error message indicating the module and line where the
|
||||
/// error occurred, but does NOT abort. This is helpful for unit tests
|
||||
/// where we do not want one failure.
|
||||
#define OIIO_CHECK_ASSERT(x) \
|
||||
((x) ? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< "\n"), \
|
||||
#define OIIO_CHECK_ASSERT(x) \
|
||||
((x) ? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< "\n"), \
|
||||
(void)++unit_test_failures))
|
||||
|
||||
#define OIIO_CHECK_EQUAL(x, y) \
|
||||
(((x) == (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " == " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
#define OIIO_CHECK_EQUAL(x, y) \
|
||||
(((x) == (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " == " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
(void)++unit_test_failures))
|
||||
|
||||
#define OIIO_CHECK_EQUAL_THRESH(x, y, eps) \
|
||||
((std::abs((x) - (y)) <= eps) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " == " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) << "'" \
|
||||
<< ", diff was " << std::abs((x) - (y)) << "\n"), \
|
||||
#define OIIO_CHECK_EQUAL_THRESH(x, y, eps) \
|
||||
((std::abs((x) - (y)) <= eps) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " == " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) << "'" \
|
||||
<< ", diff was " << std::abs((x) - (y)) << "\n"), \
|
||||
(void)++unit_test_failures))
|
||||
|
||||
#define OIIO_CHECK_EQUAL_APPROX(x, y) \
|
||||
(OIIO::pvt::equal_approx(x, y) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " == " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) << "'" \
|
||||
<< ", diff was " << ((x) - (y)) << "\n"), \
|
||||
#define OIIO_CHECK_EQUAL_APPROX(x, y) \
|
||||
(OIIO::pvt::equal_approx(x, y) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " == " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) << "'" \
|
||||
<< ", diff was " << ((x) - (y)) << "\n"), \
|
||||
(void)++unit_test_failures))
|
||||
|
||||
#define OIIO_CHECK_NE(x, y) \
|
||||
(((x) != (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " != " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
#define OIIO_CHECK_NE(x, y) \
|
||||
(((x) != (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " != " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
(void)++unit_test_failures))
|
||||
|
||||
#define OIIO_CHECK_LT(x, y) \
|
||||
(((x) < (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " < " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
#define OIIO_CHECK_LT(x, y) \
|
||||
(((x) < (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " < " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
(void)++unit_test_failures))
|
||||
|
||||
#define OIIO_CHECK_GT(x, y) \
|
||||
(((x) > (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " > " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
#define OIIO_CHECK_GT(x, y) \
|
||||
(((x) > (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " > " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
(void)++unit_test_failures))
|
||||
|
||||
#define OIIO_CHECK_LE(x, y) \
|
||||
(((x) <= (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " <= " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
#define OIIO_CHECK_LE(x, y) \
|
||||
(((x) <= (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " <= " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
(void)++unit_test_failures))
|
||||
|
||||
#define OIIO_CHECK_GE(x, y) \
|
||||
(((x) >= (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " >= " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
#define OIIO_CHECK_GE(x, y) \
|
||||
(((x) >= (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " >= " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
(void)++unit_test_failures))
|
||||
|
||||
|
||||
// Special SIMD related equality checks that use all()
|
||||
#define OIIO_CHECK_SIMD_EQUAL(x, y) \
|
||||
(all((x) == (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " == " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
#define OIIO_CHECK_SIMD_EQUAL(x, y) \
|
||||
(all((x) == (y)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " == " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
(void)++unit_test_failures))
|
||||
|
||||
#define OIIO_CHECK_SIMD_EQUAL_THRESH(x, y, eps) \
|
||||
(all(abs((x) - (y)) < (eps)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " == " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
#define OIIO_CHECK_SIMD_EQUAL_THRESH(x, y, eps) \
|
||||
(all(abs((x) - (y)) < (eps)) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< " == " << #y << "\n" \
|
||||
<< "\tvalues were '" << (x) << "' and '" << (y) \
|
||||
<< "'\n"), \
|
||||
(void)++unit_test_failures))
|
||||
|
||||
|
||||
@@ -236,12 +236,12 @@ static OIIO::pvt::UnitTestFailureCounter unit_test_failures;
|
||||
// OIIO_CHECK_IMAGEBUF_STATUS(buf,
|
||||
// ImageBufAlgo::Func (buf, ...)
|
||||
// );
|
||||
#define OIIO_CHECK_IMAGEBUF_STATUS(buf, x) \
|
||||
((x && !buf.has_error()) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< ": " << buf.geterror() << "\n"), \
|
||||
#define OIIO_CHECK_IMAGEBUF_STATUS(buf, x) \
|
||||
((x && !buf.has_error()) \
|
||||
? ((void)0) \
|
||||
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
|
||||
<< __FILE__ << ":" << __LINE__ << ":\n" \
|
||||
<< "FAILED: " \
|
||||
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
|
||||
<< ": " << buf.geterror() << "\n"), \
|
||||
(void)++unit_test_failures))
|
||||
|
||||
+3
-3
@@ -36,9 +36,9 @@ gl_err_to_string(GLenum err)
|
||||
}
|
||||
|
||||
|
||||
#define GLERRPRINT(msg) \
|
||||
for (GLenum err = glGetError(); err != GL_NO_ERROR; err = glGetError()) \
|
||||
std::cerr << "GL error " << msg << " " << (int)err << " - " \
|
||||
#define GLERRPRINT(msg) \
|
||||
for (GLenum err = glGetError(); err != GL_NO_ERROR; err = glGetError()) \
|
||||
std::cerr << "GL error " << msg << " " << (int)err << " - " \
|
||||
<< gl_err_to_string(err) << "\n";
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "imageio_pvt.h"
|
||||
|
||||
#define MAKE_OCIO_VERSION_HEX(maj, min, patch) \
|
||||
#define MAKE_OCIO_VERSION_HEX(maj, min, patch) \
|
||||
(((maj) << 24) | ((min) << 16) | (patch))
|
||||
|
||||
#ifdef USE_OCIO
|
||||
|
||||
@@ -418,14 +418,14 @@ ImageSpec::find_attribute(string_view name, ParamValue& tmpparam,
|
||||
if (iter != extra_attribs.end())
|
||||
return &(*iter);
|
||||
// Check named items in the ImageSpec structs, not in extra_attrubs
|
||||
#define MATCH(n, t) \
|
||||
(((!casesensitive && Strutil::iequals(name, n)) \
|
||||
|| (casesensitive && name == n)) \
|
||||
#define MATCH(n, t) \
|
||||
(((!casesensitive && Strutil::iequals(name, n)) \
|
||||
|| (casesensitive && name == n)) \
|
||||
&& (searchtype == TypeDesc::UNKNOWN || searchtype == t))
|
||||
#define GETINT(n) \
|
||||
if (MATCH(#n, TypeInt)) { \
|
||||
tmpparam.init(#n, TypeInt, 1, &this->n); \
|
||||
return &tmpparam; \
|
||||
#define GETINT(n) \
|
||||
if (MATCH(#n, TypeInt)) { \
|
||||
tmpparam.init(#n, TypeInt, 1, &this->n); \
|
||||
return &tmpparam; \
|
||||
}
|
||||
GETINT(nchannels);
|
||||
GETINT(width);
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
void copy_metadata(const ImageBufImpl& src);
|
||||
|
||||
template<typename... Args>
|
||||
void error(const char* fmt, const Args&... args) const
|
||||
void errorfmt(const char* fmt, const Args&... args) const
|
||||
{
|
||||
error(Strutil::fmt::format(fmt, args...));
|
||||
}
|
||||
@@ -932,12 +932,12 @@ ImageBufImpl::read(int subimage, int miplevel, int chbegin, int chend,
|
||||
auto input = ImageInput::open(m_name.string(), m_configspec.get(),
|
||||
m_rioproxy);
|
||||
if (!input) {
|
||||
error("{}", OIIO::geterror());
|
||||
error(OIIO::geterror());
|
||||
return false;
|
||||
}
|
||||
input->threads(threads()); // Pass on our thread policy
|
||||
if (!input->read_native_deep_image(subimage, miplevel, m_deepdata)) {
|
||||
error("{}", input->geterror());
|
||||
error(input->geterror());
|
||||
return false;
|
||||
}
|
||||
m_spec = m_nativespec; // Deep images always use native data
|
||||
@@ -1044,11 +1044,11 @@ ImageBufImpl::read(int subimage, int miplevel, int chbegin, int chend,
|
||||
m_pixels_valid = true;
|
||||
} else {
|
||||
m_pixels_valid = false;
|
||||
error("{}", in->geterror());
|
||||
error(in->geterror());
|
||||
}
|
||||
} else {
|
||||
m_pixels_valid = false;
|
||||
error("{}", OIIO::geterror());
|
||||
error(OIIO::geterror());
|
||||
}
|
||||
return m_pixels_valid;
|
||||
}
|
||||
@@ -1063,7 +1063,7 @@ ImageBufImpl::read(int subimage, int miplevel, int chbegin, int chend,
|
||||
m_pixels_valid = true;
|
||||
} else {
|
||||
m_pixels_valid = false;
|
||||
error("{}", m_imagecache->geterror());
|
||||
error(m_imagecache->geterror());
|
||||
}
|
||||
|
||||
return m_pixels_valid;
|
||||
@@ -1218,7 +1218,7 @@ ImageBuf::write(ImageOutput* out, ProgressCallback progress_callback,
|
||||
}
|
||||
}
|
||||
if (!ok)
|
||||
error("{}", out->geterror());
|
||||
error(out->geterror());
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -1263,7 +1263,7 @@ ImageBuf::write(string_view _filename, TypeDesc dtype, string_view _fileformat,
|
||||
|
||||
auto out = ImageOutput::create(fileformat);
|
||||
if (!out) {
|
||||
error("{}", geterror());
|
||||
error(geterror());
|
||||
return false;
|
||||
}
|
||||
out->threads(threads()); // Pass on our thread policy
|
||||
@@ -1315,7 +1315,7 @@ ImageBuf::write(string_view _filename, TypeDesc dtype, string_view _fileformat,
|
||||
}
|
||||
|
||||
if (!out->open(filename.c_str(), newspec)) {
|
||||
error("{}", out->geterror());
|
||||
error(out->geterror());
|
||||
return false;
|
||||
}
|
||||
if (!write(out.get(), progress_callback, progress_callback_data))
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
#ifdef USE_OPENCV
|
||||
# include <opencv2/core/version.hpp>
|
||||
# ifdef CV_VERSION_EPOCH
|
||||
# define OIIO_OPENCV_VERSION \
|
||||
(10000 * CV_VERSION_EPOCH + 100 * CV_VERSION_MAJOR \
|
||||
# define OIIO_OPENCV_VERSION \
|
||||
(10000 * CV_VERSION_EPOCH + 100 * CV_VERSION_MAJOR \
|
||||
+ CV_VERSION_MINOR)
|
||||
# else
|
||||
# define OIIO_OPENCV_VERSION \
|
||||
(10000 * CV_VERSION_MAJOR + 100 * CV_VERSION_MINOR \
|
||||
# define OIIO_OPENCV_VERSION \
|
||||
(10000 * CV_VERSION_MAJOR + 100 * CV_VERSION_MINOR \
|
||||
+ CV_VERSION_REVISION)
|
||||
# endif
|
||||
# include <opencv2/opencv.hpp>
|
||||
|
||||
@@ -796,17 +796,17 @@ test_IBAprep()
|
||||
ImageBuf rgb(ImageSpec(256, 256, 3)); // Basic RGB uint8 image
|
||||
ImageBuf rgba(ImageSpec(256, 256, 4)); // Basic RGBA uint8 image
|
||||
|
||||
#define CHECK(...) \
|
||||
{ \
|
||||
ImageBuf dst; \
|
||||
ROI roi; \
|
||||
OIIO_CHECK_ASSERT(IBAprep(__VA_ARGS__)); \
|
||||
#define CHECK(...) \
|
||||
{ \
|
||||
ImageBuf dst; \
|
||||
ROI roi; \
|
||||
OIIO_CHECK_ASSERT(IBAprep(__VA_ARGS__)); \
|
||||
}
|
||||
#define CHECK0(...) \
|
||||
{ \
|
||||
ImageBuf dst; \
|
||||
ROI roi; \
|
||||
OIIO_CHECK_ASSERT(!IBAprep(__VA_ARGS__)); \
|
||||
#define CHECK0(...) \
|
||||
{ \
|
||||
ImageBuf dst; \
|
||||
ROI roi; \
|
||||
OIIO_CHECK_ASSERT(!IBAprep(__VA_ARGS__)); \
|
||||
}
|
||||
|
||||
// Test REQUIRE_ALPHA
|
||||
|
||||
@@ -41,15 +41,15 @@ make_test_image(string_view formatname)
|
||||
|
||||
|
||||
|
||||
#define CHECKED(obj, call) \
|
||||
if (!obj->call) { \
|
||||
if (do_asserts) \
|
||||
OIIO_CHECK_ASSERT(false && #call); \
|
||||
if (errmsg) \
|
||||
*errmsg = obj->geterror(); \
|
||||
else \
|
||||
std::cout << " " << obj->geterror() << "\n"; \
|
||||
return false; \
|
||||
#define CHECKED(obj, call) \
|
||||
if (!obj->call) { \
|
||||
if (do_asserts) \
|
||||
OIIO_CHECK_ASSERT(false && #call); \
|
||||
if (errmsg) \
|
||||
*errmsg = obj->geterror(); \
|
||||
else \
|
||||
std::cout << " " << obj->geterror() << "\n"; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -196,19 +196,19 @@ catalog_plugin(const std::string& format_name,
|
||||
// list of file extensions, for the standard plugins that come with OIIO.
|
||||
// These won't be used unless EMBED_PLUGINS is defined. Use the PLUGENTRY
|
||||
// macro to make the declaration compact and easy to read.
|
||||
# define PLUGENTRY(name) \
|
||||
ImageInput* name##_input_imageio_create(); \
|
||||
ImageOutput* name##_output_imageio_create(); \
|
||||
extern const char* name##_output_extensions[]; \
|
||||
extern const char* name##_input_extensions[]; \
|
||||
# define PLUGENTRY(name) \
|
||||
ImageInput* name##_input_imageio_create(); \
|
||||
ImageOutput* name##_output_imageio_create(); \
|
||||
extern const char* name##_output_extensions[]; \
|
||||
extern const char* name##_input_extensions[]; \
|
||||
extern const char* name##_imageio_library_version();
|
||||
# define PLUGENTRY_RO(name) \
|
||||
ImageInput* name##_input_imageio_create(); \
|
||||
extern const char* name##_input_extensions[]; \
|
||||
# define PLUGENTRY_RO(name) \
|
||||
ImageInput* name##_input_imageio_create(); \
|
||||
extern const char* name##_input_extensions[]; \
|
||||
extern const char* name##_imageio_library_version();
|
||||
# define PLUGENTRY_WO(name) \
|
||||
ImageOutput* name##_output_imageio_create(); \
|
||||
extern const char* name##_output_extensions[]; \
|
||||
# define PLUGENTRY_WO(name) \
|
||||
ImageOutput* name##_output_imageio_create(); \
|
||||
extern const char* name##_output_extensions[]; \
|
||||
extern const char* name##_imageio_library_version();
|
||||
|
||||
PLUGENTRY(bmp);
|
||||
|
||||
@@ -951,15 +951,15 @@ make_texture_impl(ImageBufAlgo::MakeTextureMode mode, const ImageBuf* input,
|
||||
size_t peak_mem = 0;
|
||||
Timer alltime;
|
||||
|
||||
#define STATUS(task, timer) \
|
||||
{ \
|
||||
size_t mem = Sysutil::memory_used(true); \
|
||||
peak_mem = std::max(peak_mem, mem); \
|
||||
if (verbose) \
|
||||
outstream << Strutil::sprintf(" %-25s %s (%s)\n", task, \
|
||||
Strutil::timeintervalformat(timer, \
|
||||
2), \
|
||||
Strutil::memformat(mem)); \
|
||||
#define STATUS(task, timer) \
|
||||
{ \
|
||||
size_t mem = Sysutil::memory_used(true); \
|
||||
peak_mem = std::max(peak_mem, mem); \
|
||||
if (verbose) \
|
||||
outstream << Strutil::sprintf(" %-25s %s (%s)\n", task, \
|
||||
Strutil::timeintervalformat(timer, \
|
||||
2), \
|
||||
Strutil::memformat(mem)); \
|
||||
}
|
||||
|
||||
ImageSpec configspec = _configspec;
|
||||
|
||||
@@ -304,6 +304,11 @@ ImageCacheFile::ImageCacheFile(ImageCacheImpl& imagecache,
|
||||
|| m_filename.find("<u>") != m_filename.npos
|
||||
|| m_filename.find("<v>") != m_filename.npos)
|
||||
&& !Filesystem::exists(m_filename);
|
||||
|
||||
// If the config has an IOProxy, remember that we should never actually
|
||||
// release() it, because the proxy can't be reopened.
|
||||
if (config && config->find_attribute("oiio:ioproxy", TypeDesc::PTR))
|
||||
m_allow_release = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1060,7 +1065,7 @@ ImageCacheFile::release()
|
||||
m_mutex_wait_time += input_mutex_timer();
|
||||
if (m_used)
|
||||
m_used = false;
|
||||
else
|
||||
else if (m_allow_release)
|
||||
close();
|
||||
}
|
||||
|
||||
@@ -1788,12 +1793,12 @@ ImageCacheImpl::getstats(int level) const
|
||||
out << ") ver " << OIIO_VERSION_STRING << "\n";
|
||||
|
||||
std::string opt;
|
||||
#define BOOLOPT(name) \
|
||||
if (m_##name) \
|
||||
#define BOOLOPT(name) \
|
||||
if (m_##name) \
|
||||
opt += #name " "
|
||||
#define INTOPT(name) opt += Strutil::sprintf(#name "=%d ", m_##name)
|
||||
#define STROPT(name) \
|
||||
if (m_##name.size()) \
|
||||
#define STROPT(name) \
|
||||
if (m_##name.size()) \
|
||||
opt += Strutil::sprintf(#name "=\"%s\" ", m_##name)
|
||||
opt += Strutil::sprintf("max_memory_MB=%0.1f ",
|
||||
m_max_memory_bytes / (1024.0 * 1024.0));
|
||||
@@ -2189,10 +2194,10 @@ ImageCacheImpl::attribute(string_view name, TypeDesc type, const void* val)
|
||||
bool
|
||||
ImageCacheImpl::getattribute(string_view name, TypeDesc type, void* val) const
|
||||
{
|
||||
#define ATTR_DECODE(_name, _ctype, _src) \
|
||||
if (name == _name && type == BaseTypeFromC<_ctype>::value) { \
|
||||
*(_ctype*)(val) = (_ctype)(_src); \
|
||||
return true; \
|
||||
#define ATTR_DECODE(_name, _ctype, _src) \
|
||||
if (name == _name && type == BaseTypeFromC<_ctype>::value) { \
|
||||
*(_ctype*)(val) = (_ctype)(_src); \
|
||||
return true; \
|
||||
}
|
||||
|
||||
ATTR_DECODE("max_open_files", int, m_max_open_files);
|
||||
@@ -2517,10 +2522,10 @@ ImageCacheImpl::get_image_info(ImageCacheFile* file,
|
||||
int subimage, int miplevel, ustring dataname,
|
||||
TypeDesc datatype, void* data)
|
||||
{
|
||||
#define ATTR_DECODE(_name, _ctype, _src) \
|
||||
if (dataname == _name && datatype == BaseTypeFromC<_ctype>::value) { \
|
||||
*(_ctype*)(data) = (_ctype)(_src); \
|
||||
return true; \
|
||||
#define ATTR_DECODE(_name, _ctype, _src) \
|
||||
if (dataname == _name && datatype == BaseTypeFromC<_ctype>::value) { \
|
||||
*(_ctype*)(data) = (_ctype)(_src); \
|
||||
return true; \
|
||||
}
|
||||
|
||||
if (!thread_info)
|
||||
|
||||
@@ -336,6 +336,7 @@ private:
|
||||
ustring m_filename; ///< Filename
|
||||
bool m_used; ///< Recently used (in the LRU sense)
|
||||
bool m_broken; ///< has errors; can't be used properly
|
||||
bool m_allow_release = true; ///< Allow the file to release()?
|
||||
std::string m_broken_message; ///< Error message for why it's broken
|
||||
std::shared_ptr<ImageInput> m_input; ///< Open ImageInput, NULL if closed
|
||||
// Note that m_input, the shared pointer itself, is NOT safe to
|
||||
|
||||
@@ -376,12 +376,12 @@ TextureSystemImpl::getstats(int level, bool icstats) const
|
||||
out << "OpenImageIO Texture statistics\n";
|
||||
|
||||
std::string opt;
|
||||
#define BOOLOPT(name) \
|
||||
if (m_##name) \
|
||||
#define BOOLOPT(name) \
|
||||
if (m_##name) \
|
||||
opt += #name " "
|
||||
#define INTOPT(name) opt += Strutil::sprintf(#name "=%d ", m_##name)
|
||||
#define STROPT(name) \
|
||||
if (m_##name.size()) \
|
||||
#define STROPT(name) \
|
||||
if (m_##name.size()) \
|
||||
opt += Strutil::sprintf(#name "=\"%s\" ", m_##name)
|
||||
INTOPT(gray_to_rgb);
|
||||
INTOPT(flip_t);
|
||||
|
||||
@@ -658,8 +658,8 @@ Filesystem::parse_pattern(const char* pattern_, int framepadding_override,
|
||||
// string (e.g. "%04d").
|
||||
#define ONERANGE_SPEC "[0-9]+(-[0-9]+((x|y)-?[0-9]+)?)?"
|
||||
#define MANYRANGE_SPEC ONERANGE_SPEC "(," ONERANGE_SPEC ")*"
|
||||
#define SEQUENCE_SPEC \
|
||||
"(" MANYRANGE_SPEC ")?" \
|
||||
#define SEQUENCE_SPEC \
|
||||
"(" MANYRANGE_SPEC ")?" \
|
||||
"((#|@)+|(%[0-9]*d))"
|
||||
static regex sequence_re(SEQUENCE_SPEC);
|
||||
// std::cout << "pattern >" << (SEQUENCE_SPEC) << "<\n";
|
||||
|
||||
@@ -65,7 +65,7 @@ dlclose(Handle plugin_handle)
|
||||
void*
|
||||
dlsym(Handle plugin_handle, const char* symbol_name)
|
||||
{
|
||||
return GetProcAddress((HMODULE)plugin_handle, symbol_name);
|
||||
return (void*)GetProcAddress((HMODULE)plugin_handle, symbol_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+10
-4
@@ -51,7 +51,7 @@ namespace {
|
||||
static std::mutex output_mutex;
|
||||
|
||||
// On systems that support it, get a location independent locale.
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) \
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) \
|
||||
|| defined(__FreeBSD_kernel__) || defined(__GLIBC__)
|
||||
static locale_t c_loc = newlocale(LC_ALL_MASK, "C", nullptr);
|
||||
#elif defined(_WIN32)
|
||||
@@ -264,7 +264,13 @@ bool
|
||||
Strutil::get_rest_arguments(const std::string& str, std::string& base,
|
||||
std::map<std::string, std::string>& result)
|
||||
{
|
||||
std::string::size_type mark_pos = str.find_first_of("?");
|
||||
// Disregard the Windows long path question style prefix "\\?\"
|
||||
static const std::string longPathQPrefix("\\\\?\\");
|
||||
auto find_start_pos = starts_with(str, longPathQPrefix)
|
||||
? longPathQPrefix.size()
|
||||
: size_t(0);
|
||||
|
||||
std::string::size_type mark_pos = str.find_first_of("?", find_start_pos);
|
||||
if (mark_pos == std::string::npos) {
|
||||
base = str;
|
||||
return true;
|
||||
@@ -1279,7 +1285,7 @@ Strutil::strtof(const char* nptr, char** endptr) noexcept
|
||||
#ifdef __APPLE__
|
||||
// On OSX, strtod_l is for some reason drastically faster than strtof_l.
|
||||
return static_cast<float>(strtod_l(nptr, endptr, c_loc));
|
||||
#elif defined(__linux__) || defined(__FreeBSD__) \
|
||||
#elif defined(__linux__) || defined(__FreeBSD__) \
|
||||
|| defined(__FreeBSD_kernel__) || defined(__GLIBC__)
|
||||
return strtof_l(nptr, endptr, c_loc);
|
||||
#elif defined(_WIN32)
|
||||
@@ -1314,7 +1320,7 @@ double
|
||||
Strutil::strtod(const char* nptr, char** endptr) noexcept
|
||||
{
|
||||
// Can use strtod_l on platforms that support it
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) \
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) \
|
||||
|| defined(__FreeBSD_kernel__) || defined(__GLIBC__)
|
||||
// static initialization inside function is thread-safe by C++11 rules!
|
||||
return strtod_l(nptr, endptr, c_loc);
|
||||
|
||||
@@ -182,6 +182,30 @@ test_get_rest_arguments()
|
||||
OIIO_CHECK_EQUAL(base, "atext");
|
||||
OIIO_CHECK_EQUAL(result["arg1"], "value1");
|
||||
OIIO_CHECK_EQUAL(result["arg2"], "somevalue");
|
||||
|
||||
result.clear();
|
||||
url = "\\\\?\\C:\\WindowsLongPathNoRestArgs";
|
||||
ret = Strutil::get_rest_arguments(url, base, result);
|
||||
OIIO_CHECK_EQUAL(ret, true);
|
||||
OIIO_CHECK_EQUAL(base, "\\\\?\\C:\\WindowsLongPathNoRestArgs");
|
||||
OIIO_CHECK_EQUAL(result["arg1"], "");
|
||||
|
||||
result.clear();
|
||||
url = "\\\\?\\C:\\WindowsLongPathWithGoodRestArgs?arg1=value1&arg2=value2";
|
||||
ret = Strutil::get_rest_arguments(url, base, result);
|
||||
OIIO_CHECK_EQUAL(ret, true);
|
||||
OIIO_CHECK_EQUAL(base, "\\\\?\\C:\\WindowsLongPathWithGoodRestArgs");
|
||||
OIIO_CHECK_EQUAL(result["arg1"], "value1");
|
||||
OIIO_CHECK_EQUAL(result["arg2"], "value2");
|
||||
|
||||
result.clear();
|
||||
url = "\\\\?\\C:\\WindowsLongPathWithBadRestArgs?arg1=value1&arg2value2";
|
||||
result["arg2"] = "somevalue";
|
||||
ret = Strutil::get_rest_arguments(url, base, result);
|
||||
OIIO_CHECK_EQUAL(ret, false);
|
||||
OIIO_CHECK_EQUAL(base, "\\\\?\\C:\\WindowsLongPathWithBadRestArgs");
|
||||
OIIO_CHECK_EQUAL(result["arg1"], "value1");
|
||||
OIIO_CHECK_EQUAL(result["arg2"], "somevalue");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md
|
||||
|
||||
#if (defined __MINGW32__) || (defined __MINGW64__) && !(defined _POSIX_C_SOURCE)
|
||||
# define _POSIX_C_SOURCE 1 // for localtime_r
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
@@ -291,7 +295,7 @@ Sysutil::terminal_columns()
|
||||
{
|
||||
int columns = 80; // a decent guess, if we have nothing more to go on
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) \
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) \
|
||||
|| defined(__FreeBSD_kernel__) || defined(__GNU__)
|
||||
struct winsize w;
|
||||
ioctl(0, TIOCGWINSZ, &w);
|
||||
@@ -315,7 +319,7 @@ Sysutil::terminal_rows()
|
||||
{
|
||||
int rows = 24; // a decent guess, if we have nothing more to go on
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) \
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) \
|
||||
|| defined(__FreeBSD_kernel__) || defined(__GNU__)
|
||||
struct winsize w;
|
||||
ioctl(0, TIOCGWINSZ, &w);
|
||||
|
||||
@@ -209,7 +209,8 @@ public:
|
||||
= std::any_of(this->threads.begin(), this->threads.end(),
|
||||
[](std::unique_ptr<std::thread>& t) {
|
||||
DWORD rcode;
|
||||
GetExitCodeThread(t->native_handle(), &rcode);
|
||||
GetExitCodeThread((HANDLE)t->native_handle(),
|
||||
&rcode);
|
||||
return rcode != STILL_ACTIVE;
|
||||
});
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ ustring::TableRep::TableRep(string_view strref, size_t hash)
|
||||
// the std::string to make it point to our chars! In such a case, the
|
||||
// destructor will be careful not to allow a deallocation.
|
||||
|
||||
#if defined(__GNUC__) && !defined(_LIBCPP_VERSION) \
|
||||
#if defined(__GNUC__) && !defined(_LIBCPP_VERSION) \
|
||||
&& defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI
|
||||
// NEW gcc ABI
|
||||
// FIXME -- do something smart with this.
|
||||
|
||||
+40
-40
@@ -59,48 +59,48 @@ static Oiiotool ot;
|
||||
// a lambda for each subimage. Beware, the macro expansion rules may require
|
||||
// you may need to enclose the lambda itself in parenthesis () if there it
|
||||
// contains commas that are not inside other parentheses.
|
||||
#define OIIOTOOL_OP(name, ninputs, ...) \
|
||||
static int action_##name(int argc, const char* argv[]) \
|
||||
{ \
|
||||
if (ot.postpone_callback(ninputs, action_##name, argc, argv)) \
|
||||
return 0; \
|
||||
OiiotoolOp op(ot, #name, argc, argv, ninputs, __VA_ARGS__); \
|
||||
return op(); \
|
||||
#define OIIOTOOL_OP(name, ninputs, ...) \
|
||||
static int action_##name(int argc, const char* argv[]) \
|
||||
{ \
|
||||
if (ot.postpone_callback(ninputs, action_##name, argc, argv)) \
|
||||
return 0; \
|
||||
OiiotoolOp op(ot, #name, argc, argv, ninputs, __VA_ARGS__); \
|
||||
return op(); \
|
||||
}
|
||||
|
||||
// Canned setup for an op that uses one image on the stack.
|
||||
#define UNARY_IMAGE_OP(name, impl) \
|
||||
OIIOTOOL_OP(name, 1, [](OiiotoolOp& op, span<ImageBuf*> img) { \
|
||||
return impl(*img[0], *img[1]); \
|
||||
#define UNARY_IMAGE_OP(name, impl) \
|
||||
OIIOTOOL_OP(name, 1, [](OiiotoolOp& op, span<ImageBuf*> img) { \
|
||||
return impl(*img[0], *img[1]); \
|
||||
})
|
||||
|
||||
// Canned setup for an op that uses two images on the stack.
|
||||
#define BINARY_IMAGE_OP(name, impl) \
|
||||
OIIOTOOL_OP(name, 2, [](OiiotoolOp& op, span<ImageBuf*> img) { \
|
||||
return impl(*img[0], *img[1], *img[2]); \
|
||||
#define BINARY_IMAGE_OP(name, impl) \
|
||||
OIIOTOOL_OP(name, 2, [](OiiotoolOp& op, span<ImageBuf*> img) { \
|
||||
return impl(*img[0], *img[1], *img[2]); \
|
||||
})
|
||||
|
||||
// Canned setup for an op that uses one image on the stack and one color
|
||||
// on the command line.
|
||||
#define BINARY_IMAGE_COLOR_OP(name, impl, defaultval) \
|
||||
OIIOTOOL_OP(name, 1, [](OiiotoolOp& op, span<ImageBuf*> img) { \
|
||||
int nchans = img[1]->spec().nchannels; \
|
||||
std::vector<float> val(nchans, defaultval); \
|
||||
int nvals = Strutil::extract_from_list_string(val, op.args(1)); \
|
||||
val.resize(nvals); \
|
||||
val.resize(nchans, val.size() == 1 ? val.back() : defaultval); \
|
||||
return impl(*img[0], *img[1], val, ROI(), 0); \
|
||||
#define BINARY_IMAGE_COLOR_OP(name, impl, defaultval) \
|
||||
OIIOTOOL_OP(name, 1, [](OiiotoolOp& op, span<ImageBuf*> img) { \
|
||||
int nchans = img[1]->spec().nchannels; \
|
||||
std::vector<float> val(nchans, defaultval); \
|
||||
int nvals = Strutil::extract_from_list_string(val, op.args(1)); \
|
||||
val.resize(nvals); \
|
||||
val.resize(nchans, val.size() == 1 ? val.back() : defaultval); \
|
||||
return impl(*img[0], *img[1], val, ROI(), 0); \
|
||||
})
|
||||
|
||||
// Macro to fully set up the "action" function that straightforwardly
|
||||
// calls a custom OiiotoolOp class.
|
||||
#define OP_CUSTOMCLASS(name, opclass, ninputs) \
|
||||
static int action_##name(int argc, const char* argv[]) \
|
||||
{ \
|
||||
if (ot.postpone_callback(ninputs, action_##name, argc, argv)) \
|
||||
return 0; \
|
||||
opclass op(ot, #name, argc, argv); \
|
||||
return op(); \
|
||||
#define OP_CUSTOMCLASS(name, opclass, ninputs) \
|
||||
static int action_##name(int argc, const char* argv[]) \
|
||||
{ \
|
||||
if (ot.postpone_callback(ninputs, action_##name, argc, argv)) \
|
||||
return 0; \
|
||||
opclass op(ot, #name, argc, argv); \
|
||||
return op(); \
|
||||
}
|
||||
|
||||
|
||||
@@ -347,6 +347,8 @@ Oiiotool::error(string_view command, string_view explanation) const
|
||||
std::cerr << ": " << command;
|
||||
if (explanation.size())
|
||||
std::cerr << " : " << explanation;
|
||||
else
|
||||
std::cerr << " (unknown error)";
|
||||
std::cerr << "\n";
|
||||
// Repeat the command line, so if oiiotool is being called from a
|
||||
// script, it's easy to debug how the command was mangled.
|
||||
@@ -364,6 +366,8 @@ Oiiotool::warning(string_view command, string_view explanation) const
|
||||
std::cerr << ": " << command;
|
||||
if (explanation.size())
|
||||
std::cerr << " : " << explanation;
|
||||
else
|
||||
std::cerr << " (unknown warning)";
|
||||
std::cerr << "\n";
|
||||
}
|
||||
|
||||
@@ -1988,7 +1992,7 @@ public:
|
||||
// The color transform failed, but we were told not to be
|
||||
// strict, so ignore the error and just copy destination to
|
||||
// source.
|
||||
ot.warningf(opname(), "%s", img[0]->geterror());
|
||||
ot.warning(opname(), img[0]->geterror());
|
||||
// ok = ImageBufAlgo::copy (*img[0], *img[1], TypeDesc);
|
||||
ok = img[0]->copy(*img[1]);
|
||||
}
|
||||
@@ -4830,14 +4834,12 @@ output_file(int /*argc*/, const char* argv[])
|
||||
ImageOutput::OpenMode mode = ImageOutput::Create;
|
||||
if (ir->subimages() > 1 && out->supports("multiimage")) {
|
||||
if (!out->open(tmpfilename, ir->subimages(), &subimagespecs[0])) {
|
||||
std::string err = out->geterror();
|
||||
ot.error(command, err.size() ? err.c_str() : "unknown error");
|
||||
ot.error(command, out->geterror());
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (!out->open(tmpfilename, subimagespecs[0], mode)) {
|
||||
std::string err = out->geterror();
|
||||
ot.error(command, err.size() ? err.c_str() : "unknown error");
|
||||
ot.error(command, out->geterror());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -4851,9 +4853,7 @@ output_file(int /*argc*/, const char* argv[])
|
||||
(*ir)[s].was_direct_read());
|
||||
if (s > 0 || m > 0) { // already opened first subimage/level
|
||||
if (!out->open(tmpfilename, spec, mode)) {
|
||||
std::string err = out->geterror();
|
||||
ot.error(command,
|
||||
err.size() ? err.c_str() : "unknown error");
|
||||
ot.error(command, out->geterror());
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
@@ -5779,10 +5779,10 @@ handle_sequence(int argc, const char** argv)
|
||||
#define ONERANGE_SPEC "-?[0-9]+(--?[0-9]+((x|y)-?[0-9]+)?)?"
|
||||
#define MANYRANGE_SPEC ONERANGE_SPEC "(," ONERANGE_SPEC ")*"
|
||||
#define VIEW_SPEC "%[Vv]"
|
||||
#define SEQUENCE_SPEC \
|
||||
"((" MANYRANGE_SPEC ")?" \
|
||||
"((#|@)+|(%[0-9]*d)))" \
|
||||
"|" \
|
||||
#define SEQUENCE_SPEC \
|
||||
"((" MANYRANGE_SPEC ")?" \
|
||||
"((#|@)+|(%[0-9]*d)))" \
|
||||
"|" \
|
||||
"(" VIEW_SPEC ")"
|
||||
static regex sequence_re(SEQUENCE_SPEC);
|
||||
std::string framespec = "";
|
||||
|
||||
@@ -239,6 +239,21 @@ public:
|
||||
warning(command, Strutil::sprintf(fmt, args...));
|
||||
}
|
||||
|
||||
// Formatted errors with std::format-like notation
|
||||
template<typename... Args>
|
||||
void errorfmt(string_view command, const char* fmt,
|
||||
const Args&... args) const
|
||||
{
|
||||
error(command, Strutil::fmt::format(fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void warningfmt(string_view command, const char* fmt,
|
||||
const Args&... args) const
|
||||
{
|
||||
warning(command, Strutil::fmt::format(fmt, args...));
|
||||
}
|
||||
|
||||
size_t check_peak_memory()
|
||||
{
|
||||
size_t mem = Sysutil::memory_used();
|
||||
|
||||
+12
-12
@@ -161,18 +161,18 @@ dump_flat_data(ImageInput* input, const print_info_options& opt)
|
||||
|
||||
|
||||
// Macro to call a type-specialzed version func<type>(R,...)
|
||||
#define OIIO_DISPATCH_TYPES(ret, name, func, type, R, ...) \
|
||||
switch (type.basetype) { \
|
||||
case TypeDesc::FLOAT: ret = func<float>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::UINT8: ret = func<unsigned char>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::HALF: ret = func<half>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::UINT16: ret = func<unsigned short>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::INT8: ret = func<char>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::INT16: ret = func<short>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::UINT: ret = func<unsigned int>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::INT: ret = func<int>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::DOUBLE: ret = func<double>(R, __VA_ARGS__); break; \
|
||||
default: ret = false; \
|
||||
#define OIIO_DISPATCH_TYPES(ret, name, func, type, R, ...) \
|
||||
switch (type.basetype) { \
|
||||
case TypeDesc::FLOAT: ret = func<float>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::UINT8: ret = func<unsigned char>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::HALF: ret = func<half>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::UINT16: ret = func<unsigned short>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::INT8: ret = func<char>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::INT16: ret = func<short>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::UINT: ret = func<unsigned int>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::INT: ret = func<int>(R, __VA_ARGS__); break; \
|
||||
case TypeDesc::DOUBLE: ret = func<double>(R, __VA_ARGS__); break; \
|
||||
default: ret = false; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,14 +29,14 @@ using boost::math::gcd;
|
||||
#include <OpenEXR/ImfTiledInputFile.h>
|
||||
|
||||
#ifdef OPENEXR_VERSION_MAJOR
|
||||
# define OPENEXR_CODED_VERSION \
|
||||
(OPENEXR_VERSION_MAJOR * 10000 + OPENEXR_VERSION_MINOR * 100 \
|
||||
# define OPENEXR_CODED_VERSION \
|
||||
(OPENEXR_VERSION_MAJOR * 10000 + OPENEXR_VERSION_MINOR * 100 \
|
||||
+ OPENEXR_VERSION_PATCH)
|
||||
#else
|
||||
# define OPENEXR_CODED_VERSION 20000
|
||||
#endif
|
||||
|
||||
#if OPENEXR_CODED_VERSION >= 20400 \
|
||||
#if OPENEXR_CODED_VERSION >= 20400 \
|
||||
|| __has_include(<OpenEXR/ImfFloatVectorAttribute.h>)
|
||||
# define OPENEXR_HAS_FLOATVECTOR 1
|
||||
#else
|
||||
@@ -614,9 +614,9 @@ OpenEXRInput::PartInfo::parse_header(OpenEXRInput* in,
|
||||
case Imf::B44_COMPRESSION: comp = "b44"; break;
|
||||
case Imf::B44A_COMPRESSION: comp = "b44a"; break;
|
||||
#endif
|
||||
#if defined(OPENEXR_VERSION_MAJOR) \
|
||||
&& (OPENEXR_VERSION_MAJOR * 10000 + OPENEXR_VERSION_MINOR * 100 \
|
||||
+ OPENEXR_VERSION_PATCH) \
|
||||
#if defined(OPENEXR_VERSION_MAJOR) \
|
||||
&& (OPENEXR_VERSION_MAJOR * 10000 + OPENEXR_VERSION_MINOR * 100 \
|
||||
+ OPENEXR_VERSION_PATCH) \
|
||||
>= 20200
|
||||
case Imf::DWAA_COMPRESSION: comp = "dwaa"; break;
|
||||
case Imf::DWAB_COMPRESSION: comp = "dwab"; break;
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
#include <OpenEXR/ImfTiledOutputFile.h>
|
||||
|
||||
#ifdef OPENEXR_VERSION_MAJOR
|
||||
# define OPENEXR_CODED_VERSION \
|
||||
(OPENEXR_VERSION_MAJOR * 10000 + OPENEXR_VERSION_MINOR * 100 \
|
||||
# define OPENEXR_CODED_VERSION \
|
||||
(OPENEXR_VERSION_MAJOR * 10000 + OPENEXR_VERSION_MINOR * 100 \
|
||||
+ OPENEXR_VERSION_PATCH)
|
||||
#else
|
||||
# define OPENEXR_CODED_VERSION 20000
|
||||
#endif
|
||||
|
||||
#if OPENEXR_CODED_VERSION >= 20400 \
|
||||
#if OPENEXR_CODED_VERSION >= 20400 \
|
||||
|| __has_include(<OpenEXR/ImfFloatVectorAttribute.h>)
|
||||
# define OPENEXR_HAS_FLOATVECTOR 1
|
||||
#else
|
||||
@@ -891,9 +891,9 @@ OpenEXROutput::put_parameter(const std::string& name, TypeDesc type,
|
||||
else if (Strutil::iequals(str, "b44a"))
|
||||
header.compression() = Imf::B44A_COMPRESSION;
|
||||
#endif
|
||||
#if defined(OPENEXR_VERSION_MAJOR) \
|
||||
&& (OPENEXR_VERSION_MAJOR * 10000 + OPENEXR_VERSION_MINOR * 100 \
|
||||
+ OPENEXR_VERSION_PATCH) \
|
||||
#if defined(OPENEXR_VERSION_MAJOR) \
|
||||
&& (OPENEXR_VERSION_MAJOR * 10000 + OPENEXR_VERSION_MINOR * 100 \
|
||||
+ OPENEXR_VERSION_PATCH) \
|
||||
>= 20200
|
||||
else if (Strutil::iequals(str, "dwaa"))
|
||||
header.compression() = Imf::DWAA_COMPRESSION;
|
||||
|
||||
+18
-16
@@ -19,8 +19,8 @@
|
||||
#include <OpenImageIO/typedesc.h>
|
||||
|
||||
|
||||
#define OIIO_LIBPNG_VERSION \
|
||||
(PNG_LIBPNG_VER_MAJOR * 10000 + PNG_LIBPNG_VER_MINOR * 100 \
|
||||
#define OIIO_LIBPNG_VERSION \
|
||||
(PNG_LIBPNG_VER_MAJOR * 10000 + PNG_LIBPNG_VER_MINOR * 100 \
|
||||
+ PNG_LIBPNG_VER_RELEASE)
|
||||
|
||||
|
||||
@@ -49,11 +49,20 @@ rderr_handler(png_structp png, png_const_charp data)
|
||||
{
|
||||
ImageInput* inp = (ImageInput*)png_get_error_ptr(png);
|
||||
if (inp && data)
|
||||
inp->errorf("PNG read error: %s", data);
|
||||
inp->errorfmt("PNG read error: {}", data);
|
||||
}
|
||||
|
||||
|
||||
static void rdwarn_handler(png_structp /*png*/, png_const_charp /*data*/) {}
|
||||
static void
|
||||
wrerr_handler(png_structp png, png_const_charp data)
|
||||
{
|
||||
ImageOutput* outp = (ImageOutput*)png_get_error_ptr(png);
|
||||
if (outp && data)
|
||||
outp->errorfmt("PNG write error: {}", data);
|
||||
}
|
||||
|
||||
|
||||
static void null_png_handler(png_structp /*png*/, png_const_charp /*data*/) {}
|
||||
|
||||
|
||||
|
||||
@@ -64,11 +73,11 @@ inline const std::string
|
||||
create_read_struct(png_structp& sp, png_infop& ip, ImageInput* inp = nullptr)
|
||||
{
|
||||
sp = png_create_read_struct(PNG_LIBPNG_VER_STRING, inp, rderr_handler,
|
||||
rdwarn_handler);
|
||||
null_png_handler);
|
||||
if (!sp)
|
||||
return "Could not create PNG read structure";
|
||||
|
||||
png_set_error_fn(sp, inp, rderr_handler, rdwarn_handler);
|
||||
png_set_error_fn(sp, inp, rderr_handler, null_png_handler);
|
||||
ip = png_create_info_struct(sp);
|
||||
if (!ip)
|
||||
return "Could not create PNG info structure";
|
||||
@@ -328,20 +337,13 @@ destroy_read_struct(png_structp& sp, png_infop& ip)
|
||||
}
|
||||
|
||||
|
||||
inline void null_png_errhandler(png_structp /*png*/,
|
||||
png_const_charp /*message*/)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Initializes a PNG write struct.
|
||||
/// \return empty string on success, C-string error message on failure.
|
||||
///
|
||||
inline const std::string
|
||||
create_write_struct(png_structp& sp, png_infop& ip, int& color_type,
|
||||
ImageSpec& spec)
|
||||
ImageSpec& spec, ImageOutput* outp = nullptr)
|
||||
{
|
||||
// Check for things this format doesn't support
|
||||
if (spec.width < 1 || spec.height < 1)
|
||||
@@ -377,8 +379,8 @@ create_write_struct(png_structp& sp, png_infop& ip, int& color_type,
|
||||
// N.B. PNG is very rigid about the meaning of the channels, so enforce
|
||||
// which channel is alpha, that's the only way PNG can do it.
|
||||
|
||||
sp = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr,
|
||||
null_png_errhandler, nullptr);
|
||||
sp = png_create_write_struct(PNG_LIBPNG_VER_STRING, outp, wrerr_handler,
|
||||
null_png_handler);
|
||||
if (!sp)
|
||||
return "Could not create PNG write structure";
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ PNGOutput::open(const std::string& name, const ImageSpec& userspec,
|
||||
}
|
||||
|
||||
std::string s = PNG_pvt::create_write_struct(m_png, m_info, m_color_type,
|
||||
m_spec);
|
||||
m_spec, this);
|
||||
if (s.length()) {
|
||||
close();
|
||||
errorf("%s", s);
|
||||
@@ -185,6 +185,34 @@ PNGOutput::open(const std::string& name, const ImageSpec& userspec,
|
||||
png_set_compression_strategy(m_png, Z_DEFAULT_STRATEGY);
|
||||
}
|
||||
|
||||
png_set_filter(m_png, 0,
|
||||
spec().get_int_attribute("png:filter", PNG_NO_FILTERS));
|
||||
// https://www.w3.org/TR/PNG-Encoders.html#E.Filter-selection
|
||||
// https://www.w3.org/TR/PNG-Rationale.html#R.Filtering
|
||||
// The official advice is to PNG_NO_FILTER for palette or < 8 bpp
|
||||
// images, but we and one of the others may be fine for >= 8 bit
|
||||
// greyscale or color images (they aren't very prescriptive, noting that
|
||||
// different flters may be better for different images.
|
||||
// We have found the tradeoff complex, in fact as seen in
|
||||
// https://github.com/OpenImageIO/oiio/issues/2645
|
||||
// where we showed that across several images, 8 (PNG_FILTER_NONE --
|
||||
// don't ask me how that's different from PNG_NO_FILTERS) had the
|
||||
// fastest performance, but also made the largest files. I had trouble
|
||||
// finding a filter choice that for "ordinary" images consistently
|
||||
// performed better than the default on both time and resulting file
|
||||
// size. So for now, we are keeping the default 0 (PNG_NO_FILTERS).
|
||||
|
||||
#if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && defined(PNG_SET_OPTION_SUPPORTED)
|
||||
// libpng by default checks ICC profiles and are very strict, treating
|
||||
// it as a serious error if it doesn't match th profile it thinks is
|
||||
// right for sRGB. This call disables that behavior, which tends to have
|
||||
// many false positives. Some references to discussion about this:
|
||||
// https://github.com/kornelski/pngquant/issues/190
|
||||
// https://sourceforge.net/p/png-mng/mailman/message/32003609/
|
||||
// https://bugzilla.gnome.org/show_bug.cgi?id=721135
|
||||
png_set_option(m_png, PNG_SKIP_sRGB_CHECK_PROFILE, PNG_OPTION_ON);
|
||||
#endif
|
||||
|
||||
PNG_pvt::write_info(m_png, m_info, m_color_type, m_spec, m_pngtext,
|
||||
m_convert_alpha, m_gamma);
|
||||
|
||||
|
||||
@@ -462,10 +462,10 @@ private:
|
||||
// 1) Add ADD_LOADER(<ResourceID>) below
|
||||
// 2) Add a method in PSDInput:
|
||||
// bool load_resource_<ResourceID> (uint32_t length);
|
||||
#define ADD_LOADER(id) \
|
||||
{ \
|
||||
id, std::bind(&PSDInput::load_resource_##id, std::placeholders::_1, \
|
||||
std::placeholders::_2) \
|
||||
#define ADD_LOADER(id) \
|
||||
{ \
|
||||
id, std::bind(&PSDInput::load_resource_##id, std::placeholders::_1, \
|
||||
std::placeholders::_2) \
|
||||
}
|
||||
const PSDInput::ResourceLoader PSDInput::resource_loaders[]
|
||||
= { ADD_LOADER(1005), ADD_LOADER(1006), ADD_LOADER(1010), ADD_LOADER(1033),
|
||||
|
||||
@@ -105,7 +105,7 @@ PtexInput::open(const std::string& name, ImageSpec& newspec)
|
||||
m_ptex->release();
|
||||
m_ptex = NULL;
|
||||
}
|
||||
errorf("%s", perr);
|
||||
errorf("%s", perr.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -190,13 +190,13 @@ PtexInput::seek_subimage(int subimage, int miplevel)
|
||||
wrapmode += "periodic";
|
||||
m_spec.attribute("wrapmode", wrapmode);
|
||||
|
||||
#define GETMETA(pmeta, key, ptype, basetype, typedesc, value) \
|
||||
{ \
|
||||
const ptype* v; \
|
||||
int count; \
|
||||
pmeta->getValue(key, v, count); \
|
||||
typedesc = TypeDesc(basetype, count); \
|
||||
value = (const void*)v; \
|
||||
#define GETMETA(pmeta, key, ptype, basetype, typedesc, value) \
|
||||
{ \
|
||||
const ptype* v; \
|
||||
int count; \
|
||||
pmeta->getValue(key, v, count); \
|
||||
typedesc = TypeDesc(basetype, count); \
|
||||
value = (const void*)v; \
|
||||
}
|
||||
|
||||
PtexMetaData* pmeta = m_ptex->getMetaData();
|
||||
|
||||
@@ -226,8 +226,13 @@ declare_imagespec(py::module& m)
|
||||
"name"_a, "defaultval"_a = "")
|
||||
.def("getattribute", &ImageSpec_getattribute_typed, "name"_a,
|
||||
"type"_a = TypeUnknown)
|
||||
.def("erase_attribute", &ImageSpec::erase_attribute, "name"_a = "",
|
||||
"type"_a = TypeUnknown, "casesensitive"_a = false)
|
||||
.def(
|
||||
"erase_attribute",
|
||||
[](ImageSpec& spec, const std::string& name, TypeDesc type,
|
||||
bool casesensitive = false) {
|
||||
return spec.erase_attribute(name, type, casesensitive);
|
||||
},
|
||||
"name"_a = "", "type"_a = TypeUnknown, "casesensitive"_a = false)
|
||||
|
||||
.def_static(
|
||||
"metadata_val",
|
||||
|
||||
@@ -548,9 +548,9 @@ ParamValue_getitem(const ParamValue& self, bool allitems = false)
|
||||
TypeDesc t = self.type();
|
||||
int nvals = allitems ? self.nvalues() : 1;
|
||||
|
||||
#define ParamValue_convert_dispatch(TYPE) \
|
||||
case TypeDesc::TYPE: \
|
||||
return C_to_val_or_tuple((CType<TypeDesc::TYPE>::type*)self.data(), t, \
|
||||
#define ParamValue_convert_dispatch(TYPE) \
|
||||
case TypeDesc::TYPE: \
|
||||
return C_to_val_or_tuple((CType<TypeDesc::TYPE>::type*)self.data(), t, \
|
||||
nvals)
|
||||
|
||||
switch (t.basetype) {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
#if OIIO_CPLUSPLUS_VERSION >= 17 \
|
||||
#if OIIO_CPLUSPLUS_VERSION >= 17 \
|
||||
&& (OIIO_CLANG_VERSION || OIIO_APPLE_CLANG_VERSION)
|
||||
// libraw uses auto_ptr, which is not in C++17 at all for clang, though
|
||||
// it does seem to be for gcc. So for clang, alias it to unique_ptr.
|
||||
|
||||
@@ -363,11 +363,11 @@ RLAInput::seek_subimage(int subimage, int miplevel)
|
||||
}
|
||||
|
||||
// save some typing by using macros
|
||||
#define FIELD(x, name) \
|
||||
if (m_rla.x > 0) \
|
||||
#define FIELD(x, name) \
|
||||
if (m_rla.x > 0) \
|
||||
m_spec.attribute(name, m_rla.x)
|
||||
#define STRING_FIELD(x, name) \
|
||||
if (m_rla.x[0]) \
|
||||
#define STRING_FIELD(x, name) \
|
||||
if (m_rla.x[0]) \
|
||||
m_spec.attribute(name, m_rla.x)
|
||||
|
||||
STRING_FIELD(Description, "ImageDescription");
|
||||
|
||||
@@ -317,15 +317,15 @@ RLAOutput::open(const std::string& name, const ImageSpec& userspec,
|
||||
set_chromaticity(p, m_rla.WhitePoint, sizeof(m_rla.WhitePoint),
|
||||
"0.31 0.316");
|
||||
|
||||
#define STRING_FIELD(rlafield, name) \
|
||||
{ \
|
||||
std::string s = m_spec.get_string_attribute(name); \
|
||||
if (s.length()) { \
|
||||
strncpy(m_rla.rlafield, s.c_str(), sizeof(m_rla.rlafield)); \
|
||||
m_rla.rlafield[sizeof(m_rla.rlafield) - 1] = 0; \
|
||||
} else { \
|
||||
m_rla.rlafield[0] = 0; \
|
||||
} \
|
||||
#define STRING_FIELD(rlafield, name) \
|
||||
{ \
|
||||
std::string s = m_spec.get_string_attribute(name); \
|
||||
if (s.length()) { \
|
||||
strncpy(m_rla.rlafield, s.c_str(), sizeof(m_rla.rlafield)); \
|
||||
m_rla.rlafield[sizeof(m_rla.rlafield) - 1] = 0; \
|
||||
} else { \
|
||||
m_rla.rlafield[0] = 0; \
|
||||
} \
|
||||
}
|
||||
|
||||
m_rla.JobNumber = m_spec.get_int_attribute("rla:JobNumber", 0);
|
||||
|
||||
@@ -112,8 +112,8 @@ TGAInput::open(const std::string& name, ImageSpec& newspec)
|
||||
// due to struct packing, we may get a corrupt header if we just load the
|
||||
// struct from file; to adress that, read every member individually
|
||||
// save some typing
|
||||
#define RH(memb) \
|
||||
if (!fread(&m_tga.memb, sizeof(m_tga.memb), 1)) \
|
||||
#define RH(memb) \
|
||||
if (!fread(&m_tga.memb, sizeof(m_tga.memb), 1)) \
|
||||
return false
|
||||
|
||||
RH(idlen);
|
||||
|
||||
@@ -169,6 +169,10 @@ serialize(text, human):
|
||||
foo_vector: 1, 0, 11
|
||||
smpte:TimeCode: 01:18:19:06
|
||||
|
||||
|
||||
Added dog: Spot
|
||||
After erasing dog, dog = None
|
||||
|
||||
Testing construction from ROI:
|
||||
resolution (width,height,depth) = 640 480 1
|
||||
origin (x,y,z) = 0 0 0
|
||||
|
||||
@@ -169,6 +169,10 @@ serialize(text, human):
|
||||
foo_vector: 1, 0, 11
|
||||
smpte:TimeCode: 01:18:19:06
|
||||
|
||||
|
||||
Added dog: Spot
|
||||
After erasing dog, dog = None
|
||||
|
||||
Testing construction from ROI:
|
||||
resolution (width,height,depth) = 640 480 1
|
||||
origin (x,y,z) = 0 0 0
|
||||
|
||||
@@ -125,6 +125,13 @@ try:
|
||||
print (s.serialize("xml"))
|
||||
print ("serialize(text, human):")
|
||||
print (s.serialize("text", "detailedhuman"))
|
||||
print ()
|
||||
|
||||
s.attribute("dog", "Spot")
|
||||
print ("Added dog: ", s.getattribute("dog"))
|
||||
s.erase_attribute("dog")
|
||||
print ("After erasing dog, dog = ", s.getattribute("dog"))
|
||||
print()
|
||||
|
||||
# test initialization from ROI
|
||||
print ("Testing construction from ROI:")
|
||||
|
||||
Reference in New Issue
Block a user