Skip to content

Commit 81acb23

Browse files
lgritzCopilot
andauthored
build: several OpenEXR and OpenJPH build related fixes (AcademySoftwareFoundation#4875)
Original changes and goal: * Bump our "latest releases" CI tests to OpenEXR 3.4.0 * cleanup: dead guard removal for openexr -- our minimum OpenEXR release supports float vectors, so we don't need any `#if` guards for it anymore. * Fix warnings related to mixing Core and C++ library constants for H2J2K compression enums within a switch statement (only noticed on ARM Linux with Clang 18). But it seems that OpenEXR 3.4's auto-building of OpenJPH (to support exr's new h2j2k compression methods) revealed that our CI wasn't building and testing against OpenJPG as well as we thought. So: * Clean up some openjph API use and type mismatches * Suppress warnings on clang and recent gcc versions had with the OpenJPH headers and our use of them. * Fix our test scripts and reference output for the htj2k tests; I think maybe they weren't running at all before, and nad some incorrect file paths. Finally, * When no OpenEXR is found, update the auto-build version to 3.3.5. I wish I could go all the way to 3.4.0, but the OpenEXR 3.4.0 currently auto-builds OpenJPH in a way that (I think incorrectly) installs the OpenJPH components in ways that can overwrite or break existing installations. * Remove FindOpenJPH.cmake, the nomenclature clashes with the lowercase "openjph" used by the new OpenJPH exported cmake configs. * But those are only generated for OpenJPH >= 0.21.2, so make that our new minimum. (This only affects OIIO 3.1 and higher, so it's safe to do this.) --------- Signed-off-by: Larry Gritz <lg@larrygritz.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 0b2e4a3 commit 81acb23

File tree

13 files changed

+59
-104
lines changed

13 files changed

+59
-104
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ jobs:
420420
cxx_std: 20
421421
fmt_ver: 11.2.0
422422
opencolorio_ver: v2.4.2
423-
openexr_ver: v3.4-alpha
423+
openexr_ver: v3.4.0
424424
pybind11_ver: v3.0.0
425425
python_ver: "3.12"
426426
simd: avx2,f16c
@@ -511,44 +511,44 @@ jobs:
511511
depcmds: |
512512
sudo rm -rf /usr/local/include/OpenEXR
513513
sudo rm -rf /usr/local/lib64/cmake/{IlmBase,OpenEXR}
514-
- desc: Linux ARM latest releases gcc14 C++20 py3.12 exr3.3 ocio2.4
514+
- desc: Linux ARM latest releases gcc14 C++20 py3.12 exr3.4 ocio2.4
515515
nametag: linux-arm-latest-releases
516516
runner: ubuntu-24.04-arm
517517
cc_compiler: gcc-14
518518
cxx_compiler: g++-14
519519
cxx_std: 20
520-
fmt_ver: 11.1.4
520+
fmt_ver: 11.2.0
521521
opencolorio_ver: v2.4.2
522-
openexr_ver: v3.3.3
522+
openexr_ver: v3.4.0
523523
pybind11_ver: v3.0.0
524524
python_ver: "3.12"
525-
setenvs: export LIBJPEGTURBO_VERSION=3.1.0
526-
LIBRAW_VERSION=0.21.3
525+
setenvs: export LIBJPEGTURBO_VERSION=3.1.1
526+
LIBRAW_VERSION=0.21.4
527527
LIBTIFF_VERSION=v4.7.0
528528
OPENJPEG_VERSION=v2.5.3
529529
PTEX_VERSION=v2.4.3
530530
PUGIXML_VERSION=v1.15
531-
WEBP_VERSION=v1.5.0
531+
WEBP_VERSION=v1.6.0
532532
FREETYPE_VERSION=VER-2-13-3
533533
USE_OPENVDB=0
534-
- desc: Linux ARM latest releases clang18 C++20 py3.12 exr3.3 ocio2.4
534+
- desc: Linux ARM latest releases clang18 C++20 py3.12 exr3.4 ocio2.4
535535
nametag: linux-arm-latest-releases-clang
536536
runner: ubuntu-24.04-arm
537537
cc_compiler: clang-18
538538
cxx_compiler: clang++-18
539539
cxx_std: 20
540-
fmt_ver: 11.1.4
540+
fmt_ver: 11.2.0
541541
opencolorio_ver: v2.4.2
542-
openexr_ver: v3.3.3
542+
openexr_ver: v3.4.0
543543
pybind11_ver: v3.0.0
544544
python_ver: "3.12"
545545
setenvs: export LIBJPEGTURBO_VERSION=3.1.0
546-
LIBRAW_VERSION=0.21.3
546+
LIBRAW_VERSION=0.21.4
547547
LIBTIFF_VERSION=v4.7.0
548548
OPENJPEG_VERSION=v2.5.3
549549
PTEX_VERSION=v2.4.3
550550
PUGIXML_VERSION=v1.15
551-
WEBP_VERSION=v1.5.0
551+
WEBP_VERSION=v1.6.0
552552
FREETYPE_VERSION=VER-2-13-3
553553
USE_OPENVDB=0
554554

INSTALL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
8080
* libjxl >= 0.10.1 (tested through 0.11.1)
8181
* If you want support for "Ultra HDR" inside JPEG images:
8282
* libuhdr >= 1.3 (tested through 1.4)
83+
* If you want support for j2c files:
84+
* OpenJPH >= 0.21 (tested through 0.22)
8385
* We use PugiXML for XML parsing. There is a version embedded in the OIIO
8486
tree, but if you want to use an external, system-installed version (as
8587
may be required by some software distributions with policies against

src/build-scripts/build_openexr.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -ex
1111

1212
# Which OpenEXR to retrieve, how to build it
1313
OPENEXR_REPO=${OPENEXR_REPO:=https://github.com/AcademySoftwareFoundation/openexr.git}
14-
OPENEXR_VERSION=${OPENEXR_VERSION:=v3.2.4}
14+
OPENEXR_VERSION=${OPENEXR_VERSION:=v3.3.5}
1515

1616
# Where to install the final results
1717
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}

src/cmake/build_OpenEXR.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# https://github.com/AcademySoftwareFoundation/OpenImageIO
44

55

6-
set_cache (OpenEXR_BUILD_VERSION 3.2.4 "OpenEXR version for local builds")
6+
set_cache (OpenEXR_BUILD_VERSION 3.3.5 "OpenEXR version for local builds")
77
set (OpenEXR_GIT_REPOSITORY "https://github.com/AcademySoftwareFoundation/OpenEXR")
88
set (OpenEXR_GIT_TAG "v${OpenEXR_BUILD_VERSION}")
99
set_cache (OpenEXR_BUILD_SHARED_LIBS ${LOCAL_BUILD_SHARED_LIBS_DEFAULT}

src/cmake/externalpackages.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ checked_find_package (OpenJPEG VERSION_MIN 2.0
176176
# Note: Recent OpenJPEG versions have exported cmake configs, but we don't
177177
# find them reliable at all, so we stick to our FindOpenJPEG.cmake module.
178178

179-
checked_find_package (OpenJPH VERSION_MIN 0.21)
179+
checked_find_package (openjph VERSION_MIN 0.21.2)
180180

181181
checked_find_package (OpenVDB
182182
VERSION_MIN 9.0

src/cmake/modules/FindOpenJPH.cmake

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/jpeg2000.imageio/jpeg2000input.cpp

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
#ifdef USE_OPENJPH
1919
# include <openjph/ojph_codestream.h>
2020
# include <openjph/ojph_file.h>
21+
OIIO_PRAGMA_WARNING_PUSH
22+
OIIO_GCC_PRAGMA(GCC diagnostic ignored "-Wdelete-incomplete")
2123
# include <openjph/ojph_mem.h>
24+
OIIO_PRAGMA_WARNING_POP
2225
# include <openjph/ojph_message.h>
2326
# include <openjph/ojph_params.h>
2427
#endif
@@ -273,7 +276,13 @@ class jph_infile : public ojph::infile_base {
273276
return ioproxy->seek(offset, origin);
274277
}
275278
ojph::si64 tell() { return ioproxy->tell(); };
276-
bool eof() { return ioproxy->tell() == ioproxy->size(); }
279+
bool eof()
280+
{
281+
int64_t pos = ioproxy->tell();
282+
if (pos < 0)
283+
return false; // Error condition, not EOF
284+
return pos == static_cast<int64_t>(ioproxy->size());
285+
}
277286
void close()
278287
{
279288
ioproxy->close();
@@ -385,50 +394,48 @@ Jpeg2000Input::ojph_read_image()
385394
// We are going to read the whole image into the buffer, since with openjph
386395
// its hard to easily grab part of the image.
387396
if (codestream.is_planar()) {
388-
for (ojph::ui32 c = 0; c < ch; ++c)
389-
390-
for (ojph::ui32 i = 0; i < h; ++i) {
397+
for (int c = 0; c < ch; ++c)
398+
for (int i = 0; i < h; ++i) {
391399
ojph::ui32 comp_num;
392400
ojph::line_buf* line = codestream.pull(comp_num);
393401
const ojph::si32* sp = line->i32;
394-
assert(comp_num == c);
402+
OIIO_DASSERT(int(comp_num) == c);
395403
if (m_spec.format == TypeDesc::UCHAR) {
396404
unsigned char* dout = &m_buf[i * w * ch];
397405
dout += c;
398-
for (ojph::ui32 j = w; j > 0; j--, dout += ch) {
406+
for (int j = w; j > 0; j--, dout += ch) {
399407
*dout = *sp++;
400408
}
401409
}
402410
if (m_spec.format == TypeDesc::USHORT) {
403411
unsigned short* dout
404412
= (unsigned short*)&m_buf[buffer_bpp * (i * w * ch)];
405413
dout += c;
406-
for (ojph::ui32 j = w; j > 0; j--, dout += ch) {
414+
for (int j = w; j > 0; j--, dout += ch) {
407415
*dout = bit_range_convert(*sp++, file_bit_depth,
408416
buffer_bpp * 8);
409417
}
410418
}
411419
}
412-
413420
} else {
414-
for (ojph::ui32 i = 0; i < h; ++i) {
415-
for (ojph::ui32 c = 0; c < ch; ++c) {
421+
for (int i = 0; i < h; ++i) {
422+
for (int c = 0; c < ch; ++c) {
416423
ojph::ui32 comp_num;
417424
ojph::line_buf* line = codestream.pull(comp_num);
418425
const ojph::si32* sp = line->i32;
419-
assert(comp_num == c);
426+
OIIO_DASSERT(int(comp_num) == c);
420427
if (m_spec.format == TypeDesc::UCHAR) {
421428
unsigned char* dout = &m_buf[i * w * ch];
422429
dout += c;
423-
for (ojph::ui32 j = w; j > 0; j--, dout += ch) {
430+
for (int j = w; j > 0; j--, dout += ch) {
424431
*dout = *sp++;
425432
}
426433
}
427434
if (m_spec.format == TypeDesc::USHORT) {
428435
unsigned short* dout
429436
= (unsigned short*)&m_buf[buffer_bpp * (i * w * ch)];
430437
dout += c;
431-
for (ojph::ui32 j = w; j > 0; j--, dout += ch) {
438+
for (int j = w; j > 0; j--, dout += ch) {
432439
*dout = bit_range_convert(*sp++, file_bit_depth,
433440
buffer_bpp * 8);
434441
}
@@ -480,6 +487,9 @@ Jpeg2000Input::open(const std::string& name, ImageSpec& p_spec)
480487
jph_infile* jphinfile = new jph_infile(ioproxy());
481488
ojph_reader = true;
482489
ojph::message_error* default_error = ojph::get_error();
490+
// Disable the default OpenJPH error stream to prevent unwanted error output.
491+
// Errors will be handled by the custom error handler (Oiio_Reader_Error_handler) configured below.
492+
ojph::set_error_stream(nullptr);
483493

484494
try {
485495
Oiio_Reader_Error_handler error_handler(default_error);

src/jpeg2000.imageio/jpeg2000output.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
# include <openjph/ojph_arg.h>
2828
# include <openjph/ojph_codestream.h>
2929
# include <openjph/ojph_file.h>
30+
OIIO_PRAGMA_WARNING_PUSH
31+
OIIO_GCC_PRAGMA(GCC diagnostic ignored "-Wdelete-incomplete")
3032
# include <openjph/ojph_mem.h>
33+
OIIO_PRAGMA_WARNING_POP
3134
# include <openjph/ojph_params.h>
3235
#endif
3336

@@ -760,8 +763,9 @@ Jpeg2000Output::create_jph_image()
760763

761764
siz.set_num_components(m_spec.nchannels);
762765
ojph::point subsample(1, 1); // Default subsample
763-
for (ojph::ui32 c = 0; c < m_spec.nchannels; ++c)
764-
siz.set_component(c, subsample, output_depth, is_signed);
766+
for (int c = 0; c < m_spec.nchannels; ++c)
767+
siz.set_component(static_cast<ojph::ui32>(c), subsample, output_depth,
768+
is_signed);
765769

766770
ojph::size tile_size(0, 0);
767771
ojph::point tile_offset(0, 0);

src/openexr.imageio/exrinput.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ OIIO_GCC_PRAGMA(GCC diagnostic ignored "-Wunused-parameter")
4141
#include <OpenEXR/ImfDoubleAttribute.h>
4242
#include <OpenEXR/ImfEnvmapAttribute.h>
4343
#include <OpenEXR/ImfFloatAttribute.h>
44+
#include <OpenEXR/ImfFloatVectorAttribute.h>
4445
#include <OpenEXR/ImfHeader.h>
45-
#if OPENEXR_HAS_FLOATVECTOR
46-
# include <OpenEXR/ImfFloatVectorAttribute.h>
47-
#endif
4846
#include <OpenEXR/ImfInputPart.h>
4947
#include <OpenEXR/ImfIntAttribute.h>
5048
#include <OpenEXR/ImfKeyCodeAttribute.h>
@@ -432,10 +430,10 @@ OpenEXRInput::PartInfo::parse_header(OpenEXRInput* in,
432430
case Imf::DWAA_COMPRESSION: comp = "dwaa"; break;
433431
case Imf::DWAB_COMPRESSION: comp = "dwab"; break;
434432
#ifdef IMF_HTJ2K256_COMPRESSION
435-
case EXR_COMPRESSION_HTJ2K256: comp = "htj2k256"; break;
433+
case Imf::HTJ2K256_COMPRESSION: comp = "htj2k256"; break;
436434
#endif
437435
#ifdef IMF_HTJ2K32_COMPRESSION
438-
case EXR_COMPRESSION_HTJ2K32: comp = "htj2k32"; break;
436+
case Imf::HTJ2K32_COMPRESSION: comp = "htj2k32"; break;
439437
#endif
440438
default: break;
441439
}
@@ -459,9 +457,7 @@ OpenEXRInput::PartInfo::parse_header(OpenEXRInput* in,
459457
const Imf::KeyCodeAttribute* kcattr;
460458
const Imf::ChromaticitiesAttribute* crattr;
461459
const Imf::RationalAttribute* rattr;
462-
#if OPENEXR_HAS_FLOATVECTOR
463460
const Imf::FloatVectorAttribute* fvattr;
464-
#endif
465461
const Imf::StringVectorAttribute* svattr;
466462
const Imf::DoubleAttribute* dattr;
467463
const Imf::V2dAttribute* v2dattr;
@@ -529,16 +525,13 @@ OpenEXRInput::PartInfo::parse_header(OpenEXRInput* in,
529525
ustrvec[i] = strvec[i];
530526
TypeDesc sv(TypeDesc::STRING, ustrvec.size());
531527
spec.attribute(oname, sv, &ustrvec[0]);
532-
#if OPENEXR_HAS_FLOATVECTOR
533-
534528
} else if (type == "floatvector"
535529
&& (fvattr
536530
= header->findTypedAttribute<Imf::FloatVectorAttribute>(
537531
name))) {
538532
std::vector<float> fvec = fvattr->value();
539533
TypeDesc fv(TypeDesc::FLOAT, fvec.size());
540534
spec.attribute(oname, fv, &fvec[0]);
541-
#endif
542535
} else if (type == "double"
543536
&& (dattr = header->findTypedAttribute<Imf::DoubleAttribute>(
544537
name))) {

src/openexr.imageio/exrinput_c.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ OpenEXRCoreInput::PartInfo::parse_header(OpenEXRCoreInput* in,
629629
case EXR_ATTR_FLOAT_VECTOR: {
630630
TypeDesc fv(TypeDesc::FLOAT, (size_t)attr->floatvector->length);
631631
spec.attribute(oname, fv, attr->floatvector->arr);
632-
633632
break;
634633
}
635634

0 commit comments

Comments
 (0)