Skip to content

Commit 58970cb

Browse files
committed
build: Detect libultrahdr version and enforce minimum of 1.3 (#4729)
I discovered, by testing against the latest libultrahdr, that only starting in 1.3 does it support the "64 bit 'half' RGBA" variety of UHDR that is the flavor used by the testsuite example. But our "auto-build" is pegged to 1.2, which means that all along, we were not decoding that test file properly as UHDR and our test reference output was therefore wrong. We also didn't detect libuhdr's version at all, let alone exclude versions that were too old. Remediations: * Amend Findlibuhdr.cmake to detect the version from symbols in its header files. * Have our search for libuhdr enforce a minimum version of 1.3. (I feel bad about "changing minimum dependencies" in a release branch, which we usually disallow, but I think this time is an exception since we know versions < 1.3 are broken.) * Change the auto-build selected version to 1.4, the latest. * Mention libuhdr in the INSTALL description of dependencies and acknowledgement in the docs, where it had previously been omitted in those places. * Update the testsuite/jpeg-ultrahdr test reference output. (You can tell it was wrong before because the "max" channel value was 1.0, and now it's 4.6. Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 030949d commit 58970cb

9 files changed

Lines changed: 49 additions & 10 deletions

File tree

INSTALL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
7474
* Ptex >= 2.3.1 (probably works for older; tested through 2.4.3)
7575
* If you want to be able to do font rendering into images:
7676
* **Freetype >= 2.10.0** (tested through 2.13)
77+
* If you want to be able to read "ultra-HDR" embedded in JPEG files:
78+
* libultrahdr >= 1.3 (tested through 1.4)
7779
* We use PugiXML for XML parsing. There is a version embedded in the OIIO
7880
tree, but if you want to use an external, system-installed version (as
7981
may be required by some software distributions with policies against

src/build-scripts/install_homebrew_deps.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ brew link --overwrite --force python@${PYTHON_VERSION} || true
3939
#brew install --display-times -q libtiff
4040
brew install --display-times -q imath openexr opencolorio
4141
#brew install --display-times -q libpng giflib webp
42-
brew install --display-times -q jpeg-turbo openjpeg
42+
brew install --display-times -q jpeg-turbo openjpeg libultrahdr
4343
brew install --display-times -q freetype libraw dcmtk pybind11 numpy || true
4444
brew install --display-times -q ffmpeg libheif ptex || true
4545
brew install --display-times -q tbb || true

src/cmake/build_libuhdr.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# libuhdr by hand!
77
######################################################################
88

9-
set_cache (libuhdr_BUILD_VERSION 1.2.0 "libuhdr version for local builds")
9+
set_cache (libuhdr_BUILD_VERSION 1.4.0 "libultrahdr version for local builds")
1010
set (libuhdr_GIT_REPOSITORY "https://github.com/google/libultrahdr")
1111
set (libuhdr_GIT_TAG "v${libuhdr_BUILD_VERSION}")
1212

src/cmake/externalpackages.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ endif ()
8787

8888

8989
# Ultra HDR
90-
checked_find_package (libuhdr)
91-
90+
checked_find_package (libuhdr
91+
VERSION_MIN 1.3)
9292

9393
checked_find_package (TIFF REQUIRED
9494
VERSION_MIN 4.0)

src/cmake/modules/Findlibuhdr.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# libuhdr_FOUND True if libuhdr was found.
1010
# LIBUHDR_INCLUDE_DIR Where to find libuhdr headers
1111
# LIBUHDR_LIBRARY Library for uhdr
12+
# LIBUHDR_VERSION Version of the library
1213

1314
include (FindPackageHandleStandardArgs)
1415

@@ -24,7 +25,34 @@ find_library(LIBUHDR_LIBRARY uhdr
2425
lib
2526
)
2627

28+
if (LIBUHDR_INCLUDE_DIR)
29+
file (STRINGS "${LIBUHDR_INCLUDE_DIR}/ultrahdr_api.h" TMP REGEX "^#define UHDR_LIB_VER_MAJOR .*$")
30+
string (REGEX MATCHALL "[0-9]+" LIBUHDR_VERSION_MAJOR ${TMP})
31+
file (STRINGS "${LIBUHDR_INCLUDE_DIR}/ultrahdr_api.h" TMP REGEX "^#define UHDR_LIB_VER_MINOR .*$")
32+
string (REGEX MATCHALL "[0-9]+" LIBUHDR_VERSION_MINOR ${TMP})
33+
file (STRINGS "${LIBUHDR_INCLUDE_DIR}/ultrahdr_api.h" TMP REGEX "^#define UHDR_LIB_VER_PATCH .*$")
34+
string (REGEX MATCHALL "[0-9]+" LIBUHDR_VERSION_PATCH ${TMP})
35+
set (LIBUHDR_VERSION "${LIBUHDR_VERSION_MAJOR}.${LIBUHDR_VERSION_MINOR}.${LIBUHDR_VERSION_PATCH}")
36+
endif ()
37+
2738
find_package_handle_standard_args (libuhdr
2839
REQUIRED_VARS LIBUHDR_INCLUDE_DIR
2940
LIBUHDR_LIBRARY
41+
VERSION_VAR LIBUHDR_VERSION
3042
)
43+
44+
if (LIBUHDR_FOUND)
45+
set(LIBUHDR_LIBRARIES ${LIBUHDR_LIBRARY})
46+
set(LIBUHDR_INCLUDES ${LIBUHDR_INCLUDE_DIR})
47+
if (NOT TARGET libuhdr::libuhdr)
48+
add_library(libuhdr::libuhdr UNKNOWN IMPORTED)
49+
set_target_properties(libuhdr::libuhdr PROPERTIES
50+
INTERFACE_INCLUDE_DIRECTORIES "${LIBUHDR_INCLUDES}")
51+
set_property(TARGET libuhdr::libuhdr APPEND PROPERTY
52+
IMPORTED_LOCATION "${LIBUHDR_LIBRARIES}")
53+
endif ()
54+
else ()
55+
unset (LIBUHDR_INCLUDE_DIR)
56+
unset (LIBUHDR_LIBRARY)
57+
unset (LIBUHDR_VERSION)
58+
endif()

src/doc/oiiointro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,4 @@ against dynamic libraries:
267267
* OpenVDB © 2012-2018 DreamWorks Animation LLC, Mozilla Public License 2.0. https://www.openvdb.org/
268268
* Thread Building Blocks © Intel. Apache 2.0 license. https://www.threadingbuildingblocks.org/
269269
* libheif © 2017-2018 Struktur AG (LGPL). https://github.com/strukturag/libheif
270-
270+
* libultrahdr © 2022 The Android Open Source Project. Apache 2.0 license. https://github.com/google/libultrahdr

src/jpeg.imageio/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ else ()
1111
endif ()
1212

1313
add_oiio_plugin (jpeginput.cpp jpegoutput.cpp
14-
INCLUDE_DIRS ${LIBUHDR_INCLUDE_DIR}
1514
LINK_LIBRARIES
1615
$<TARGET_NAME_IF_EXISTS:libjpeg-turbo::jpeg>
1716
$<TARGET_NAME_IF_EXISTS:JPEG::JPEG>
18-
${LIBUHDR_LIBRARY}
17+
$<TARGET_NAME_IF_EXISTS:libuhdr::libuhdr>
1918
DEFINITIONS "${UHDR_DEFS}"
2019
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
4080 x 3072, 4 channel, float jpeg
2+
Stats Min: 0.000000 0.000000 0.000000 1.000000 (float)
3+
Stats Max: 4.613281 4.613281 4.613281 1.000000 (float)
4+
Stats Avg: 0.314777 0.358598 0.465455 1.000000 (float)
5+
Stats StdDev: 0.463126 0.471940 0.496298 0.000000 (float)
6+
Stats NanCount: 0 0 0 0
7+
Stats InfCount: 0 0 0 0
8+
Stats FiniteCount: 12533760 12533760 12533760 12533760
9+
Constant: No
10+
Monochrome: No

testsuite/jpeg-ultrahdr/ref/out.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
4080 x 3072, 4 channel, float jpeg
22
Stats Min: 0.000000 0.000000 0.000000 1.000000 (float)
3-
Stats Max: 1.000000 1.000000 1.000000 1.000000 (float)
4-
Stats Avg: 0.068257 0.077759 0.100931 1.000000 (float)
5-
Stats StdDev: 0.100425 0.102336 0.107618 0.000000 (float)
3+
Stats Max: 4.613281 4.613281 4.613281 1.000000 (float)
4+
Stats Avg: 0.314776 0.358598 0.465455 1.000000 (float)
5+
Stats StdDev: 0.463126 0.471940 0.496298 0.000000 (float)
66
Stats NanCount: 0 0 0 0
77
Stats InfCount: 0 0 0 0
88
Stats FiniteCount: 12533760 12533760 12533760 12533760

0 commit comments

Comments
 (0)