Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions src/openexr.imageio/exrinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ OpenEXRInput::PartInfo::parse_header(OpenEXRInput* in,
case Imf::DWAB_COMPRESSION: comp = "dwab"; break;
#ifdef IMF_HTJ2K_COMPRESSION
case Imf::HTJ2K_COMPRESSION: comp = "htj2k"; break;
#endif
#ifdef IMF_ZSTD_COMPRESSION
case Imf::ZSTD_COMPRESSION: comp = "zstd"; break;
#endif
default: break;
}
Expand Down
3 changes: 3 additions & 0 deletions src/openexr.imageio/exrinput_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,9 @@ OpenEXRCoreInput::PartInfo::parse_header(OpenEXRCoreInput* in,
case EXR_COMPRESSION_DWAB: comp = "dwab"; break;
#ifdef IMF_HTJ2K_COMPRESSION
case EXR_COMPRESSION_HTJ2K: comp = "htj2k"; break;
#endif
#ifdef IMF_ZSTD_COMPRESSION
case EXR_COMPRESSION_ZSTD: comp = "zstd"; break;
#endif
default: break;
}
Expand Down
12 changes: 12 additions & 0 deletions src/openexr.imageio/exroutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,14 @@ OpenEXROutput::spec_to_header(ImageSpec& spec, int subimage,
if (Strutil::istarts_with(comp, "zip")) {
header.zipCompressionLevel() = (qual >= 1 && qual <= 9) ? qual : 4;
}
#endif
#if OPENEXR_CODED_VERSION >= 30500
// OpenEXR 3.5.0 and later allow us to pick the level. We've found
// that 5 is a great tradeoff between size and speed, so that is our
// default.
if (Strutil::istarts_with(comp, "zstd")) {
header.zstdCompressionLevel() = (qual >= 1 && qual <= 22) ? qual : 5;
Copy link
Contributor

Choose a reason for hiding this comment

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

It will be important to document these values, and zstd in general, in the src/doc/builtinplugins.rst file under the OpenEXR section.

}
#endif
if (Strutil::istarts_with(comp, "dwa") && qual > 0) {
#if OPENEXR_CODED_VERSION >= 30103
Expand Down Expand Up @@ -964,6 +972,10 @@ OpenEXROutput::put_parameter(const std::string& name, TypeDesc type,
#ifdef IMF_HTJ2K_COMPRESSION
else if (Strutil::iequals(str, "htj2k"))
header.compression() = Imf::HTJ2K_COMPRESSION;
#endif
#ifdef IMF_ZSTD_COMPRESSION
else if (Strutil::iequals(str, "zstd"))
header.compression() = Imf::ZSTD_COMPRESSION;
#endif
}
return true;
Expand Down
Loading