Skip to content

Commit ea8022e

Browse files
palemieuxcary-ilm
andcommitted
Add HTJ2K Compressor (AcademySoftwareFoundation#1883)
* Add HT256 compressor Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.h Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.cpp Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update website/ReadingAndWritingImageFiles.rst Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Add channel map Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> --------- Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Co-authored-by: Cary Phillips <cary@ilm.com>
1 parent 39b9d24 commit ea8022e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1088
-11
lines changed

.github/workflows/ci_steps.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ on:
4949
type: string
5050
OPENEXR_FORCE_INTERNAL_DEFLATE:
5151
type: string
52+
OPENEXR_FORCE_INTERNAL_OPENJPH:
53+
type: string
5254
BUILD_TESTING:
5355
type: string
5456
namespace:
@@ -108,6 +110,11 @@ jobs:
108110
run: share/ci/scripts/install_libdeflate.sh master
109111
shell: bash
110112

113+
- name: Install OpenJPH
114+
# Pre-install OpenJPH so the builds validate finding the external installation
115+
if: ${{ inputs.OPENEXR_FORCE_INTERNAL_OPENJPH == 'OFF' }}
116+
run: share/ci/scripts/install_openjph.sh master
117+
111118
- name: Set PATH for Imath/libdeflate DLLs
112119
# When building against external Imath/libdeflate shared objects, the tests need PATH to include the dll's.
113120
if: contains(inputs.os, 'windows') && inputs.msystem == ''
@@ -144,6 +151,7 @@ jobs:
144151
cmake_args+=("-DOPENEXR_BUILD_TOOLS=${{ inputs.OPENEXR_BUILD_TOOLS }}")
145152
cmake_args+=("-DOPENEXR_FORCE_INTERNAL_IMATH=${{ inputs.OPENEXR_FORCE_INTERNAL_IMATH }}")
146153
cmake_args+=("-DOPENEXR_FORCE_INTERNAL_DEFLATE=${{ inputs.OPENEXR_FORCE_INTERNAL_DEFLATE }}")
154+
cmake_args+=("-DOPENEXR_FORCE_INTERNAL_OPENJPH=${{ inputs.OPENEXR_FORCE_INTERNAL_OPENJPH }}")
147155
cmake_args+=("-DBUILD_TESTING=${{ inputs.BUILD_TESTING }}")
148156
cmake_args+=("-DOPENEXR_RUN_FUZZ_TESTS=OFF")
149157
cmake_args+=("-DCMAKE_VERBOSE_MAKEFILE=ON")
@@ -214,4 +222,3 @@ jobs:
214222
share/ci/scripts/validate_install.py "_build/$INSTALL_MANIFEST" "share/ci/install_manifest/$INSTALL_MANIFEST"
215223
shell: bash
216224

217-

.github/workflows/ci_workflow.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878
OPENEXR_BUILD_TOOLS: ${{ matrix.OPENEXR_BUILD_TOOLS || 'ON' }}
7979
OPENEXR_FORCE_INTERNAL_IMATH: ${{ matrix.OPENEXR_FORCE_INTERNAL_IMATH || 'OFF' }}
8080
OPENEXR_FORCE_INTERNAL_DEFLATE: ${{ matrix.OPENEXR_FORCE_INTERNAL_DEFLATE || 'OFF' }}
81+
OPENEXR_FORCE_INTERNAL_OPENJPH: ${{ matrix.OPENEXR_FORCE_INTERNAL_OPENJPH || 'OFF' }}
8182
BUILD_TESTING: ${{ matrix.BUILD_TESTING || 'ON' }}
8283
namespace: ${{ matrix.namespace }}
8384
validate_install: ${{ matrix.validate_install || 'ON' }}
@@ -110,6 +111,7 @@ jobs:
110111
OPENEXR_BUILD_TOOLS: 'OFF'
111112
OPENEXR_FORCE_INTERNAL_IMATH: 'ON'
112113
OPENEXR_FORCE_INTERNAL_DEFLATE: 'ON'
114+
OPENEXR_FORCE_INTERNAL_OPENJPH: 'ON'
113115
BUILD_TESTING: 'OFF'
114116

115117
- build: 6
@@ -144,6 +146,7 @@ jobs:
144146
OPENEXR_BUILD_TOOLS: ${{ matrix.OPENEXR_BUILD_TOOLS || 'ON' }}
145147
OPENEXR_FORCE_INTERNAL_IMATH: ${{ matrix.OPENEXR_FORCE_INTERNAL_IMATH || 'OFF' }}
146148
OPENEXR_FORCE_INTERNAL_DEFLATE: ${{ matrix.OPENEXR_FORCE_INTERNAL_DEFLATE || 'OFF' }}
149+
OPENEXR_FORCE_INTERNAL_OPENJPH: ${{ matrix.OPENEXR_FORCE_INTERNAL_OPENJPH || 'OFF' }}
147150
BUILD_TESTING: ${{ matrix.BUILD_TESTING || 'ON' }}
148151
validate_install: ${{ matrix.validate_install || 'ON' }}
149152

@@ -175,6 +178,7 @@ jobs:
175178
OPENEXR_BUILD_TOOLS: 'OFF'
176179
OPENEXR_FORCE_INTERNAL_IMATH: 'ON'
177180
OPENEXR_FORCE_INTERNAL_DEFLATE: 'ON'
181+
OPENEXR_FORCE_INTERNAL_OPENJPH: 'ON'
178182
BUILD_TESTING: 'OFF'
179183

180184
- build: 6
@@ -200,6 +204,7 @@ jobs:
200204
OPENEXR_BUILD_TOOLS: ${{ matrix.OPENEXR_BUILD_TOOLS || 'ON' }}
201205
OPENEXR_FORCE_INTERNAL_IMATH: ${{ matrix.OPENEXR_FORCE_INTERNAL_IMATH || 'OFF' }}
202206
OPENEXR_FORCE_INTERNAL_DEFLATE: ${{ matrix.OPENEXR_FORCE_INTERNAL_DEFLATE || 'OFF' }}
207+
OPENEXR_FORCE_INTERNAL_OPENJPH: ${{ matrix.OPENEXR_FORCE_INTERNAL_OPENJPH || 'OFF' }}
203208
msystem: ${{ matrix.msystem }}
204209
BUILD_TESTING: ${{ matrix.BUILD_TESTING || 'ON' }}
205210
validate_install: ${{ matrix.validate_install || 'ON' }}
@@ -232,6 +237,7 @@ jobs:
232237
OPENEXR_BUILD_TOOLS: 'OFF'
233238
OPENEXR_FORCE_INTERNAL_IMATH: 'ON'
234239
OPENEXR_FORCE_INTERNAL_DEFLATE: 'ON'
240+
OPENEXR_FORCE_INTERNAL_OPENJPH: 'ON'
235241
BUILD_TESTING: 'OFF'
236242

237243
- build: 6

.github/workflows/python-wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ jobs:
8989
name: wheels-${{ matrix.os }}-${{ matrix.arch }}
9090
path: |
9191
./wheelhouse/*.whl
92-
./wheelhouse/*.tar.gz
92+
./wheelhouse/*.tar.gz

BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ cc_library(
190190
"src/lib/OpenEXRCore/internal_dwa_simd.h",
191191
"src/lib/OpenEXRCore/internal_file.h",
192192
"src/lib/OpenEXRCore/internal_float_vector.h",
193+
"src/lib/OpenEXRCore/internal_ht.cpp",
194+
"src/lib/OpenEXRCore/internal_ht_common.h",
195+
"src/lib/OpenEXRCore/internal_ht_common.cpp",
193196
"src/lib/OpenEXRCore/internal_huf.c",
194197
"src/lib/OpenEXRCore/internal_huf.h",
195198
"src/lib/OpenEXRCore/internal_memory.h",
@@ -263,6 +266,7 @@ cc_library(
263266
visibility = ["//visibility:public"],
264267
deps = [
265268
"@imath",
269+
"@openjph",
266270
"@libdeflate//:deflate",
267271
],
268272
)
@@ -309,6 +313,7 @@ cc_library(
309313
"src/lib/OpenEXR/ImfGenericInputFile.cpp",
310314
"src/lib/OpenEXR/ImfGenericOutputFile.cpp",
311315
"src/lib/OpenEXR/ImfHeader.cpp",
316+
"src/lib/OpenEXR/ImfHTCompressor.cpp",
312317
"src/lib/OpenEXR/ImfHuf.cpp",
313318
"src/lib/OpenEXR/ImfIDManifest.cpp",
314319
"src/lib/OpenEXR/ImfIDManifestAttribute.cpp",
@@ -414,6 +419,7 @@ cc_library(
414419
"src/lib/OpenEXR/ImfGenericInputFile.h",
415420
"src/lib/OpenEXR/ImfGenericOutputFile.h",
416421
"src/lib/OpenEXR/ImfHeader.h",
422+
"src/lib/OpenEXR/ImfHTCompressor.h",
417423
"src/lib/OpenEXR/ImfHuf.h",
418424
"src/lib/OpenEXR/ImfIDManifest.h",
419425
"src/lib/OpenEXR/ImfIDManifestAttribute.h",
@@ -505,6 +511,7 @@ cc_library(
505511
":IlmThread",
506512
":OpenEXRCore",
507513
"@imath",
514+
"@openjph"
508515
],
509516
)
510517

MODULE.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module(
88

99
bazel_dep(name = "bazel_skylib", version = "1.7.1")
1010
bazel_dep(name = "imath")
11+
bazel_dep(name = "openjph")
1112
bazel_dep(name = "libdeflate")
1213
bazel_dep(name = "platforms", version = "0.0.11")
1314
bazel_dep(name = "rules_cc", version = "0.1.1")
@@ -31,3 +32,13 @@ archive_override(
3132
strip_prefix = "libdeflate-master",
3233
urls = ["https://github.com/ebiggers/libdeflate/archive/refs/heads/master.zip"],
3334
)
35+
36+
archive_override(
37+
module_name = "openjph",
38+
patches = [
39+
"//bazel:openjph_add_build_file.patch",
40+
"//bazel:openjph_module_dot_bazel.patch",
41+
],
42+
strip_prefix = "OpenJPH-add-export",
43+
urls = ["https://github.com/palemieux/OpenJPH/archive/refs/heads/add-export.zip"],
44+
)

bazel/openjph_add_build_file.patch

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
--- /dev/null
2+
+++ BUILD.bazel
3+
@@ -0,0 +1,116 @@
4+
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
5+
+load("@rules_license//rules:license.bzl", "license")
6+
+
7+
+package(
8+
+ default_applicable_licenses = [":license"],
9+
+)
10+
+
11+
+exports_files([
12+
+ "LICENSE",
13+
+])
14+
+
15+
+license(
16+
+ name = "license",
17+
+ license_kinds = ["@rules_license//licenses/spdx:BSD-2-Clause"],
18+
+ license_text = "LICENSE",
19+
+)
20+
+
21+
+cc_binary(
22+
+ name = "ojph_compress",
23+
+ srcs = ["src/apps/ojph_compress/ojph_compress.cpp"],
24+
+ visibility = ["//visibility:public"],
25+
+ deps = [":ojph_expand"],
26+
+)
27+
+
28+
+cc_library(
29+
+ name = "ojph_expand",
30+
+ srcs = [
31+
+ "src/apps/ojph_expand/ojph_expand.cpp",
32+
+ "src/apps/others/ojph_img_io.cpp",
33+
+ ],
34+
+ hdrs = [
35+
+ "src/apps/common/ojph_img_io.h",
36+
+ ],
37+
+ includes = [
38+
+ "src/apps/common",
39+
+ ],
40+
+ visibility = ["//visibility:public"],
41+
+ deps = [":openjph"],
42+
+)
43+
+
44+
+cc_library(
45+
+ name = "openjph",
46+
+ srcs = [
47+
+ "src/core/codestream/ojph_bitbuffer_read.h",
48+
+ "src/core/codestream/ojph_bitbuffer_write.h",
49+
+ "src/core/codestream/ojph_codeblock.cpp",
50+
+ "src/core/codestream/ojph_codeblock.h",
51+
+ "src/core/codestream/ojph_codeblock_fun.cpp",
52+
+ "src/core/codestream/ojph_codeblock_fun.h",
53+
+ "src/core/codestream/ojph_codestream.cpp",
54+
+ "src/core/codestream/ojph_codestream_gen.cpp",
55+
+ "src/core/codestream/ojph_codestream_local.cpp",
56+
+ "src/core/codestream/ojph_codestream_local.h",
57+
+ "src/core/codestream/ojph_params.cpp",
58+
+ "src/core/codestream/ojph_params_local.h",
59+
+ "src/core/codestream/ojph_precinct.cpp",
60+
+ "src/core/codestream/ojph_precinct.h",
61+
+ "src/core/codestream/ojph_resolution.cpp",
62+
+ "src/core/codestream/ojph_resolution.h",
63+
+ "src/core/codestream/ojph_subband.cpp",
64+
+ "src/core/codestream/ojph_subband.h",
65+
+ "src/core/codestream/ojph_tile.cpp",
66+
+ "src/core/codestream/ojph_tile.h",
67+
+ "src/core/codestream/ojph_tile_comp.cpp",
68+
+ "src/core/codestream/ojph_tile_comp.h",
69+
+ "src/core/coding/ojph_block_common.cpp",
70+
+ "src/core/coding/ojph_block_common.h",
71+
+ "src/core/coding/ojph_block_decoder.h",
72+
+ "src/core/coding/ojph_block_decoder32.cpp",
73+
+ "src/core/coding/ojph_block_decoder64.cpp",
74+
+ "src/core/coding/ojph_block_encoder.cpp",
75+
+ "src/core/coding/ojph_block_encoder.h",
76+
+ "src/core/coding/table0.h",
77+
+ "src/core/coding/table1.h",
78+
+ "src/core/common/ojph_arch.h",
79+
+ "src/core/common/ojph_base.h",
80+
+ "src/core/common/ojph_codestream.h",
81+
+ "src/core/common/ojph_defs.h",
82+
+ "src/core/common/ojph_file.h",
83+
+ "src/core/common/ojph_message.h",
84+
+ "src/core/common/ojph_params.h",
85+
+ "src/core/common/ojph_version.h",
86+
+ "src/core/others/ojph_arch.cpp",
87+
+ "src/core/others/ojph_file.cpp",
88+
+ "src/core/others/ojph_mem.cpp",
89+
+ "src/core/others/ojph_message.cpp",
90+
+ "src/core/transform/ojph_colour.cpp",
91+
+ "src/core/transform/ojph_colour.h",
92+
+ "src/core/transform/ojph_colour_local.h",
93+
+ "src/core/transform/ojph_transform.cpp",
94+
+ "src/core/transform/ojph_transform.h",
95+
+ "src/core/transform/ojph_transform_local.h",
96+
+ ],
97+
+ hdrs = [
98+
+ "src/core/common/ojph_arg.h",
99+
+ "src/core/common/ojph_mem.h",
100+
+ ],
101+
+ defines = [
102+
+ "OJPH_DISABLE_SIMD",
103+
+ #"OJPH_DISABLE_SSE2",
104+
+ #"OJPH_DISABLE_SSSE3",
105+
+ #"OJPH_DISABLE_SSE4",
106+
+ #"OJPH_DISABLE_AVX",
107+
+ #"OJPH_DISABLE_AVX2",
108+
+ #"OJPH_DISABLE_AVX512",
109+
+ #"OJPH_DISABLE_NEON",
110+
+ ],
111+
+ includes = [
112+
+ "src/core/codestream",
113+
+ "src/core/coding",
114+
+ "src/core/common",
115+
+ "src/core/others",
116+
+ "src/core/transform",
117+
+ ],
118+
+ visibility = ["//visibility:public"],
119+
+)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- MODULE.bazel
2+
+++ MODULE.bazel
3+
@@ -0,0 +1,8 @@
4+
+module(
5+
+ name = "openjph",
6+
+ version = "0.20.0",
7+
+ compatibility_level = 1,
8+
+)
9+
+
10+
+bazel_dep(name = "rules_cc", version = "0.1.0")
11+
+bazel_dep(name = "rules_license", version = "1.0.0")

cmake/LibraryDefine.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function(OPENEXR_DEFINE_LIBRARY libname)
2424
PRIVATE cxx_std_${OPENEXR_CXX_STANDARD}
2525
INTERFACE cxx_std_17 )
2626

27-
# we are embedding libdeflate
27+
# we are embedding libdeflate
2828
target_include_directories(${objlib} PRIVATE ${EXR_DEFLATE_INCLUDE_DIR})
2929

3030
if(OPENEXR_CURLIB_PRIV_EXPORT AND BUILD_SHARED_LIBS)
@@ -40,7 +40,7 @@ function(OPENEXR_DEFINE_LIBRARY libname)
4040
if(OPENEXR_CURLIB_CURBINDIR)
4141
target_include_directories(${objlib} PRIVATE $<BUILD_INTERFACE:${OPENEXR_CURLIB_CURBINDIR}>)
4242
endif()
43-
target_link_libraries(${objlib} PUBLIC ${PROJECT_NAME}::Config ${OPENEXR_CURLIB_DEPENDENCIES})
43+
target_link_libraries(${objlib} PUBLIC ${PROJECT_NAME}::Config ${OPENEXR_CURLIB_DEPENDENCIES} ${CMAKE_DL_LIBS} ${EXR_OPENJPH_LIB})
4444
if(OPENEXR_CURLIB_PRIVATE_DEPS)
4545
target_link_libraries(${objlib} PRIVATE ${OPENEXR_CURLIB_PRIVATE_DEPS})
4646
endif()

cmake/OpenEXRSetup.cmake

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,68 @@ else()
306306
set(EXR_DEFLATE_LIB)
307307
endif()
308308

309+
310+
#######################################
311+
# Find or download OpenJPH
312+
#######################################
313+
314+
message(STATUS "Locating OpenJPH")
315+
316+
option(OPENEXR_FORCE_INTERNAL_OPENJPH "Force downloading OpenJPH from a git repo" OFF)
317+
318+
set(OPENEXR_OJPH_REPO "https://github.com/palemieux/OpenJPH.git" CACHE STRING "OpenJPH Git repo URI")
319+
set(OPENEXR_OJPH_TAG "add-export" CACHE STRING "OpenJPH Git repo tag")
320+
321+
if (NOT OPENEXR_FORCE_INTERNAL_OPENJPH)
322+
find_package(openjph 0.20 QUIET)
323+
324+
if(openjph_FOUND)
325+
message(STATUS "Found OpenJPH using find_package.")
326+
set(EXR_OPENJPH_LIB openjph)
327+
else()
328+
# If not found, try pkgconfig
329+
find_package(PkgConfig)
330+
if(PKG_CONFIG_FOUND)
331+
include(FindPkgConfig)
332+
pkg_check_modules(openjph IMPORTED_TARGET GLOBAL openjph=0.20)
333+
if(openjph_FOUND)
334+
set(EXR_OPENJPH_LIB PkgConfig::openjph)
335+
message(STATUS "Found OpenJPH using PkgConfig at ${deflate_LINK_LIBRARIES}")
336+
endif()
337+
endif()
338+
endif()
339+
endif()
340+
341+
if(NOT EXR_OPENJPH_LIB)
342+
include(FetchContent)
343+
FetchContent_Declare(
344+
openjph
345+
GIT_REPOSITORY ${OPENEXR_OJPH_REPO}
346+
GIT_TAG ${OPENEXR_OJPH_TAG}
347+
)
348+
349+
set(OJPH_BUILD_TESTS OFF CACHE BOOL "" FORCE)
350+
set(OJPH_ENABLE_TIFF_SUPPORT OFF CACHE BOOL "" FORCE)
351+
set(OJPH_BUILD_EXECUTABLES OFF CACHE BOOL "" FORCE)
352+
FetchContent_MakeAvailable(openjph)
353+
install(
354+
TARGETS openjph
355+
EXPORT ${PROJECT_NAME}
356+
)
357+
set_target_properties(openjph PROPERTIES
358+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
359+
)
360+
include_directories("${openjph_SOURCE_DIR}/src/core/common")
361+
362+
set(EXR_OPENJPH_LIB openjph)
363+
364+
message(STATUS "Building OpenJPH from ${OPENEXR_OJPH_REPO}.")
365+
endif()
366+
367+
if (NOT EXR_OPENJPH_LIB)
368+
message(ERROR "Failed to find OpenJPH.")
369+
endif()
370+
309371
#######################################
310372
# Find or install Imath
311373
#######################################

share/ci/install_manifest/install_manifest.macos.1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ include/OpenEXR/openexr_errors.h
156156
include/OpenEXR/openexr_part.h
157157
include/OpenEXR/openexr_std_attr.h
158158
include/OpenEXR/openexr_version.h
159+
include/OpenEXR/ImfHTCompressor.h
159160
lib/cmake/OpenEXR/OpenEXRConfig.cmake
160161
lib/cmake/OpenEXR/OpenEXRConfigVersion.cmake
161162
lib/cmake/OpenEXR/OpenEXRTargets-release.cmake

0 commit comments

Comments
 (0)