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

Open
wants to merge 4 commits into
base: htj2k-beta
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion .github/workflows/ci_steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ on:
type: string
OPENEXR_FORCE_INTERNAL_DEFLATE:
type: string
OPENEXR_FORCE_INTERNAL_OPENJPH:
type: string
BUILD_TESTING:
type: string
namespace:
Expand Down Expand Up @@ -84,6 +86,12 @@ jobs:
run: share/ci/scripts/install_libdeflate.sh master
shell: bash

- name: Install OpenJPH
# Pre-install OpenJPH so the builds validate finding the external installation
if: ${{ inputs.OPENEXR_FORCE_INTERNAL_OPENJPH == 'OFF' }}
run: share/ci/scripts/install_openjph.sh master
shell: bash

- name: Install help2man
# TODO: this could go in the ASWF Linux docker
# container. Also, it doesn't currently work for Windows, so
Expand Down Expand Up @@ -113,6 +121,7 @@ jobs:
-DOPENEXR_BUILD_TOOLS=${{ inputs.OPENEXR_BUILD_TOOLS }} \
-DOPENEXR_FORCE_INTERNAL_IMATH=${{ inputs.OPENEXR_FORCE_INTERNAL_IMATH }} \
-DOPENEXR_FORCE_INTERNAL_DEFLATE=${{ inputs.OPENEXR_FORCE_INTERNAL_DEFLATE }} \
-DOPENEXR_FORCE_INTERNAL_OPENJPH=${{ inputs.OPENEXR_FORCE_INTERNAL_OPENJPH }} \
-DBUILD_TESTING=${{ inputs.BUILD_TESTING }} \
-DOPENEXR_RUN_FUZZ_TESTS=OFF \
-DCMAKE_VERBOSE_MAKEFILE=ON"
Expand Down Expand Up @@ -170,7 +179,7 @@ jobs:
# When building against external Imath/libdeflate shared objects, the tests need PATH to include the dll's.
if: contains(inputs.os, 'windows')
run: |
echo "$PATH;C:/Program Files (x86)/Imath/bin;C:/Program Files (x86)/Imath/lib;C:/Program Files (x86)/libdeflate/bin;C:/Program Files (x86)/libdeflate/lib" >> $GITHUB_PATH
echo "$PATH;C:/Program Files (x86)/openjph/lib/;C:/Program Files (x86)/openjph/bin;C:/Program Files (x86)/Imath/bin;C:/Program Files (x86)/Imath/lib;C:/Program Files (x86)/libdeflate/bin;C:/Program Files (x86)/libdeflate/lib" >> $GITHUB_PATH
shell: bash

- name: Test
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
OPENEXR_BUILD_TOOLS: ${{ matrix.OPENEXR_BUILD_TOOLS || 'ON' }}
OPENEXR_FORCE_INTERNAL_IMATH: ${{ matrix.OPENEXR_FORCE_INTERNAL_IMATH || 'OFF' }}
OPENEXR_FORCE_INTERNAL_DEFLATE: ${{ matrix.OPENEXR_FORCE_INTERNAL_DEFLATE || 'OFF' }}
OPENEXR_FORCE_INTERNAL_OPENJPH: ${{ matrix.OPENEXR_FORCE_INTERNAL_OPENJPH || 'OFF' }}
BUILD_TESTING: ${{ matrix.BUILD_TESTING || 'ON' }}
namespace: ${{ matrix.namespace }}
validate_install: ${{ matrix.validate_install || 'ON' }}
Expand Down Expand Up @@ -107,6 +108,7 @@ jobs:
OPENEXR_BUILD_TOOLS: 'OFF'
OPENEXR_FORCE_INTERNAL_IMATH: 'ON'
OPENEXR_FORCE_INTERNAL_DEFLATE: 'ON'
OPENEXR_FORCE_INTERNAL_OPENJPH: 'ON'
BUILD_TESTING: 'OFF'

