Skip to content

Commit

Permalink
fix(openexr): modernize dwa compression level setting
Browse files Browse the repository at this point in the history
Starting with OpenEXR 3.1.3, the preferred API call for setting
DWAA/DWAB compression level has changed. We never changed the OIIO
side. Luckily, OpenEXR seems to have kept respecting the old API calls
we were making (passing as an attribute). But this modernizes the
approach, now that we don't have OpenEXR 2.x suppor to maintain.

Signed-off-by: Larry Gritz <[email protected]>
  • Loading branch information
lgritz committed Sep 18, 2024
1 parent 9c7f522 commit 0b09e4b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/openexr.imageio/exroutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
#include <OpenEXR/ImfTiledOutputFile.h>

#include "exr_pvt.h"
#define OPENEXR_CODED_VERSION \
(OPENEXR_VERSION_MAJOR * 10000 + OPENEXR_VERSION_MINOR * 100 \
+ OPENEXR_VERSION_PATCH)

// The way that OpenEXR uses dynamic casting for attributes requires
// temporarily suspending "hidden" symbol visibility mode.
Expand Down Expand Up @@ -734,15 +731,19 @@ OpenEXROutput::spec_to_header(ImageSpec& spec, int subimage,
|| !ispow2(spec.tile_width) || !ispow2(spec.tile_height))) {
comp = "zip";
}
if (Strutil::istarts_with(comp, "dwa")) {
spec.attribute("openexr:dwaCompressionLevel",
qual > 0 ? float(qual) : 45.0f);
}
spec.attribute("compression", comp);
#if OPENEXR_CODED_VERSION >= 30103
if (Strutil::istarts_with(comp, "zip")) {
header.zipCompressionLevel() = (qual >= 1 && qual <= 9) ? qual : 4;
}
if (Strutil::istarts_with(comp, "dwa")) {
header.dwaCompressionLevel() = qual > 0 ? float(qual) : 45.0f;
}
#else
if (Strutil::istarts_with(comp, "dwa")) {
spec.attribute("openexr:dwaCompressionLevel",
qual > 0 ? float(qual) : 45.0f);
}
#endif

// Default to increasingY line order
Expand Down

0 comments on commit 0b09e4b

Please sign in to comment.