From 75f0fbec8785fde620cce16216916c5e5a04fa48 Mon Sep 17 00:00:00 2001 From: Kimball Thurston Date: Fri, 14 Feb 2025 00:09:21 +1300 Subject: [PATCH] Adjust the clamping on the dwa compression The dwa compression is not truly a quality level like other things, so a maximal value is controlling quantization, not quality. A value of 0 is allowed, but negative is not. Signed-off-by: Kimball Thurston --- src/lib/OpenEXRCore/part.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/OpenEXRCore/part.c b/src/lib/OpenEXRCore/part.c index 6a51b3c79d..814fd5ceee 100644 --- a/src/lib/OpenEXRCore/part.c +++ b/src/lib/OpenEXRCore/part.c @@ -609,7 +609,12 @@ exr_set_dwa_compression_level (exr_context_t ctxt, int part_index, float level) return EXR_UNLOCK_AND_RETURN ( ctxt->standard_error (ctxt, EXR_ERR_NOT_OPEN_WRITE)); - if (level > 0.f && level <= 100.f) + // avoid bad math (fp exceptions or whatever) by clamping here + // there has always been a clamp to 0, but on the upper end, there + // is a limit too, where you only get black images anyway, so that + // is not particularly useful, not that any large value will + // really be crushing the image + if (level >= 0.f && level <= (65504.f*100000.f)) { part->dwa_compression_level = level; rv = EXR_ERR_SUCCESS;