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 "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<float>(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<float>(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<dou
val = brightcurve.getVal (val);
// store result in a temporary array
outCurve[i] = CLIPD(val);
outCurve[i] = LIM01<float>(val);
}
} 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);
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);