Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTJ2K Compressor #1883

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ cc_library(
"src/lib/OpenEXRCore/internal_dwa_simd.h",
"src/lib/OpenEXRCore/internal_file.h",
"src/lib/OpenEXRCore/internal_float_vector.h",
"src/lib/OpenEXRCore/internal_ht.cpp",
"src/lib/OpenEXRCore/internal_htk.cpp",
"src/lib/OpenEXRCore/internal_ht_common.cpp",
"src/lib/OpenEXRCore/internal_huf.c",
"src/lib/OpenEXRCore/internal_huf.h",
"src/lib/OpenEXRCore/internal_memory.h",
Expand Down
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# docker build --rm -f Dockerfile -t openexr-ht:latest .
# docker run -it --rm -v C:\\temp:/tmp/ openexr-ht:latest
FROM ubuntu:jammy

RUN apt-get update

# disable interactive install
ENV DEBIAN_FRONTEND noninteractive

# install developement tools
RUN apt-get -y install cmake
RUN apt-get -y install g++
RUN apt-get -y install git
RUN apt-get -y install unzip
RUN apt-get -y install libnuma-dev
RUN apt-get -y install python3

# install developement debugging tools
RUN apt-get -y install valgrind

# build OpenEXR
WORKDIR /usr/src/OpenEXR
COPY . .
WORKDIR /usr/src/OpenEXR/build
RUN cmake ..
RUN make
RUN make install

# finalize docker environment



53 changes: 53 additions & 0 deletions Dockerfile_KDU
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# run this docker file outside the openexr-ht folder so Kakadu SDK ZIP is not included in the git repo
# docker build --rm -f ./openexr-ht/Dockerfile_KDU -t openexr-ht-kdu:latest .
# docker run -it --rm -v C:\\temp:/tmp/ openexr-ht-kdu:latest
FROM ubuntu:jammy

RUN apt-get update

# disable interactive install
ENV DEBIAN_FRONTEND noninteractive

# install developement tools
RUN apt-get -y install cmake
RUN apt-get -y install g++
RUN apt-get -y install git
RUN apt-get -y install unzip
RUN apt-get -y install libnuma-dev
RUN apt-get -y install python3

# install developement debugging tools
RUN apt-get -y install valgrind

# set Kakadu distribution version and unique serial number
ARG KDU_SOURCE_NAME=v8_4_1-00462N
# set path to location of source zip, in this case its here ./v8_2_1-00462N.zip
ARG KDU_SOURCE_ZIP_DIRECTORY=./
WORKDIR /usr/src/kakadu
COPY $KDU_SOURCE_ZIP_DIRECTORY/$KDU_SOURCE_NAME.zip $KDU_SOURCE_NAME.zip
RUN unzip $KDU_SOURCE_NAME.zip
RUN rm -f $KDU_SOURCE_NAME.zip
# enable HTJ2K
WORKDIR /usr/src/kakadu/$KDU_SOURCE_NAME/
RUN mv srclib_ht srclib_ht_noopt; cp -r altlib_ht_opt srclib_ht
# compile Kakadu SDK and demo apps with HTJ2K enabled (#define FBC_ENABLED)
WORKDIR /usr/src/kakadu/$KDU_SOURCE_NAME/make
RUN make CXXFLAGS=-DFBC_ENABLED -f Makefile-Linux-x86-64-gcc all_but_jni
# set environment variables
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/src/kakadu/$KDU_SOURCE_NAME/lib/Linux-x86-64-gcc
ENV PATH=$PATH:/usr/src/kakadu/$KDU_SOURCE_NAME/bin/Linux-x86-64-gcc
ENV KDU_INCLUDE_DIR=/usr/src/kakadu/$KDU_SOURCE_NAME/managed/all_includes
ENV KDU_LIBRARY=/usr/src/kakadu/$KDU_SOURCE_NAME/lib/Linux-x86-64-gcc/libkdu_a84R.so

# build OpenEXR
WORKDIR /usr/src/OpenEXR
COPY ./openexr-ht .
WORKDIR /usr/src/OpenEXR/build
RUN cmake .. -DKDU_INCLUDE_DIR=$KDU_INCLUDE_DIR -DKDU_LIBRARY=$KDU_LIBRARY
RUN make
RUN make install

# finalize docker environment



12 changes: 6 additions & 6 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

install(EXPORT ${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
EXPORT_LINK_INTERFACE_LIBRARIES
)
# install(EXPORT ${PROJECT_NAME}
# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
# FILE ${PROJECT_NAME}Targets.cmake
# NAMESPACE ${PROJECT_NAME}::
# EXPORT_LINK_INTERFACE_LIBRARIES
# )
endif()
19 changes: 18 additions & 1 deletion cmake/LibraryDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ function(OPENEXR_DEFINE_LIBRARY libname)
PRIVATE cxx_std_${OPENEXR_CXX_STANDARD}
INTERFACE cxx_std_17 )

# we are embedding OpenJPH
target_include_directories(${objlib} PRIVATE ${openjph_SOURCE_DIR}/src/core/common)

# we are including KDU
if( KDU_INCLUDE_DIR )
target_include_directories(${objlib} PRIVATE ${KDU_INCLUDE_DIR})
endif()

# we are embedding libdeflate
target_include_directories(${objlib} PRIVATE ${EXR_DEFLATE_INCLUDE_DIR})

Expand All @@ -40,7 +48,16 @@ function(OPENEXR_DEFINE_LIBRARY libname)
if(OPENEXR_CURLIB_CURBINDIR)
target_include_directories(${objlib} PRIVATE $<BUILD_INTERFACE:${OPENEXR_CURLIB_CURBINDIR}>)
endif()
target_link_libraries(${objlib} PUBLIC ${PROJECT_NAME}::Config ${OPENEXR_CURLIB_DEPENDENCIES})

if(KDU_LIBRARY)
target_compile_definitions(${objlib} PRIVATE KDU_AVAILABLE=1)
endif()

if(KDU_LIBRARY)
target_link_libraries(${objlib} PUBLIC ${PROJECT_NAME}::Config ${OPENEXR_CURLIB_DEPENDENCIES} ${KDU_LIBRARY} ${CMAKE_DL_LIBS} openjph)
else()
target_link_libraries(${objlib} PUBLIC ${PROJECT_NAME}::Config ${OPENEXR_CURLIB_DEPENDENCIES} ${CMAKE_DL_LIBS} openjph)
endif()
if(OPENEXR_CURLIB_PRIVATE_DEPS)
target_link_libraries(${objlib} PRIVATE ${OPENEXR_CURLIB_PRIVATE_DEPS})
endif()
Expand Down
31 changes: 31 additions & 0 deletions cmake/OpenEXRSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,37 @@ else()
set(EXR_DEFLATE_LIB)
endif()


#######################################
# Get OpenJPH
#######################################

message(STATUS "Fetching OpenJPH")

include(FetchContent)
FetchContent_Declare(
openjph
GIT_REPOSITORY https://github.com/aous72/OpenJPH
GIT_TAG origin/master
)

FetchContent_MakeAvailable(openjph)
set_property(DIRECTORY ${openjph_SOURCE_DIR} PROPERTY OJPH_ENABLE_TIFF_SUPPORT OFF)
set_property(DIRECTORY ${openjph_SOURCE_DIR} PROPERTY OJPH_BUILD_TESTS OFF)
set_property(DIRECTORY ${openjph_SOURCE_DIR} PROPERTY OJPH_BUILD_EXECUTABLES OFF)

#######################################
# Get KDU
#######################################

message(STATUS "Fetching KDU")
find_path(KDU_INCLUDE_DIR kdu_args.h PATH_SUFFIXES kakadu kdu)
find_library(KDU_LIBRARY NAMES kdu_a84R PATH_SUFFIXES kakadu kdu)

if(NOT(KDU_INCLUDE_DIR) OR NOT(KDU_LIBRARY))
message("Kakadu SDK not found: ${KDU_LIBRARY} and ${KDU_INCLUDE_DIR}.")
endif()

#######################################
# Find or install Imath
#######################################
Expand Down
2 changes: 2 additions & 0 deletions src/bin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ add_subdirectory( exrmultiview )
add_subdirectory( exrmultipart )
add_subdirectory( exrcheck )
add_subdirectory( exrmanifest )
add_subdirectory( exrperf )
add_subdirectory( exrconv )
15 changes: 15 additions & 0 deletions src/bin/exrconv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenEXR Project.

add_executable(exrconv main.cpp)
target_link_libraries(exrconv OpenEXR::OpenEXR)
set_target_properties(exrconv PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)

if(OPENEXR_INSTALL_TOOLS)
install(TARGETS exrconv DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED))
target_compile_definitions(exrconv PRIVATE OPENEXR_DLL)
endif()
Loading
Loading