Skip to content

Commit 75f0fbe

Browse files
kdt3rdcary-ilm
authored andcommitted
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 <[email protected]>
1 parent 97f8571 commit 75f0fbe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/lib/OpenEXRCore/part.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,12 @@ exr_set_dwa_compression_level (exr_context_t ctxt, int part_index, float level)
609609
return EXR_UNLOCK_AND_RETURN (
610610
ctxt->standard_error (ctxt, EXR_ERR_NOT_OPEN_WRITE));
611611

612-
if (level > 0.f && level <= 100.f)
612+
// avoid bad math (fp exceptions or whatever) by clamping here
613+
// there has always been a clamp to 0, but on the upper end, there
614+
// is a limit too, where you only get black images anyway, so that
615+
// is not particularly useful, not that any large value will
616+
// really be crushing the image
617+
if (level >= 0.f && level <= (65504.f*100000.f))
613618
{
614619
part->dwa_compression_level = level;
615620
rv = EXR_ERR_SUCCESS;

0 commit comments

Comments
 (0)