minor speedups

This commit is contained in:
heckflosse 2019-07-02 23:24:58 +02:00
parent bb11f68535
commit c04171bf34
2 changed files with 19 additions and 15 deletions

View File

@ -37,8 +37,6 @@
#include "ciecam02.h" #include "ciecam02.h"
#include "color.h" #include "color.h"
#include "iccstore.h" #include "iccstore.h"
#undef CLIPD
#define CLIPD(a) ((a)>0.0f?((a)<1.0f?(a):1.0f):0.0f)
using namespace std; using namespace std;
@ -635,33 +633,37 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
//%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%
// change to [0,1] range // 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. 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; if (black == 0.0) {
float val2 = simplebasecurve (val, black, 0.015 * shcompr); shCurve.makeConstant(1.f);
shCurve[0] = CLIPD(val2) / val; } else {
const float val = 1.f / 65535.f;
shCurve[0] = simplebasecurve(val, black, 0.015 * shcompr) / val;
}
// gamma correction // gamma correction
val = Color::gammatab_srgb[0] / 65535.f; float val = Color::gammatab_srgb1[0];
// apply brightness curve // apply brightness curve
if (brightcurve) { 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 // store result in a temporary array
dcurve[0] = CLIPD(val); dcurve[0] = LIM01<float>(val);
for (int i = 1; i < 0x10000; i++) { for (int i = 1; i < 0x10000; i++) {
float val = i / 65535.f;
float val2 = simplebasecurve (val, black, 0.015 * shcompr); if (black != 0.0) {
shCurve[i] = val2 / val; const float val = i / 65535.f;
shCurve[i] = simplebasecurve(val, black, 0.015 * shcompr) / val;
}
// gamma correction // gamma correction
val = Color::gammatab_srgb[i] / 65535.f; float val = Color::gammatab_srgb1[i];
// apply brightness curve // apply brightness curve
if (brightcurve) { if (brightcurve) {
val = CLIPD(brightcurve->getVal (val)); // TODO: getVal(double) is very slow! Optimize with a LUTf val = LIM01<float>(brightcurve->getVal (val)); // TODO: getVal(double) is very slow! Optimize with a LUTf
} }
// store result in a temporary array // store result in a temporary array
@ -849,7 +851,7 @@ void CurveFactory::complexLCurve (double br, double contr, const std::vector<dou
val = brightcurve.getVal (val); val = brightcurve.getVal (val);
// store result in a temporary array // store result in a temporary array
outCurve[i] = CLIPD(val); outCurve[i] = LIM01<float>(val);
} }
} else { } else {

View File

@ -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); 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) { if (dcpProf) {
dcpProf->step2ApplyTile (rtemp, gtemp, btemp, tW - jstart, tH - istart, TS, asIn); dcpProf->step2ApplyTile (rtemp, gtemp, btemp, tW - jstart, tH - istart, TS, asIn);