Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d6d331e
Initial commit for HTJ2K support.
richardssam Feb 25, 2025
e45e9e9
Use the compression flag for qstep, also default to lossless.
richardssam Mar 31, 2025
a8011bf
Adding testing.
richardssam Apr 12, 2025
ed4b96c
Adding docs.
richardssam Apr 12, 2025
81d32da
Refining the test.
richardssam Apr 12, 2025
61b5459
Clang formatting.
richardssam Apr 12, 2025
4a8e567
Remove htj2k plugin merging it into the jpeg2000 plugin.
richardssam May 26, 2025
4e090e6
Removing annoying file addition.
richardssam May 26, 2025
ce87082
Updated documentation to for jpeg2000 plugin (migrating from htj2k pl…
richardssam May 26, 2025
0ed7e3c
Updating add_oiio_plugin code to support target_link_directories.
richardssam May 27, 2025
eca23b8
Revamped cmake configs, taking advantage of pkg-config.
richardssam May 27, 2025
7786d2f
Adding support for openJPH reader, which is optional, but should impr…
richardssam May 27, 2025
92d760a
Adding in openJPH support if enabled, which adds htj2k encoding support.
richardssam May 27, 2025
c41a551
Added some clarity to what openJPH is providing vs. OpenJpeg
richardssam May 27, 2025
2b1141e
Removed the floating point support for now, until if its clear its pa…
richardssam May 27, 2025
59686c0
Removed some debug output that shouldnt be there.
richardssam May 27, 2025
d93d170
Re-enabling the associateAlpha code.
richardssam May 27, 2025
e6be06e
Removed plugin reference, merged into the jpeg2000 code.
richardssam May 27, 2025
8dcdcca
Technically these are part of the jpeg2000 plugin, but only if openjp…
richardssam May 27, 2025
0af0325
Remove debug message.
richardssam May 28, 2025
b4fc92a
Fixing test for new arguments.
richardssam May 28, 2025
aadfaf1
Applying clang-formatting.
richardssam May 28, 2025
df5b9a9
0.21 is the baseline, recommended is not needed since its the same ve…
richardssam Jun 1, 2025
00f7207
Whitespace cleanup, 3 lines between functions, removing more than one…
richardssam Jun 1, 2025
c432632
Removing un-needed global variable.
richardssam Jun 1, 2025
4fa83c5
Add a default, just in case.
richardssam Jun 1, 2025
814ae5d
Use std::unique_ptr instead of pointers.
richardssam Jun 1, 2025
3bd6029
clang-format fixes.
richardssam Jun 1, 2025
4548850
Another clang-format issue.
richardssam Jun 1, 2025
eee3848
WS
richardssam Jun 1, 2025
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
18 changes: 18 additions & 0 deletions iinfo Args.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations" : [
{
"id" : "E800C18D-6608-42DB-8622-CF764A0DAE82",
"name" : "Configuration 1",
"options" : {

}
}
],
"defaultOptions" : {
"testTimeoutsEnabled" : true
},
"testTargets" : [

],
"version" : 1
}
Comment thread
richardssam marked this conversation as resolved.
Outdated
2 changes: 2 additions & 0 deletions src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ checked_find_package (OpenJPEG VERSION_MIN 2.0
# Note: Recent OpenJPEG versions have exported cmake configs, but we don't
# find them reliable at all, so we stick to our FindOpenJPEG.cmake module.

checked_find_package (OpenJPH VERSION_MIN 0.15)

checked_find_package (OpenVDB
VERSION_MIN 9.0
DEPS TBB
Expand Down
133 changes: 133 additions & 0 deletions src/cmake/modules/FindOpenJPH.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: BSD-3-Clause and Apache-2.0
Comment thread
richardssam marked this conversation as resolved.
Outdated
# https://github.com/AcademySoftwareFoundation/OpenImageIO

# Module to find OPENJPH.
#
Comment on lines +5 to +6
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking: OpenJPH doesn't have an exported cmake config?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think so no. I'll check what they have done with OpenEXR, so we dont have two different approaches.

Copy link
Copy Markdown

@kmilos kmilos Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more recent 0.21.x version do, and I guess 0.21.2 should be the minimum required due to some other bugfixes as well. See also AcademySoftwareFoundation/openexr#1883

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we never had OpenJPH as a dependency before, there is no need to preserve any back compatibility, so we can set the minimum version to anything we want. If the most recent version makes the build process more foolproof by supplying the exported cmake config files and eliminating the need for a FindOpenJPH module, I think that's a totally valid reason to make it the minimum going forward.

An example of a potential counter-argument would be: if OpenJPH is widely used and an older version is probably on most developer's machines already, requiring the very newest is an extra burden for them, so maybe it's worth accommodating older versions. (But I suspect this is not the case with OpenJPH as it would be with something like libtiff or libjpeg... I bet most developers will have to install OpenJPH for the first time only after we add it as a dependency, so it shouldn't matter much if we require them to have a new version.)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I tend to agree; 0.21.x is available OOTB only recently, in the upcoming Fedora 42, Ubuntu 25.04, Debian 13 (trixie), etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, so I did clean up the cmake part of findJPH to use pkg-config.
However, it did require changes to add_oiio_plugin to add support for link_directories.
Otherwise the oiio build was asking for libraries it couldnt find. I'm not a cmake expert, so definately could use some eyes on this part, but it seems like I'm now taking advantage of something that should have been there already.

# This module will first look into the directories defined by the variables:
# - OPENJPH_ROOT
#
# This module defines the following variables:
#
# OPENJPH_INCLUDES - where to find ojph_arg.h
# OPENJPH_LIBRARIES - list of libraries to link against when using OPENJPH.
# OPENJPH_FOUND - True if OPENJPH was found.
# OPENJPH_VERSION - Set to the OPENJPH version found
include (FindPackageHandleStandardArgs)
include (FindPackageMessage)
include (SelectLibraryConfigurations)

macro (PREFIX_FIND_INCLUDE_DIR prefix includefile libpath_var)
string (TOUPPER ${prefix}_INCLUDE_DIR tmp_varname)
find_path(${tmp_varname} ${includefile}
PATHS ${${libpath_var}}
PATH_SUFFIXES openjph
)
if (${tmp_varname})
mark_as_advanced (${tmp_varname})
endif ()
unset (tmp_varname)
endmacro ()


macro (PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var)
string (TOUPPER ${prefix}_${libname} tmp_prefix)
find_library(${tmp_prefix}_LIBRARY_RELEASE
NAMES ${libname}
PATHS ${${libpath_var}}
)
find_library(${tmp_prefix}_LIBRARY_DEBUG
NAMES ${libname}d ${libname}_d ${libname}debug ${libname}_debug
PATHS ${${libpath_var}}
)
# Properly define ${tmp_prefix}_LIBRARY (cached) and ${tmp_prefix}_LIBRARIES
select_library_configurations (${tmp_prefix})
list (APPEND ${liblist_var} ${tmp_prefix}_LIBRARIES)

# Add to the list of variables which should be reset
list (APPEND ${cachelist_var}
${tmp_prefix}_LIBRARY
${tmp_prefix}_LIBRARY_RELEASE
${tmp_prefix}_LIBRARY_DEBUG)
mark_as_advanced (
${tmp_prefix}_LIBRARY
${tmp_prefix}_LIBRARY_RELEASE
${tmp_prefix}_LIBRARY_DEBUG)
unset (tmp_prefix)
endmacro ()

# Generic search paths
set (OPENJPH_include_paths
/usr/include
/opt/local/include
/usr/local/include
)

set (OPENJPH_library_paths
/usr/lib
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/local/lib
/sw/lib
/opt/local/lib)



# Locate the header files
PREFIX_FIND_INCLUDE_DIR (OPENJPH ojph_arg.h OPENJPH_include_paths)

# If the headers were found, add its parent to the list of lib directories
if (OPENJPH_INCLUDE_DIR)
get_filename_component (tmp_extra_dir "${OPENJPH_INCLUDE_DIR}/../" ABSOLUTE)
list (APPEND OPENJPH_library_paths ${tmp_extra_dir})
unset (tmp_extra_dir)
endif ()

# Search for opj_config.h -- it is only part of OPENJPH >= 2.0, and will
# contain symbols OPJ_VERSION_MAJOR and OPJ_VERSION_MINOR. If the file
# doesn't exist, we're dealing with OPENJPH 1.x.
# Note that for OPENJPH 2.x, the library is named libopenjp2, not
# libOPENJPH (which is for 1.x)
set (OPENJPH_CONFIG_FILE "${OPENJPH_INCLUDE_DIR}/ojph_version.h")
message("!!!!!!!!!!!!!!!!!!OPENJPH OPENJPH_CONFIG_FILE ${OPENJPH_INCLUDE_DIR} ${OPENJPH_CONFIG_FILE}")

if (EXISTS "${OPENJPH_CONFIG_FILE}")
message("!!!!!!--- CONFIGFILE - ${OPENJPH_CONFIG_FILE}")
file(STRINGS "${OPENJPH_CONFIG_FILE}" TMP REGEX "^#define OPENJPH_VERSION_MAJOR .*$")
string (REGEX MATCHALL "[0-9]+" OJPH_VERSION_MAJOR ${TMP})
file(STRINGS "${OPENJPH_CONFIG_FILE}" TMP REGEX "^#define OPENJPH_VERSION_MINOR .*$")
string (REGEX MATCHALL "[0-9]+" OJPH_VERSION_MINOR ${TMP})
endif ()
set (OPENJPH_VERSION "${OJPH_VERSION_MAJOR}.${OJPH_VERSION_MINOR}")
message("!!!!!!!!!!!!!!!!!!OPENJPH VERSION ${OPENJPH_VERSION}")

# Locate the OPENJPH library
set (OPENJPH_libvars "")
set (OPENJPH_cachevars "")

PREFIX_FIND_LIB (OPENJPH openjph
OPENJPH_library_paths OPENJPH_libvars OPENJPH_cachevars)


# Use the standard function to handle OPENJPH_FOUND
FIND_PACKAGE_HANDLE_STANDARD_ARGS (OPENJPH
VERSION_VAR OPENJPH_VERSION
REQUIRED_VARS OPENJPH_INCLUDE_DIR ${OPENJPH_libvars})

if (OPENJPH_FOUND)
set (OPENJPH_INCLUDES ${OPENJPH_INCLUDE_DIR})
set (OPENJPH_LIBRARIES "")
foreach (tmplib ${OPENJPH_libvars})
list (APPEND OPENJPH_LIBRARIES ${${tmplib}})
endforeach ()
if (NOT OPENJPH_FIND_QUIETLY)
FIND_PACKAGE_MESSAGE (OPENJPH
"Found OPENJPH: v${OPENJPH_VERSION} ${OPENJPH_LIBRARIES}"
"[${OPENJPH_INCLUDE_DIR}][${OPENJPH_LIBRARIES}]"
)
endif ()
endif ()

unset (OPENJPH_include_paths)
unset (OPENJPH_library_paths)
unset (OPENJPH_libvars)
unset (OPENJPH_cachevars)
3 changes: 3 additions & 0 deletions src/cmake/testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ macro (oiio_add_all_tests)
oiio_add_tests (jpeg2000
FOUNDVAR OPENJPEG_FOUND
IMAGEDIR oiio-images URL "Recent checkout of OpenImageIO-images")
oiio_add_tests (htj2k
FOUNDVAR OPENJPH_FOUND
IMAGEDIR oiio-images URL "Recent checkout of OpenImageIO-images")
oiio_add_tests (jpeg2000-j2kp4files
FOUNDVAR OPENJPEG_FOUND
IMAGEDIR j2kp4files_v1_5
Expand Down
56 changes: 56 additions & 0 deletions src/doc/builtinplugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,62 @@ special ``"oiio:ioproxy"`` attributes (see Sections
the `set_ioproxy()` methods.


|

.. _sec-bundledplugins-htj2k:

High Throughput JPEG2000 (HTJ2K):
===============================================

HTJ2K is an extension of JPEG2000 (Jpeg2000 Part 15) that offers substantailly faster encoding and decoding performance.
While the OpenJpeg library can decode these files, they need to be decoded using the OpenJPH library.
Comment thread
richardssam marked this conversation as resolved.
Outdated
Comment thread
richardssam marked this conversation as resolved.
Outdated

Currently the HTJ2K encoding encodes to file:`.j2c`` files. For more details on HTJ2K please see: https://ds.jpeg.org/whitepapers/jpeg-htj2k-whitepaper.pdf and https://github.com/aous72/OpenJPH.

The default operation on creating a HTJ2K file is to use lossless compression.

**Configuration settings for HTJ2K output**

When opening a HTJ2K ImageOutput, the following special metadata tokens
control aspects of the writing itself:

.. list-table::
:widths: 30 10 65
:header-rows: 1

* - Output Configuration Attribute
- Type
- Meaning
* - ``jph:bit_depth``
- int
- The output bitdepth of the file.
* - ``jph:num_decomps``
- int
- (5) number of decompositions.
* - ``jph:block_size``
- string
- The output block size, defaults to 64,64
* - ``jph:prog_order``
- string
- (RPCL) is the progression order, and can be one of:
LRCP, RLCP, RPCL, PCRL, CPRL. These determine the sequence in which the image data is processed and transmitted. The letters stand for:
R: Resolution
P: position
C: component
L: Layer
RPCL is common for applications where resolution scalability is important.
* - ``jph:precincts``
- string
- x,y,x,y,...,x,y where x,y is the precinct size
starting from the coarsest resolution; the last precinct
is repeated for all finer resolutions
* - ``compression``
- string
- If supplied, must be ``"qstep:<VALUE>"``, where <VALUE> is the quantization step size for lossy compression;
quantization steps size for all subbands are derived from this value. Valid values can be from 0.00001 to 0.5.
If not used, the encoder will be lossless.


|

.. _sec-bundledplugins-jpegxl:
Expand Down
12 changes: 12 additions & 0 deletions src/htj2k.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO

if (OPENJPH_FOUND)
add_oiio_plugin (jphoutput.cpp
INCLUDE_DIRS ${OPENJPH_INCLUDES}
LINK_LIBRARIES ${OPENJPH_LIBRARIES}
DEFINITIONS "USE_OPENJPH")
else()
message (WARNING "HTJpeg-2000 JPH plugin will not be built")
endif()
Loading
Loading