From b54528fa1ed49625a8988bbd9c6191f844231e47 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Thu, 1 Aug 2019 18:17:56 +0200 Subject: BrightContrast not working correctly with negative contrast followup to rB8dd95abb2ff9 (which fixed this for the Compositor node), turns out this was also wrong for the VSE modifier and in vertex color operator. - also adjust min/max for VSE modifier - also guard against division by zero Reviewers: brecht Maniphest Tasks: T67808 Differential Revision: https://developer.blender.org/D5398 --- source/blender/compositor/operations/COM_BrightnessOperation.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/compositor/operations') diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp index d0bab5aa4d9..b6c22029899 100644 --- a/source/blender/compositor/operations/COM_BrightnessOperation.cpp +++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp @@ -62,12 +62,13 @@ void BrightnessOperation::executePixelSampled(float output[4], * Extracted of OpenCV demhist.c */ if (contrast > 0) { - a = 1.0f / (1.0f - delta * 2.0f); + a = 1.0f - delta * 2.0f; + a = 1.0f / max_ff(a, FLT_EPSILON); b = a * (brightness - delta); } else { delta *= -1; - a = 1.0f - delta * 2.0f; + a = max_ff(1.0f - delta * 2.0f, 0.0f); b = a * brightness + delta; } if (this->m_use_premultiply) { -- cgit v1.2.3