Skip to content

Commit

Permalink
build: ensure libuhdr build recipe points to correct JPEG package
Browse files Browse the repository at this point in the history
Signed-off-by: loicvital <[email protected]>
  • Loading branch information
mugulmd committed Nov 6, 2024
1 parent 2a5fc74 commit 398a34b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
14 changes: 14 additions & 0 deletions src/cmake/build_libuhdr.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ 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)

# CI debugging
if (TARGET libjpeg-turbo::jpeg)
get_target_property(JPEG_INCLUDE_DIR JPEG::JPEG INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(JPEG_LIBRARY JPEG::JPEG INTERFACE_LINK_LIBRARIES)
endif ()
message("[libuhdr] JPEG_INCLUDE_DIR=${JPEG_INCLUDE_DIR}")
message("[libuhdr] JPEG_LIBRARY=${JPEG_LIBRARY}")

build_dependency_with_cmake(libuhdr
VERSION ${libuhdr_BUILD_VERSION}
GIT_REPOSITORY ${libuhdr_GIT_REPOSITORY}
Expand All @@ -22,7 +30,13 @@ build_dependency_with_cmake(libuhdr
-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}
# Debug: force gcc/g++ compiler for libuhdr
-D CMAKE_C_COMPILER=gcc
-D CMAKE_CXX_COMPILER=g++
)

if (WIN32)
Expand Down
8 changes: 4 additions & 4 deletions src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ else ()
endif ()


# Ultra HDR
checked_find_package (libuhdr)


checked_find_package (TIFF REQUIRED
VERSION_MIN 4.0)
alias_library_if_not_exists (TIFF::TIFF TIFF::tiff)
Expand Down Expand Up @@ -226,10 +230,6 @@ checked_find_package (fmt REQUIRED
get_target_property(FMT_INCLUDE_DIR fmt::fmt-header-only INTERFACE_INCLUDE_DIRECTORIES)


# Ultra HDR
checked_find_package (libuhdr)


###########################################################################

list (SORT CFP_ALL_BUILD_DEPS_FOUND COMPARE STRING CASE INSENSITIVE)
Expand Down
6 changes: 5 additions & 1 deletion src/jpeg.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

if (libuhdr_FOUND)
set (UHDR_DEFS USE_UHDR)
else ()
set (LIBUHDR_INCLUDE_DIR "")
set (LIBUHDR_LIBRARY "")
set (UHDR_DEFS "")
endif ()

add_oiio_plugin (jpeginput.cpp jpegoutput.cpp
Expand All @@ -12,5 +16,5 @@ add_oiio_plugin (jpeginput.cpp jpegoutput.cpp
$<TARGET_NAME_IF_EXISTS:libjpeg-turbo::jpeg>
$<TARGET_NAME_IF_EXISTS:JPEG::JPEG>
${LIBUHDR_LIBRARY}
DEFINITIONS ${UHDR_DEFS}
DEFINITIONS "${UHDR_DEFS}"
)
15 changes: 13 additions & 2 deletions src/jpeg.imageio/jpeginput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ JpgInput::open(const std::string& name, ImageSpec& newspec)
if (m_spec.find_attribute("hdrgm:Version"))
m_is_uhdr = read_uhdr(m_io);

if (m_spec.find_attribute("hdrgm:Version") && !m_is_uhdr) {
std::cout << "[libuhdr] out color space: " << m_cinfo.out_color_space << std::endl;
std::cout << "[libuhdr] jpeg color space: " << m_cinfo.jpeg_color_space << std::endl;
std::cout << "[libuhdr] num components: " << m_cinfo.num_components << std::endl;
std::cout << "[libuhdr] img height: " << m_cinfo.image_height << std::endl;
std::cout << "[libuhdr] img width: " << m_cinfo.image_width << std::endl;
}

newspec = m_spec;
return true;
}
Expand Down Expand Up @@ -426,7 +434,8 @@ JpgInput::read_uhdr(Filesystem::IOProxy* ioproxy)
// Check if this is an actual Ultra HDR image.
const bool detect_uhdr = is_uhdr_image(buffer.data(), buffer.size());
if (!detect_uhdr)
return false;
std::cout << "[libuhdr] detect uhdr returned false";
//return false;

// Create Ultra HDR decoder.
// Do not forget to release it once we don't need it,
Expand All @@ -448,10 +457,12 @@ JpgInput::read_uhdr(Filesystem::IOProxy* ioproxy)
uhdr_error_info_t err_info = uhdr_decode(m_uhdr_dec);

if (err_info.error_code != UHDR_CODEC_OK) {
std::cout << "[libuhdr] error code: " << err_info.error_code << std::endl;
errorfmt("Ultra HDR decoding failed with error code {}",
int(err_info.error_code));
if (err_info.has_detail != 0)
errorfmt("Additional error details: {}", err_info.detail);
std::cout << "[libuhdr] error detail: " << err_info.detail << std::endl;
//errorfmt("Additional error details: {}", err_info.detail);
uhdr_release_decoder(m_uhdr_dec);
return false;
}
Expand Down

0 comments on commit 398a34b

Please sign in to comment.