Fix rtengine::min() for NaNs (#3742)

Also fix `LuminanceToneCurve::Apply()`. Kudos to @heckflosse!
This commit is contained in:
Flössie
2017-03-08 20:23:57 +01:00
parent 06137b02be
commit 61b913f7f9
2 changed files with 4 additions and 3 deletions

View File

@@ -994,8 +994,9 @@ inline void LuminanceToneCurve::Apply(float &r, float &g, float &b) const
assert (lutToneCurve);
float currLuminance = r * 0.2126729f + g * 0.7151521f + b * 0.0721750f;
float newLuminance = lutToneCurve[currLuminance];
float coef = newLuminance / currLuminance;
const float newLuminance = lutToneCurve[currLuminance];
currLuminance = currLuminance == 0.f ? 0.00001f : currLuminance;
const float coef = newLuminance / currLuminance;
r = LIM<float>(r * coef, 0.f, 65535.f);
g = LIM<float>(g * coef, 0.f, 65535.f);
b = LIM<float>(b * coef, 0.f, 65535.f);

View File

@@ -42,7 +42,7 @@ constexpr const T& min(const T& a)
template<typename T>
constexpr const T& min(const T& a, const T& b)
{
return a < b ? a : b;
return b < a ? b : a;
}
template<typename T, typename... ARGS>