Skip to content

Conversation

@lji-ilm
Copy link
Contributor

@lji-ilm lji-ilm commented May 26, 2025

Description

After adding the new htj2k compression codec to OpenEXR, here we enable it in the OIIO stack so it will be recognized by the library and binary tools, such as using oiiotool to directly change compression type into htj2k.

EXR side is planning to do a round of renaming of enum names (AcademySoftwareFoundation/openexr#2048), and therefore this MR is marked as Draft for visibility for now. The enum names should be changed to htj2k name after 2048 on the EXR side goes into the mainline.

I'm also trying to study if more changes on the OIIO side is required to enabled the new htj2k codec throughout the OIIO tool chain... suggestions welcome.

Tests

Draft MR, more test will be followed up.

Does this need a new test?

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable. (Check if there is no
    need to update the documentation, for example if this is a bug fix that
    doesn't change the API.)
  • I have ensured that the change is tested somewhere in the testsuite
    (adding new test cases if necessary).
  • If I added or modified a C++ API call, I have also amended the
    corresponding Python bindings (and if altering ImageBufAlgo functions, also
    exposed the new functionality as oiiotool options).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format before submitting, I definitely will look at the CI
    test that runs clang-format and fix anything that it highlights as being
    nonconforming.

case Imf::B44A_COMPRESSION: comp = "b44a"; break;
case Imf::DWAA_COMPRESSION: comp = "dwaa"; break;
case Imf::DWAB_COMPRESSION: comp = "dwab"; break;
case Imf::HT256_COMPRESSION: comp = "htj2k"; break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're going to need some sort of guard here to prevent it from being a compiler error when using older versions of the library. We used to have that for DWA compression, though we eventually removed the guards once our minimum supported OpenEXR version was high enough to be guaranteed to have those symbols.

Maybe something like

#if OPENEXR_CODED_VERSION >= 30400

Though that wouldn't cover the case of the current "main" if we haven't flipped the version number yet.

Did the OpenEXR htj2k patch add some kind of #define in its headers that would give us an easy way to check if those symbols are going to be defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I contemplated on this last night too.

Now I'm inclined to not do this in OIIO until a bit later, and do this patch -- at the same time bump OIIO's required EXR version to 3.4?
HT2K is a new codec and maybe people will discover issues upon it being officially released by EXR upon 3.4; I think it is okay for OIIO to run "behind" exr a bit, and support this when we're confident that EXR 3.4 is running without problem for those low level developers who can/need to use EXR directly. At that point we'll open this feature on OIIO for the pipeline developers.

Maybe we can hang this PR as draft here for a while for early adopters. I'll keep rebase it from time to time.

Do we need to add a constant in OIIO python binding somewhere too?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Our policy is to support OpenEXR versions up to at least 3 years back. It will be a long time before we can enforce openexr 3.4 as a minimum.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should handle this the same way as we have always handled other newly introduced features:

  1. Build against any version of OpenEXR (within reason, but going back at least as far as what VFX Platform said 3 years ago).
  2. Identify some preprocessor symbol or version in the OpenEXR header that accurately identifies whether the feature is available so that we don't have a broken build. If no such identifiable symbol exists, we should add it on the OpenEXR file, or we should bump the reported version in OpenEXR main now, rather than only upon the immediate lead-up to release in the fall.
  3. Use #if guards on the OIIO side when behavior needs to change for differing openexr versions, and when OIIO requests a feature from a version that doesn't support it, make sure we are giving appropriate error messages that make it clear that this is the reason.

We used to have exactly this scheme around DWAA and DWAB compression methods, but the extra logic was eventually removed when our minimum openexr was up to where DWA compression was added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback. I have edited the PR to include the macro-based switch.
I have done some preliminary testing and it seems to be working with the current EXR main tip. Also works with an older release which doesn't have the macro defined.

I'll do a bit more testing tomorrow.

Signed-off-by: lji <[email protected]>
@lji-ilm lji-ilm changed the title [Draft] Add htj2k as a compression option in OIIO Add htj2k as a compression option for the OpenEXR plugin in OIIO May 28, 2025
@lgritz
Copy link
Collaborator

lgritz commented May 28, 2025

Before this is ready to mark as non-draft, can you also please amend builtinplugins.md where there is a table or list of which compression methods we support? Thanks.

@lji-ilm lji-ilm marked this pull request as ready for review May 28, 2025 00:51
@lji-ilm lji-ilm marked this pull request as draft May 28, 2025 00:53
@lji-ilm
Copy link
Contributor Author

lji-ilm commented May 28, 2025

Before this is ready to mark as non-draft, can you also please amend builtinplugins.md where there is a table or list of which compression methods we support? Thanks.

Thanks for the feedback. I added "htj2k" as one of the options for EXR compression in the doc. Here is a test sphinx rendering of the edited passage.

image

I also examined the python binding layer; however, as that layer is format agnostic, I don't think any change is required.

Let me know if we should write a more detailed explanation on exr's htj2k option.

@lji-ilm lji-ilm marked this pull request as ready for review May 28, 2025 17:50
@lgritz
Copy link
Collaborator

lgritz commented May 28, 2025

Let me know if we should write a more detailed explanation on exr's htj2k option.

It might be nice to point out that htj2k is only supported for OpenEXR >= 3.4.

But other than that, this all looks good to me.

@lji-ilm
Copy link
Contributor Author

lji-ilm commented May 28, 2025

Let me know if we should write a more detailed explanation on exr's htj2k option.

It might be nice to point out that htj2k is only supported for OpenEXR >= 3.4.

But other than that, this all looks good to me.

Thanks for the feedback! I've updated the rst file with a note about this.

Test sphinx rendering below:
Screenshot 2025-05-28 at 1 59 20 PM

Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

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

LGTM!

@lgritz lgritz merged commit 8031b57 into AcademySoftwareFoundation:main May 28, 2025
32 checks passed
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request May 31, 2025
…wareFoundation#4785)

After adding the new `htj2k` compression codec to OpenEXR, here we
enable it in the OIIO stack so it will be recognized by the library and
binary tools, such as using `oiiotool` to directly change compression
type into htj2k.

---------

Signed-off-by: lji <[email protected]>
zachlewis pushed a commit to zachlewis/OpenImageIO that referenced this pull request Aug 1, 2025
…wareFoundation#4785)

After adding the new `htj2k` compression codec to OpenEXR, here we
enable it in the OIIO stack so it will be recognized by the library and
binary tools, such as using `oiiotool` to directly change compression
type into htj2k.

---------

Signed-off-by: lji <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants