Skip to content

Commit

Permalink
use std::abs in chromaticity sanity tests (fixes AcademySoftwareFound…
Browse files Browse the repository at this point in the history
…ation#1177) (AcademySoftwareFoundation#1178)

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman authored and cary-ilm committed Oct 13, 2021
1 parent b7d33a2 commit b5c5f9b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/OpenEXR/ImfChromaticities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ RGBtoXYZ (const Chromaticities &chroma, float Y)
//

// prevent a division that rounds to zero
if (abs(chroma.white.y) <= 1.f && abs(chroma.white.x * Y) >= abs(chroma.white.y) * FLT_MAX)
if (std::abs(chroma.white.y) <= 1.f && std::abs(chroma.white.x * Y) >= std::abs(chroma.white.y) * FLT_MAX)
{
throw std::invalid_argument("Bad chromaticities: white.y cannot be zero");
}
Expand Down Expand Up @@ -108,7 +108,7 @@ RGBtoXYZ (const Chromaticities &chroma, float Y)
chroma.red.y * (X + Z)));


if ( abs(d)<1.f && (abs(SrN) >= abs(d)* FLT_MAX || abs(SgN) >= abs(d)* FLT_MAX || abs(SbN) >= abs(d)* FLT_MAX) )
if ( std::abs(d)<1.f && (std::abs(SrN) >= std::abs(d)* FLT_MAX || std::abs(SgN) >= std::abs(d)* FLT_MAX || std::abs(SbN) >= std::abs(d)* FLT_MAX) )
{
// cannot generate matrix if all RGB primaries have the same y value
// or if they all have the an x value of zero
Expand Down

0 comments on commit b5c5f9b

Please sign in to comment.