- build: 6
Expand Down Expand Up @@ -141,6 +143,7 @@ jobs:
OPENEXR_BUILD_TOOLS: ${{ matrix.OPENEXR_BUILD_TOOLS || 'ON' }}
OPENEXR_FORCE_INTERNAL_IMATH: ${{ matrix.OPENEXR_FORCE_INTERNAL_IMATH || 'OFF' }}
OPENEXR_FORCE_INTERNAL_DEFLATE: ${{ matrix.OPENEXR_FORCE_INTERNAL_DEFLATE || 'OFF' }}
OPENEXR_FORCE_INTERNAL_OPENJPH: ${{ matrix.OPENEXR_FORCE_INTERNAL_OPENJPH || 'OFF' }}
BUILD_TESTING: ${{ matrix.BUILD_TESTING || 'ON' }}
validate_install: ${{ matrix.validate_install || 'ON' }}
strategy:
Expand Down Expand Up @@ -170,6 +173,7 @@ jobs:
OPENEXR_BUILD_TOOLS: 'OFF'
OPENEXR_FORCE_INTERNAL_IMATH: 'ON'
OPENEXR_FORCE_INTERNAL_DEFLATE: 'ON'
OPENEXR_FORCE_INTERNAL_OPENJPH: 'ON'
BUILD_TESTING: 'OFF'

- build: 6
Expand All @@ -195,6 +199,7 @@ jobs:
OPENEXR_BUILD_TOOLS: ${{ matrix.OPENEXR_BUILD_TOOLS || 'ON' }}
OPENEXR_FORCE_INTERNAL_IMATH: ${{ matrix.OPENEXR_FORCE_INTERNAL_IMATH || 'OFF' }}
OPENEXR_FORCE_INTERNAL_DEFLATE: ${{ matrix.OPENEXR_FORCE_INTERNAL_DEFLATE || 'OFF' }}
OPENEXR_FORCE_INTERNAL_OPENJPH: ${{ matrix.OPENEXR_FORCE_INTERNAL_OPENJPH || 'OFF' }}
BUILD_TESTING: ${{ matrix.BUILD_TESTING || 'ON' }}
validate_install: ${{ matrix.validate_install || 'ON' }}
strategy:
Expand Down Expand Up @@ -224,6 +229,7 @@ jobs:
OPENEXR_BUILD_TOOLS: 'OFF'
OPENEXR_FORCE_INTERNAL_IMATH: 'ON'
OPENEXR_FORCE_INTERNAL_DEFLATE: 'ON'
OPENEXR_FORCE_INTERNAL_OPENJPH: 'ON'
BUILD_TESTING: 'OFF'

- build: 6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ossfuzz_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
dry-run: false
language: c++
- name: Upload Crash
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3.2.1
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-wheels-publish-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
CIBW_ENVIRONMENT: OPENEXR_RELEASE_CANDIDATE_TAG="${{ github.ref_name }}"

- name: Upload artifact
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3.2.1
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-wheels-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
CIBW_TEST_SKIP: "*arm64"

- name: Upload artifact
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3.2.1
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ jobs:
OPENEXR_TEST_IMAGE_REPO: "https://raw.githubusercontent.com/AcademySoftwareFoundation/openexr-images/main"

