-
Notifications
You must be signed in to change notification settings - Fork 663
Add HTJ2K Compressor #1883
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
Conversation
|
The CI is failing in the validate step, which is attempting to link a test program against the library. The error message indicate the link is failing with unresolved symbols, possibly because that cmake configuration is missing the new dependency. However, this part of the CI has been rewritten in the PR I just merged. Can you rebase your branch onto the current main branch now? It may still fail, but hopefully it will be easier to resolve then at least. |
2a3f1c5 to
439cfe5
Compare
@cary-ilm Done. |
|
The failure in the "Validate" step of the linux build is along the lines of what we discussed in the TSC meeting today, the check to make sure "make install" installs just the right files. This output from the logs appears to indicate that the cmake configuration is causing the Try to make sure your cmake "fetch" of |
|
Thanks! What is the best way to run that validate step locally? |
|
@cary-ilm I remember now... I could never fix the following errors: It seems to impose some requirements on openjph, which I could not find a solution for. |
|
I'm not enough of a cmake expert to immediately know how to resolve this. Since this is a work in progress, you could just disable the CI "validate" step entirely for now, just edit the workflow file on your branch and add a "if: false" line, or just delete it. We'll need it resolved eventually before merging, but at least that will allow you to get on with other priorities. I'm happy to help resolve this, but I won't have much time to look into it until mid-January. |
2230cc5 to
e28aaf5
Compare
src/bin/exrconv/main.cpp
Outdated
|
|
||
| // make image filename | ||
| char input_filename[512] = { '\0' }; | ||
| sprintf(input_filename, args->input_filename, frame_index + args->start_frame); |
Check failure
Code scanning / CodeQL
Uncontrolled format string
src/bin/exrconv/main.cpp
Outdated
| // make image filenames | ||
| char input_filename[512] = { '\0' }; | ||
| char output_filename[512] = { '\0' }; | ||
| sprintf(input_filename, args.input_filename, frame_index + args.start_frame); |
Check failure
Code scanning / CodeQL
Uncontrolled format string
src/bin/exrconv/main.cpp
Outdated
| char input_filename[512] = { '\0' }; | ||
| char output_filename[512] = { '\0' }; | ||
| sprintf(input_filename, args.input_filename, frame_index + args.start_frame); | ||
| sprintf(output_filename, args.output_filename, frame_index + args.start_frame); |
Check failure
Code scanning / CodeQL
Uncontrolled format string
|
Regarding |
Yes. exrperf and exrconv will be removed before this is merged. |
|
@cary-ilm I believe this is ready for review and discussion at the upcoming TSC call. |
|
Please either make this optional, and/or also support building w/ system OpenJPH, like libdeflate. Bundling a (unreleased) feature branch/tag is not an ideal solution for long-term distribution... |
|
@kmilos I agree that referencing an unreleased branch/tag of a dependency is not ideal. I expect a release of OpenJPH to be referenced by the time this PR is merged. |
|
Ok, makes sense, thanks @palemieux In the meantime I still think it would also be good to prepare for the detection for the system library, like it is done for libdeflate... |
You mean use the system library if available (through |
Exactly, this is how it is already done for libdeflate (one can skip the CONFIG detection branch as OpenJPH doesn't ship a CMake config, only a pkgconf one). And Imath as well. In addition there are options to force use of the "internal" (fetched from GitHub) ones... |
Ok. No objection from me. Is that regularly tested? |
| {"b44a", Compression::B44A_COMPRESSION}, | ||
| {"dwaa", Compression::DWAA_COMPRESSION}, | ||
| {"dwab", Compression::DWAB_COMPRESSION}, | ||
| {"ht256", Compression::HT256_COMPRESSION}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| {"ht256", Compression::HT256_COMPRESSION}, | |
| {"ht", Compression::HT_COMPRESSION}, |
Rename ht256 to ht 256-scanline chunks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this still need to be resolved? "ht256" still appears in other places, such as in CompressionDesc on line 180 above, does that need to be consistent?
|
setting |
|
Question about RGB channels: I see special handling of RGB in the code. I admit I don't fully understand what's happening there, but are RGB channels in all layers treated as RGB? Would an image with channels called |
|
@peterhillman the compressor makes use of a JPEG 2000 (Part 1) feature that improves coding efficiency when the first three channels are RGB (or equivalent): in that scenario, a decorrelating transform (effectively a RGB to YUV transform) is applied to the channels before coding. Currently both the encode and decoder determine the mapping at run time. The mapping could conceivably be serialized in the file or the the channel order modified by the encoder (if possible). The algorithm could be modified to accommodate channels named something other than How would multiple sets of RGB channels be signaled in the file? Is that a common use case? More complex/flexible JPEG 2000 tools are available if needed. |
|
Channel naming is defined in a couple of places: It's common for a multipart file to contain Having multiple RGB layers within the same part is possible, e.g. six channels forming two layers: There would be a lot of compression efficiency to be gained from a codec that understood that RGB channels within each layer have similarity to each other, but you would also expect strong correlation between all the red components (say) of each layer. Perhaps a future OpenEXR codec could apply a more complex decorrelation transform itself before using JPEG2000. Including the mapping may be useful, and it may even be useful to support custom mappings at write time. #1942 discusses this issue in lossy DWA files, though it's more critical there because it affects image quality not just file size. |
|
@peterhillman Thanks for the detailed information. Will review the code in light of the naming convention. Would supporting custom mappings at write time require a change to the API? What kind of mappings do you have in mind?
JPEG 2000 supports complex component transformations. The questions is whether it is worth involving that machinery at this time. Is there a latent or existing use case for files with, say, multiple R channels within a part? |
Probably an API extension, yes, ideally one that's more general so it can be used across different codecs.
Future work, I think, and probably a new compression method as far as OpenEXR is concerned. Storing many channels within an OpenEXR is relatively common, and those files get very large. Making compression work well in that case would be really beneficial. An example of multiple R channels is a render where different shader components (specular, diffuse, emission) or different CG lights are split out to allow interactive adjustments later without rerendering. The Beachball example sequence is 3D-Stereo image and has separate RGB layers for left and right. It stores a single layer in each part. That is a common strategy as it reduces the amount of data that needs to be loaded and decompressed before accessing a subset of all channels. However, if a codec is very efficient at compressing multiple RGB layers together, it would make sense to store all channels in a single part to reduce the total file size. |
|
@palemieux, well that's unfortunate for the grammar sticklers, even the Library of Congress document is a mix of "High Throughput", "High-Throughput" and "High-throughput". I do see the ISO document has "High-Throughput" in the title, so I'm fine with that. I remove the original suggestions but left a few where things should be updated. |
|
@peterhillman et al. Should the reordering currently automatically performed by the compressor be removed and instead ask the application to provide the channels in RGB order if it wants decorrelation to be performed by the compressor? That would avoid burning in the channel reordering algorithm in the compressor. |
|
The C++ API doesn't track the order you add files to the FrameBuffer or channellist attribute, it maintains them in alphabetical order. That's also the order when they are presented to the compressor. So making the codec aware of the ordering would be tricky. |
|
@peterhillman Ok. Thanks for the background. I am tempted to include the channel map in the codestream... in case the algorithm/naming convention changes in the future. |
|
@peterhillman A channel map is now written to each chunk so that the channel mapping algorithm is not set in stone, as suggested at #1883 (comment) |
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
7148b01 to
04fcf2f
Compare
a06d700
into
AcademySoftwareFoundation:htj2k-beta
|
I probably should have asked this before, but is there a way for a program building against OpenEXR to know if the one it's building against has this capability? |
|
Oh, I think it can test |
|
... or maybe Fixed per #1883 (comment) |
|
The standalone tools that ship with OpenEXR avoid hard-coded references to compression types/enum values by using the various helper functions in ImfCompression.h. A similar approach could avoid the need for any compile-time detection of compression codecs. |
* Add HT256 compressor Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.h Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.cpp Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update website/ReadingAndWritingImageFiles.rst Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Add channel map Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> --------- Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Co-authored-by: Cary Phillips <cary@ilm.com>
* Add HT256 compressor Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.h Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.cpp Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update website/ReadingAndWritingImageFiles.rst Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Add channel map Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> --------- Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Co-authored-by: Cary Phillips <cary@ilm.com>
* Add HT256 compressor Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.h Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.cpp Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update website/ReadingAndWritingImageFiles.rst Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Add channel map Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> --------- Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Co-authored-by: Cary Phillips <cary@ilm.com>
* Add HT256 compressor Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.h Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.cpp Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update website/ReadingAndWritingImageFiles.rst Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Add channel map Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> --------- Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Co-authored-by: Cary Phillips <cary@ilm.com>
* Add HT256 compressor Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.h Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.cpp Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update website/ReadingAndWritingImageFiles.rst Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Add channel map Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> --------- Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Co-authored-by: Cary Phillips <cary@ilm.com>
* Add HT256 compressor Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.h Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.cpp Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update website/ReadingAndWritingImageFiles.rst Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Add channel map Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> --------- Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Co-authored-by: Cary Phillips <cary@ilm.com>
* Add HTJ2K Compressor (#1883) * Add HT256 compressor Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.h Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update src/lib/OpenEXR/ImfCompression.cpp Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Update website/ReadingAndWritingImageFiles.rst Co-authored-by: Cary Phillips <cary@ilm.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Add channel map Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> --------- Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Co-authored-by: Cary Phillips <cary@ilm.com> * Bump OpenJPH (#1978) * Bump OpenJPH to 0.21.2 (#1994) Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Rebase htj2k-beta onto main (#2033) Signed-off-by: Cary Phillips <cary@ilm.com> * Improve RGB channel detection heuristics for the HT256 encoder (#2029) * Allow lowercase r,g and b, and reg, greee and blue. Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Improved RGB channel detection heuristics Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Fix Windows build Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Improve RGB heuristics Add unit tests Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Removed unusued color channel abbreviations Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> --------- Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> * Fix HTJ2K Compressor python (#2038) * HT256 COMPRESSION Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com> * HT256 Compression fix Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com> --------- Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com> * resolve conflicts Signed-off-by: Cary Phillips <cary@ilm.com> * OPENEXR_FORCE_INTERNAL_OPENJPH in pyproject.toml Signed-off-by: Cary Phillips <cary@ilm.com> * POSITION_INDEPENDENT_CODE=ON for openjpg and OpenEXR.so Signed-off-by: Cary Phillips <cary@ilm.com> * CMAKE_VERBOSE_MAKEFILE=ON Signed-off-by: Cary Phillips <cary@ilm.com> * Disable macos universal2 cibuildwheel, doesn't work with openjph Signed-off-by: Cary Phillips <cary@ilm.com> * add openjph to OpenEXR.pc Signed-off-by: Cary Phillips <cary@ilm.com> * using ubuntu-latest for website.yml Signed-off-by: Cary Phillips <cary@ilm.com> * website.1 Signed-off-by: Cary Phillips <cary@ilm.com> --------- Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Cary Phillips <cary@ilm.com> Signed-off-by: Todica Ionut <todicaionut2000111@gmail.com> Co-authored-by: Pierre-Anthony Lemieux <pal@sandflow.com> Co-authored-by: Todica Ionut <todicaionut2000111@gmail.com>
This patch fulfills my action item from the September 19 TSC meeting.
The patch proposes to add support for High-Throughput JPEG 2000 (HTJ2K) compression to OpenEXR -- HTJ2K is JPEG 2000 with the HT block coder standardized in Rec. ITU-T T.814 | ISO/IEC 15444-15. As detailed at Evaluating HTJ2K as a compressor option for OpenEXR, HTJ2K demonstrates significant improvements in both speed and file size over other OpenEXR compressors. Furthermore, HTJ2K is a worldwide standard that benefits from a diversity of implementations, builds on JPEG 2000, which is in broad use in studio workflows, is appropriate for long-term preservation, has both lossy and lossless modes and supports integer and floating point samples. Finally, the unique features of HTJ2K could be powerful additions to high-performance OpenEXR workflows where the full image may not always be viewed at its full resolution.
The patch defines a
ht256compressor, which uses 256-scanline chunks (this is not a limitation of HTJ2K, which can support any number of scanlines) and the open-source OpenJPH library.