Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ci_steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
if: inputs.OPENEXR_FORCE_INTERNAL_OPENJPH == 'OFF' && inputs.msystem == ''
run: |
set -x
share/ci/scripts/install_openjph.sh 0.22.0
share/ci/scripts/install_openjph.sh 0.27.3
echo "OPENEXR_PATH=$OPENEXR_PATH:$PROGRAM_FILES/openjph/bin:$PROGRAM_FILES/openjph/lib" >> $GITHUB_ENV
shell: bash

Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ module(
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "imath", version = "3.2.2.bcr.1")
bazel_dep(name = "libdeflate", version = "1.25")
bazel_dep(name = "openjph", version = "0.27.0")
bazel_dep(name = "openjph", version = "0.27.3.bcr.1")
bazel_dep(name = "platforms", version = "1.1.0")
bazel_dep(name = "rules_cc", version = "0.2.18")
25 changes: 9 additions & 16 deletions cmake/OpenEXRSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ option(OPENEXR_FORCE_INTERNAL_OPENJPH "Force downloading OpenJPH from a git repo
if (NOT OPENEXR_FORCE_INTERNAL_OPENJPH)
find_package(openjph CONFIG QUIET)
if(openjph_FOUND)
if(openjph_VERSION VERSION_LESS "0.21.0")
message(FATAL_ERROR "OpenJPH >= 0.21.0 required, but found ${openjph_VERSION}")
if(openjph_VERSION VERSION_LESS "0.27.3")
message(FATAL_ERROR "OpenJPH >= 0.27.3 required, but found ${openjph_VERSION}")
endif()

message(STATUS "Using OpenJPH ${openjph_VERSION} from ${openjph_DIR}")
Expand All @@ -282,7 +282,7 @@ if (NOT OPENEXR_FORCE_INTERNAL_OPENJPH)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
include(FindPkgConfig)
pkg_check_modules(openjph IMPORTED_TARGET GLOBAL QUIET openjph=0.21)
pkg_check_modules(openjph IMPORTED_TARGET GLOBAL QUIET openjph=0.27.3)
if(openjph_FOUND)
set(EXR_OPENJPH_LIB PkgConfig::openjph)
message(STATUS "Using OpenJPH ${openjph_VERSION} from ${openjph_LINK_LIBRARIES}")
Expand All @@ -294,7 +294,7 @@ endif()
if(EXR_OPENJPH_LIB)
# Using external library
# For OpenEXR.pc.in for static build
set(EXR_OPENJPH_PKGCONFIG_REQUIRES "openjph >= 0.21.0")
set(EXR_OPENJPH_PKGCONFIG_REQUIRES "openjph >= 0.27.3")
else()
# Using internal openjph

Expand Down Expand Up @@ -432,18 +432,11 @@ if(TARGET Imath AND TARGET ImathConfig)
"${_openexr_imath_cfg_compat}/Imath/ImathConfig.h" COPYONLY)
endif()

# Add the build interface include directory, but only do it once;
# if the cache key exists, it's already been added by a previous
# configuration run.
set(_openexr_imath_inc_patch_key "${Imath_SOURCE_DIR}|${Imath_BINARY_DIR}")
if(NOT OPENEXR_IMATH_SUBDIR_INCLUDE_PATCH STREQUAL _openexr_imath_inc_patch_key)
target_include_directories(Imath INTERFACE
"$<BUILD_INTERFACE:${Imath_SOURCE_DIR}/src>")
if(EXISTS "${_openexr_imath_gen_cfg}")
target_include_directories(ImathConfig INTERFACE
"$<BUILD_INTERFACE:${_openexr_imath_cfg_compat}>")
endif()
set(OPENEXR_IMATH_SUBDIR_INCLUDE_PATCH "${_openexr_imath_inc_patch_key}" CACHE INTERNAL "")
target_include_directories(Imath INTERFACE
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This fix mirrors what I just submitted in #2444, I think. Fine to leave it here.

"$<BUILD_INTERFACE:${Imath_SOURCE_DIR}/src>")
if(EXISTS "${_openexr_imath_gen_cfg}")
target_include_directories(ImathConfig INTERFACE
"$<BUILD_INTERFACE:${_openexr_imath_cfg_compat}>")
endif()
endif()
endif()
Expand Down
12 changes: 11 additions & 1 deletion external/OpenJPH/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ option(OJPH_ENABLE_TIFF_SUPPORT "Enables input and output support for TIFF files
option(OJPH_BUILD_TESTS "Enables building test code" OFF)
option(OJPH_BUILD_EXECUTABLES "Enables building command line executables" ON)
option(OJPH_BUILD_STREAM_EXPAND "Enables building ojph_stream_expand executable" OFF)
option(OJPH_BUILD_FUZZER "Enables building oss-fuzzing target executable" OFF)

option(OJPH_DISABLE_SIMD "Disables the use of SIMD instructions -- agnostic to architectures" OFF)
option(OJPH_DISABLE_SSE "Disables the use of SSE SIMD instructions and associated files" OFF)
Expand Down Expand Up @@ -230,10 +231,19 @@ install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
)

################################################################################################
# Testing (OJPH_BUILD_TESTS)
# Testing and fuzzing (OJPH_BUILD_TESTS)
################################################################################################

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND OJPH_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()

################################################################################################
# Testing and fuzzing (OJPH_BUILD_FUZZER)
################################################################################################

if(OJPH_BUILD_FUZZER)
add_subdirectory(fuzzing)
endif()

2 changes: 1 addition & 1 deletion external/OpenJPH/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The standard is available free of charge from [ITU website](https://www.itu.int/
* [Usage Example](./docs/usage_examples.md)
* [Web-based Demos](./docs/web_demos.md)
* [Doxygen Documentation Style](./docs/doxygen_style.md)
* [OSS-Fuzzing](./docs/fuzzing.md)

# Repositories #
[![Packaging status](https://repology.org/badge/vertical-allrepos/openjph.svg)](https://repology.org/project/openjph/versions)

12 changes: 11 additions & 1 deletion external/OpenJPH/src/core/codestream/ojph_codestream_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,17 @@ namespace ojph {
ui32 num_comments)
{
//finalize
siz.check_validity(cod);
siz.set_cod(cod);
// set the tile size if it was not set by the user
size tile_size = siz.get_tile_size();
if (tile_size.h == 0 && tile_size.w == 0)
{
point img_offset = siz.get_image_offset();
point img_extent = siz.get_image_extent();
size t(img_extent.x + img_offset.x, img_extent.y + img_offset.y);
siz.set_tile_size(t);
}
siz.check_validity();
cod.check_validity(siz);
cod.update_atk(&atk);
qcd.check_validity(siz, cod);
Expand Down
122 changes: 88 additions & 34 deletions external/OpenJPH/src/core/codestream/ojph_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,25 @@ namespace ojph {
////////////////////////////////////////////////////////////////////////////
void param_siz::set_image_extent(point dims)
{
state->Xsiz = dims.x;
state->Ysiz = dims.y;
state->set_image_extent(dims);
}

////////////////////////////////////////////////////////////////////////////
void param_siz::set_tile_size(size s)
{
state->XTsiz = s.w;
state->YTsiz = s.h;
state->set_tile_size(s);
}

////////////////////////////////////////////////////////////////////////////
void param_siz::set_image_offset(point offset)
{ // WARNING need to check if these are valid
state->XOsiz = offset.x;
state->YOsiz = offset.y;
{
state->set_image_offset(offset);
}

////////////////////////////////////////////////////////////////////////////
void param_siz::set_tile_offset(point offset)
{ // WARNING need to check if these are valid
state->XTOsiz = offset.x;
state->YTOsiz = offset.y;
{
state->set_tile_offset(offset);
}

////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -703,24 +699,24 @@ namespace ojph {
if (file->read(&Ysiz, 4) != 4)
OJPH_ERROR(0x00050046, "error reading SIZ marker");
Ysiz = swap_byte(Ysiz);
if (file->read(&XOsiz, 4) != 4)
ui32 t_XOsiz, t_YOsiz;
if (file->read(&t_XOsiz, 4) != 4)
OJPH_ERROR(0x00050047, "error reading SIZ marker");
XOsiz = swap_byte(XOsiz);
if (file->read(&YOsiz, 4) != 4)
if (file->read(&t_YOsiz, 4) != 4)
OJPH_ERROR(0x00050048, "error reading SIZ marker");
YOsiz = swap_byte(YOsiz);
if (file->read(&XTsiz, 4) != 4)
set_image_offset(point(swap_byte(t_XOsiz), swap_byte(t_YOsiz)));
ui32 t_XTsiz, t_YTsiz;
if (file->read(&t_XTsiz, 4) != 4)
OJPH_ERROR(0x00050049, "error reading SIZ marker");
XTsiz = swap_byte(XTsiz);
if (file->read(&YTsiz, 4) != 4)
if (file->read(&t_YTsiz, 4) != 4)
OJPH_ERROR(0x0005004A, "error reading SIZ marker");
YTsiz = swap_byte(YTsiz);
if (file->read(&XTOsiz, 4) != 4)
set_tile_size(size(swap_byte(t_XTsiz), swap_byte(t_YTsiz)));
ui32 t_XTOsiz, t_YTOsiz;
if (file->read(&t_XTOsiz, 4) != 4)
OJPH_ERROR(0x0005004B, "error reading SIZ marker");
XTOsiz = swap_byte(XTOsiz);
if (file->read(&YTOsiz, 4) != 4)
if (file->read(&t_YTOsiz, 4) != 4)
OJPH_ERROR(0x0005004C, "error reading SIZ marker");
YTOsiz = swap_byte(YTOsiz);
set_tile_offset(point(swap_byte(t_XTOsiz), swap_byte(t_YTOsiz)));
if (file->read(&Csiz, 2) != 2)
OJPH_ERROR(0x0005004D, "error reading SIZ marker");
Csiz = swap_byte(Csiz);
Expand All @@ -745,6 +741,8 @@ namespace ojph {

ws_kern_support_needed = (Rsiz & 0x20) != 0;
dfs_support_needed = (Rsiz & 0x80) != 0;

check_validity();
}

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -994,10 +992,21 @@ namespace ojph {
OJPH_ERROR(0x0005007E, "unsupported settings in a COD-SPcod parameter");

ui8 num_decompositions = get_num_decompositions();
if (Scod & 1)
for (int i = 0; i <= num_decompositions; ++i)
if (Scod & 1) {
for (int i = 0; i <= num_decompositions; ++i) {
if (file->read(&SPcod.precinct_size[i], 1) != 1)
OJPH_ERROR(0x0005007B, "error reading COD segment");
if (i)
if ((SPcod.precinct_size[i] & 0x0F) == 0 ||
(SPcod.precinct_size[i] >> 4) == 0)
OJPH_ERROR(0x0005007F,
"Precinct width or height for resolutions other than the"
" coarsest must be larger than 1; here, they are %d and %d,"
" respectively.",
1 << (SPcod.precinct_size[i] & 0x0F),
1 << (SPcod.precinct_size[i] >> 4));
}
}
if (Lcod != 12 + ((Scod & 1) ? 1 + SPcod.num_decomp : 0))
OJPH_ERROR(0x0005007C, "error in COD segment length");
}
Expand Down Expand Up @@ -1053,10 +1062,21 @@ namespace ojph {
OJPH_ERROR(0x0005012D, "unsupported settings in a COC-SPcoc parameter");

ui8 num_decompositions = get_num_decompositions();
if (Scod & 1)
for (int i = 0; i <= num_decompositions; ++i)
if (Scod & 1) {
for (int i = 0; i <= num_decompositions; ++i) {
if (file->read(&SPcod.precinct_size[i], 1) != 1)
OJPH_ERROR(0x0005012A, "error reading COC segment");
if (i)
if ((SPcod.precinct_size[i] & 0x0F) == 0 ||
(SPcod.precinct_size[i] >> 4) == 0)
OJPH_ERROR(0x0005012E,
"Precinct width or height for resolutions other than the"
" coarsest must be larger than 1; here, they are %d and %d,"
" respectively.",
1 << (SPcod.precinct_size[i] & 0x0F),
1 << (SPcod.precinct_size[i] >> 4));
}
}
ui32 t = 9;
t += num_comps < 257 ? 0 : 1;
t += (Scod & 1) ? 1 + num_decompositions : 0;
Expand Down Expand Up @@ -1196,8 +1216,10 @@ namespace ojph {
qcd_component < 3 ? employing_color_transform : false);
else if (qcd_wavelet_kern == param_cod::DWT_IRV97)
{
if (this->base_delta == -1.0f)
this->base_delta = 1.0f / (float)(1 << qcd_bit_depth);
if (this->base_delta == -1.0f) {
ui32 t = ojph_min(16, qcd_bit_depth);
this->base_delta = 1.0f / (float)(1 << t);
}
set_irrev_quant(qcd_num_decompositions);
}
else
Expand Down Expand Up @@ -1230,8 +1252,16 @@ namespace ojph {
c < 3 ? employing_color_transform : false);
else if (cp->get_wavelet_kern() == param_cod::DWT_IRV97)
{
if (qp->base_delta == -1.0f)
qp->base_delta = 1.0f / (float)(1 << bit_depth);
if (qp->base_delta == -1.0f) {
if (qcd_wavelet_kern == param_cod::DWT_IRV97) {
assert(this->base_delta != -1.0f);
qp->base_delta = this->base_delta;
}
else {
ui32 t = ojph_min(16, qcd_bit_depth);
qp->base_delta = 1.0f / (float)(1 << t);
}
}
qp->set_irrev_quant(num_decompositions);
}
else
Expand All @@ -1255,8 +1285,16 @@ namespace ojph {
c < 3 ? employing_color_transform : false);
else if (cp->get_wavelet_kern() == param_cod::DWT_IRV97)
{
if (qp->base_delta == -1.0f)
qp->base_delta = 1.0f / (float)(1 << bit_depth);
if (qp->base_delta == -1.0f) {
if (qcd_wavelet_kern == param_cod::DWT_IRV97) {
assert(this->base_delta != -1.0f);
qp->base_delta = this->base_delta;
}
else {
ui32 t = ojph_min(16, qcd_bit_depth);
qp->base_delta = 1.0f / (float)(1 << t);
}
}
qp->set_irrev_quant(num_decompositions);
}
else
Expand Down Expand Up @@ -1401,11 +1439,15 @@ namespace ojph {

//////////////////////////////////////////////////////////////////////////
float param_qcd::get_irrev_delta(const param_dfs* dfs,
ui32 num_decompositions,
ui32 num_decompositions, ui32 comp_num,
ui32 resolution, ui32 subband) const
{
float arr[] = { 1.0f, 2.0f, 2.0f, 4.0f };
assert((Sqcd & 0x1F) == 2);
if ((Sqcd & 0x1F) != 2)
OJPH_ERROR(0x00050101, "There is something wrong in the configuration "
"of the codestream; for component %d, the codestream defines an "
"irreversible transform, for which the codestream provides a "
"reversible (no quantization) step sizes in Sqcd/Sqcc.", comp_num);

ui32 idx;
if (dfs != NULL && dfs->exists())
Expand Down Expand Up @@ -1657,6 +1699,9 @@ namespace ojph {
if ((Sqcd & 0x1F) == 0)
{
num_subbands = (Lqcd - 3);
if (num_subbands == 0)
OJPH_ERROR(0x0005008A, "QCD marker segment that specifies no "
"quantization informtion");
if (num_subbands > 97 || Lqcd != 3 + num_subbands)
OJPH_ERROR(0x00050083, "wrong Lqcd value of %d in QCD marker", Lqcd);
for (ui32 i = 0; i < num_subbands; ++i)
Expand All @@ -1674,6 +1719,9 @@ namespace ojph {
else if ((Sqcd & 0x1F) == 2)
{
num_subbands = (Lqcd - 3) / 2;
if (num_subbands == 0)
OJPH_ERROR(0x0005008B, "QCD marker segment that specifies no "
"quantization informtion");
if (num_subbands > 97 || Lqcd != 3 + 2 * num_subbands)
OJPH_ERROR(0x00050086, "wrong Lqcd value of %d in QCD marker", Lqcd);
for (ui32 i = 0; i < num_subbands; ++i)
Expand Down Expand Up @@ -1712,6 +1760,9 @@ namespace ojph {
if ((Sqcd & 0x1F) == 0)
{
num_subbands = (Lqcd - offset);
if (num_subbands == 0)
OJPH_ERROR(0x000500AC, "QCC marker segment that specifies no "
"quantization informtion");
if (num_subbands > 97 || Lqcd != offset + num_subbands)
OJPH_ERROR(0x000500A5, "wrong Lqcd value of %d in QCC marker", Lqcd);
for (ui32 i = 0; i < num_subbands; ++i)
Expand All @@ -1729,6 +1780,9 @@ namespace ojph {
else if ((Sqcd & 0x1F) == 2)
{
num_subbands = (Lqcd - offset) / 2;
if (num_subbands == 0)
OJPH_ERROR(0x000500AD, "QCC marker segment that specifies no "
"quantization informtion");
if (num_subbands > 97 || Lqcd != offset + 2 * num_subbands)
OJPH_ERROR(0x000500A8, "wrong Lqcc value of %d in QCC marker", Lqcd);
for (ui32 i = 0; i < num_subbands; ++i)
Expand Down
Loading
Loading