-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jpeg): Support reading Ultra HDR images (#4484)
Initial feature request: #4424 Add support in the `jpeg` plugin for reading Ultra HDR images using the reference codec `libultrahdr`: https://github.com/google/libultrahdr In short, "ultra hdr" images are a clever extension of JPEG where the image file really is an old school JPEG file and will be interpreted correctly as such by old readers not aware of ultra hdr, but readers that are aware will see an extra piece of metadata that contains a gain map, that when applied to the base layer then yields an HDR image. Pretty clever approach! Images used for testing during development: https://github.com/MishaalRahmanGH/Ultra_HDR_Samples --------- Signed-off-by: loicvital <[email protected]>
- Loading branch information
Showing
11 changed files
with
273 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright Contributors to the OpenImageIO project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# https://github.com/AcademySoftwareFoundation/OpenImageIO | ||
|
||
###################################################################### | ||
# libuhdr by hand! | ||
###################################################################### | ||
|
||
set_cache (libuhdr_BUILD_VERSION 1.2.0 "libuhdr version for local builds") | ||
set (libuhdr_GIT_REPOSITORY "https://github.com/google/libultrahdr") | ||
set (libuhdr_GIT_TAG "v${libuhdr_BUILD_VERSION}") | ||
|
||
set_cache (libuhdr_BUILD_SHARED_LIBS OFF | ||
DOC "Should execute a local libuhdr build, if necessary, build shared libraries" ADVANCED) | ||
|
||
if (TARGET libjpeg-turbo::jpeg) | ||
# We've had some trouble with libuhdr finding the JPEG resources it needs to | ||
# build if we're using libjpeg-turbo, libuhdr needs an extra nudge. | ||
get_target_property(JPEG_INCLUDE_DIR JPEG::JPEG INTERFACE_INCLUDE_DIRECTORIES) | ||
get_target_property(JPEG_LIBRARY JPEG::JPEG INTERFACE_LINK_LIBRARIES) | ||
endif () | ||
|
||
set_cache (UHDR_CMAKE_C_COMPILER ${CMAKE_C_COMPILER} "libuhdr build C compiler override" ADVANCED) | ||
set_cache (UHDR_CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} "libuhdr build C++ compiler override" ADVANCED) | ||
|
||
build_dependency_with_cmake(libuhdr | ||
VERSION ${libuhdr_BUILD_VERSION} | ||
GIT_REPOSITORY ${libuhdr_GIT_REPOSITORY} | ||
GIT_TAG ${libuhdr_GIT_TAG} | ||
CMAKE_ARGS | ||
-D BUILD_SHARED_LIBS=${libuhdr_BUILD_SHARED_LIBS} | ||
-D CMAKE_INSTALL_LIBDIR=lib | ||
-D CMAKE_POSITION_INDEPENDENT_CODE=ON | ||
-D UHDR_BUILD_EXAMPLES=FALSE | ||
-D UHDR_BUILD_DEPS=FALSE | ||
-D UHDR_ENABLE_LOGS=TRUE | ||
-D JPEG_INCLUDE_DIR=${JPEG_INCLUDE_DIR} | ||
-D JPEG_LIBRARY=${JPEG_LIBRARY} | ||
-D CMAKE_C_COMPILER=${UHDR_CMAKE_C_COMPILER} | ||
-D CMAKE_CXX_COMPILER=${UHDR_CMAKE_CXX_COMPILER} | ||
) | ||
|
||
if (WIN32) | ||
file (GLOB _lib_files "${libuhdr_LOCAL_BUILD_DIR}/Release/*.lib") | ||
file (COPY ${_lib_files} DESTINATION ${libuhdr_LOCAL_INSTALL_DIR}/lib) | ||
unset (_lib_files) | ||
file (GLOB _header_files "${libuhdr_LOCAL_SOURCE_DIR}/ultrahdr_api.h") | ||
file (COPY ${_header_files} DESTINATION ${libuhdr_LOCAL_INSTALL_DIR}/include) | ||
unset (_header_files) | ||
endif () | ||
|
||
set (libuhdr_ROOT ${libuhdr_LOCAL_INSTALL_DIR}) | ||
|
||
find_package(libuhdr REQUIRED) | ||
|
||
set (libuhdr_VERSION ${libuhdr_BUILD_VERSION}) | ||
|
||
if (libuhdr_BUILD_SHARED_LIBS) | ||
install_local_dependency_libs (uhdr uhdr) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Module to find libuhdr | ||
# | ||
# Copyright Contributors to the OpenImageIO project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# https://github.com/AcademySoftwareFoundation/OpenImageIO | ||
# | ||
# This module defines the following variables: | ||
# | ||
# libuhdr_FOUND True if libuhdr was found. | ||
# LIBUHDR_INCLUDE_DIR Where to find libuhdr headers | ||
# LIBUHDR_LIBRARY Library for uhdr | ||
|
||
include (FindPackageHandleStandardArgs) | ||
|
||
find_path(LIBUHDR_INCLUDE_DIR | ||
NAMES | ||
ultrahdr_api.h | ||
PATH_SUFFIXES | ||
include | ||
) | ||
|
||
find_library(LIBUHDR_LIBRARY uhdr | ||
PATH_SUFFIXES | ||
lib | ||
) | ||
|
||
find_package_handle_standard_args (libuhdr | ||
REQUIRED_VARS LIBUHDR_INCLUDE_DIR | ||
LIBUHDR_LIBRARY | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
4080 x 3072, 4 channel, float jpeg | ||
Stats Min: 0.000000 0.000000 0.000000 1.000000 (float) | ||
Stats Max: 1.000000 1.000000 1.000000 1.000000 (float) | ||
Stats Avg: 0.068257 0.077759 0.100931 1.000000 (float) | ||
Stats StdDev: 0.100425 0.102336 0.107618 0.000000 (float) | ||
Stats NanCount: 0 0 0 0 | ||
Stats InfCount: 0 0 0 0 | ||
Stats FiniteCount: 12533760 12533760 12533760 12533760 | ||
Constant: No | ||
Monochrome: No |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright Contributors to the OpenImageIO project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# https://github.com/AcademySoftwareFoundation/OpenImageIO | ||
|
||
|
||
# read and print stats, that tests the read | ||
command += oiiotool (OIIO_TESTSUITE_IMAGEDIR+"/jpeg/ultrahdr/sky.jpg --printstats") |