From c04171bf34e1d938c6ee4b3f43696e9c8d0e63d8 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Tue, 2 Jul 2019 23:24:58 +0200 Subject: [PATCH] minor speedups --- rtengine/curves.cc | 30 ++++++++++++++++-------------- rtengine/improcfun.cc | 4 +++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/rtengine/curves.cc b/rtengine/curves.cc index ecd38d4aa..f03a43e60 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -37,8 +37,6 @@ #include "ciecam02.h" #include "color.h" #include "iccstore.h" -#undef CLIPD -#define CLIPD(a) ((a)>0.0f?((a)<1.0f?(a):1.0f):0.0f) using namespace std; @@ -635,33 +633,37 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou //%%%%%%%%%%%%%%%%%%%%%%%%%% // change to [0,1] range shCurve.setClip(LUT_CLIP_ABOVE); // used LUT_CLIP_ABOVE, because the curve converges to 1.0 at the upper end and we don't want to exceed this value. - float val = 1.f / 65535.f; - float val2 = simplebasecurve (val, black, 0.015 * shcompr); - shCurve[0] = CLIPD(val2) / val; + if (black == 0.0) { + shCurve.makeConstant(1.f); + } else { + const float val = 1.f / 65535.f; + shCurve[0] = simplebasecurve(val, black, 0.015 * shcompr) / val; + } // gamma correction - val = Color::gammatab_srgb[0] / 65535.f; + float val = Color::gammatab_srgb1[0]; // apply brightness curve if (brightcurve) { - val = brightcurve->getVal (val); // TODO: getVal(double) is very slow! Optimize with a LUTf + val = brightcurve->getVal(val); // TODO: getVal(double) is very slow! Optimize with a LUTf } // store result in a temporary array - dcurve[0] = CLIPD(val); + dcurve[0] = LIM01(val); for (int i = 1; i < 0x10000; i++) { - float val = i / 65535.f; - float val2 = simplebasecurve (val, black, 0.015 * shcompr); - shCurve[i] = val2 / val; + if (black != 0.0) { + const float val = i / 65535.f; + shCurve[i] = simplebasecurve(val, black, 0.015 * shcompr) / val; + } // gamma correction - val = Color::gammatab_srgb[i] / 65535.f; + float val = Color::gammatab_srgb1[i]; // apply brightness curve if (brightcurve) { - val = CLIPD(brightcurve->getVal (val)); // TODO: getVal(double) is very slow! Optimize with a LUTf + val = LIM01(brightcurve->getVal (val)); // TODO: getVal(double) is very slow! Optimize with a LUTf } // store result in a temporary array @@ -849,7 +851,7 @@ void CurveFactory::complexLCurve (double br, double contr, const std::vector(val); } } else { diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index b3fd5f5af..0c1431868 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -2474,7 +2474,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } highlightToneCurve(hltonecurve, rtemp, gtemp, btemp, istart, tH, jstart, tW, TS, exp_scale, comp, hlrange); - shadowToneCurve(shtonecurve, rtemp, gtemp, btemp, istart, tH, jstart, tW, TS); + if (params->toneCurve.black != 0.0) { + shadowToneCurve(shtonecurve, rtemp, gtemp, btemp, istart, tH, jstart, tW, TS); + } if (dcpProf) { dcpProf->step2ApplyTile (rtemp, gtemp, btemp, tW - jstart, tH - istart, TS, asIn);