Skip to content

Commit

Permalink
Adjust the clamping on the dwa compression
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
kdt3rd authored and cary-ilm committed Feb 18, 2025
1 parent 97f8571 commit 75f0fbe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/OpenEXRCore/part.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 75f0fbe

Please sign in to comment.