- name: Upload artifact
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3.2.1
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: |
./wheelhouse/*.whl
./wheelhouse/*.tar.gz
./wheelhouse/*.tar.gz
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

# Upload the results as artifacts (optional)
- name: "Upload artifact"
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3.2.1
uses: actions/upload-artifact@v4
with:
name: SARIF file
path: results.sarif
Expand Down
7 changes: 7 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,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_ht_common.h",
"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 Expand Up @@ -262,6 +265,7 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
"@imath",
"@openjph",
"@libdeflate//:deflate",
],
)
Expand Down Expand Up @@ -308,6 +312,7 @@ cc_library(
"src/lib/OpenEXR/ImfGenericInputFile.cpp",
"src/lib/OpenEXR/ImfGenericOutputFile.cpp",
"src/lib/OpenEXR/ImfHeader.cpp",
"src/lib/OpenEXR/ImfHTCompressor.cpp",
"src/lib/OpenEXR/ImfHuf.cpp",
"src/lib/OpenEXR/ImfIDManifest.cpp",
"src/lib/OpenEXR/ImfIDManifestAttribute.cpp",
Expand Down Expand Up @@ -413,6 +418,7 @@ cc_library(
"src/lib/OpenEXR/ImfGenericInputFile.h",
"src/lib/OpenEXR/ImfGenericOutputFile.h",
"src/lib/OpenEXR/ImfHeader.h",
"src/lib/OpenEXR/ImfHTCompressor.h",
"src/lib/OpenEXR/ImfHuf.h",
"src/lib/OpenEXR/ImfIDManifest.h",
"src/lib/OpenEXR/ImfIDManifestAttribute.h",
Expand Down Expand Up @@ -504,6 +510,7 @@ cc_library(
":IlmThread",
":OpenEXRCore",
"@imath",
"@openjph"
],
)

Expand Down
11 changes: 11 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module(

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "imath")
bazel_dep(name = "openjph")
bazel_dep(name = "libdeflate")
bazel_dep(name = "platforms", version = "0.0.10")

Expand All @@ -30,3 +31,13 @@ archive_override(
strip_prefix = "libdeflate-master",
urls = ["https://github.com/ebiggers/libdeflate/archive/refs/heads/master.zip"],
)

archive_override(
module_name = "openjph",
patches = [
"//bazel:openjph_add_build_file.patch",
"//bazel:openjph_module_dot_bazel.patch",
],
strip_prefix = "OpenJPH-add-export",
urls = ["https://github.com/palemieux/OpenJPH/archive/refs/heads/add-export.zip"],
)
119 changes: 119 additions & 0 deletions bazel/openjph_add_build_file.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
--- /dev/null
+++ BUILD.bazel
@@ -0,0 +1,116 @@
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
+load("@rules_license//rules:license.bzl", "license")
+
+package(
+ default_applicable_licenses = [":license"],
+)
+
+exports_files([
+ "LICENSE",
+])
+
+license(
+ name = "license",
+ license_kinds = ["@rules_license//licenses/spdx:BSD-2-Clause"],
+ license_text = "LICENSE",
+)
+
+cc_binary(
+ name = "ojph_compress",
+ srcs = ["src/apps/ojph_compress/ojph_compress.cpp"],
+ visibility = ["//visibility:public"],
+ deps = [":ojph_expand"],
+)
+
+cc_library(
+ name = "ojph_expand",
+ srcs = [
+ "src/apps/ojph_expand/ojph_expand.cpp",
+ "src/apps/others/ojph_img_io.cpp",
+ ],
+ hdrs = [
+ "src/apps/common/ojph_img_io.h",
+ ],
+ includes = [
+ "src/apps/common",
+ ],
+ visibility = ["//visibility:public"],
+ deps = [":openjph"],
+)
+
+cc_library(
+ name = "openjph",
+ srcs = [
+ "src/core/codestream/ojph_bitbuffer_read.h",
+ "src/core/codestream/ojph_bitbuffer_write.h",
+ "src/core/codestream/ojph_codeblock.cpp",
+ "src/core/codestream/ojph_codeblock.h",
+ "src/core/codestream/ojph_codeblock_fun.cpp",
+ "src/core/codestream/ojph_codeblock_fun.h",
+ "src/core/codestream/ojph_codestream.cpp",
+ "src/core/codestream/ojph_codestream_gen.cpp",
+ "src/core/codestream/ojph_codestream_local.cpp",
+ "src/core/codestream/ojph_codestream_local.h",
+ "src/core/codestream/ojph_params.cpp",
+ "src/core/codestream/ojph_params_local.h",
+ "src/core/codestream/ojph_precinct.cpp",
+ "src/core/codestream/ojph_precinct.h",
+ "src/core/codestream/ojph_resolution.cpp",
+ "src/core/codestream/ojph_resolution.h",
+ "src/core/codestream/ojph_subband.cpp",
+ "src/core/codestream/ojph_subband.h",
+ "src/core/codestream/ojph_tile.cpp",
+ "src/core/codestream/ojph_tile.h",
+ "src/core/codestream/ojph_tile_comp.cpp",
+ "src/core/codestream/ojph_tile_comp.h",
+ "src/core/coding/ojph_block_common.cpp",
+ "src/core/coding/ojph_block_common.h",
+ "src/core/coding/ojph_block_decoder.h",
+ "src/core/coding/ojph_block_decoder32.cpp",
+ "src/core/coding/ojph_block_decoder64.cpp",
+ "src/core/coding/ojph_block_encoder.cpp",
+ "src/core/coding/ojph_block_encoder.h",
+ "src/core/coding/table0.h",
+ "src/core/coding/table1.h",
+ "src/core/common/ojph_arch.h",
+ "src/core/common/ojph_base.h",
+ "src/core/common/ojph_codestream.h",
+ "src/core/common/ojph_defs.h",
+ "src/core/common/ojph_file.h",
+ "src/core/common/ojph_message.h",
+ "src/core/common/ojph_params.h",
+ "src/core/common/ojph_version.h",
+ "src/core/others/ojph_arch.cpp",
+ "src/core/others/ojph_file.cpp",
+ "src/core/others/ojph_mem.cpp",
+ "src/core/others/ojph_message.cpp",
+ "src/core/transform/ojph_colour.cpp",
+ "src/core/transform/ojph_colour.h",
+ "src/core/transform/ojph_colour_local.h",
+ "src/core/transform/ojph_transform.cpp",
+ "src/core/transform/ojph_transform.h",
+ "src/core/transform/ojph_transform_local.h",
+ ],
+ hdrs = [
+ "src/core/common/ojph_arg.h",
+ "src/core/common/ojph_mem.h",
+ ],
+ defines = [
+ "OJPH_DISABLE_SIMD",
+ #"OJPH_DISABLE_SSE2",
+ #"OJPH_DISABLE_SSSE3",
+ #"OJPH_DISABLE_SSE4",
+ #"OJPH_DISABLE_AVX",
+ #"OJPH_DISABLE_AVX2",
+ #"OJPH_DISABLE_AVX512",
+ #"OJPH_DISABLE_NEON",
+ ],
+ includes = [
+ "src/core/codestream",
+ "src/core/coding",
+ "src/core/common",
+ "src/core/others",
+ "src/core/transform",
+ ],
+ visibility = ["//visibility:public"],
+)
11 changes: 11 additions & 0 deletions bazel/openjph_module_dot_bazel.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- MODULE.bazel
+++ MODULE.bazel
@@ -0,0 +1,8 @@
+module(
+ name = "openjph",
+ version = "0.20.0",
+ compatibility_level = 1,
+)
+
+bazel_dep(name = "rules_cc", version = "0.1.0")
+bazel_dep(name = "rules_license", version = "1.0.0")
4 changes: 2 additions & 2 deletions cmake/LibraryDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function(OPENEXR_DEFINE_LIBRARY libname)
PRIVATE cxx_std_${OPENEXR_CXX_STANDARD}
INTERFACE cxx_std_17 )

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

if(OPENEXR_CURLIB_PRIV_EXPORT AND BUILD_SHARED_LIBS)
Expand All @@ -40,7 +40,7 @@ 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})
target_link_libraries(${objlib} PUBLIC ${PROJECT_NAME}::Config ${OPENEXR_CURLIB_DEPENDENCIES} ${CMAKE_DL_LIBS} ${EXR_OPENJPH_LIB})
if(OPENEXR_CURLIB_PRIVATE_DEPS)
target_link_libraries(${objlib} PRIVATE ${OPENEXR_CURLIB_PRIVATE_DEPS})
endif()
Expand Down
Loading
Loading