Fixed a lot of issues reported by cppcheck 1.78

This commit is contained in:
heckflosse
2017-04-08 22:41:46 +02:00
parent 73e14702dd
commit 6e55f6bab5
41 changed files with 226 additions and 254 deletions

View File

@@ -181,6 +181,9 @@ void ImProcFunctions::firstAnalysis (const Imagefloat* const original, const Pro
histogram += hist;
}
#ifdef _OPENMP
static_cast<void>(numThreads); // to silence cppcheck warning
#endif
} else {
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
@@ -212,7 +215,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
LUTf dLcurve;
LUTu hist16JCAM;
bool jp = false;
float val;
//preparate for histograms CIECAM
if(pW != 1) { //only with improccoordinator
@@ -222,7 +224,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
hist16JCAM.clear();
for (int i = 0; i < 32768; i++) { //# 32768*1.414 approximation maxi for chroma
val = (double)i / 32767.0;
float val = (double)i / 32767.0;
dLcurve[i] = CLIPD(val);
}
}
@@ -230,7 +232,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
LUTf dCcurve;
LUTu hist16_CCAM;
bool chropC = false;
float valc;
if(pW != 1) { //only with improccoordinator
dCcurve(65536, 0);
@@ -238,7 +239,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
hist16_CCAM.clear();
for (int i = 0; i < 48000; i++) { //# 32768*1.414 approximation maxi for chroma
valc = (double)i / 47999.0;
float valc = (double)i / 47999.0;
dCcurve[i] = CLIPD(valc);
}
}
@@ -1208,9 +1209,9 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
artifact = 1.f;
}
int hotbad = 0;
float chrom = 50.f;
{
int hotbad = 0;
ImProcFunctions::badpixcam (ncie, artifact, 5, 2 , b_l, t_l, t_r, b_r, params->dirpyrequalizer.skinprotect , chrom, hotbad); //enabled remove artifacts for cbDL
}
}
@@ -1233,15 +1234,15 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
//if(params->dirpyrequalizer.enabled) if(execsharp) {
if(params->dirpyrequalizer.enabled /*&& (execsharp)*/) {
float b_l = static_cast<float>(params->dirpyrequalizer.hueskin.value[0]) / 100.0f;
float t_l = static_cast<float>(params->dirpyrequalizer.hueskin.value[1]) / 100.0f;
float b_r = static_cast<float>(params->dirpyrequalizer.hueskin.value[2]) / 100.0f;
float t_r = static_cast<float>(params->dirpyrequalizer.hueskin.value[3]) / 100.0f;
int choice = 0; //not disabled in case of ! always 0
// if (params->dirpyrequalizer.algo=="FI") choice=0;
// else if(params->dirpyrequalizer.algo=="LA") choice=1;
if(rtt == 1) {
float b_l = static_cast<float>(params->dirpyrequalizer.hueskin.value[0]) / 100.0f;
float t_l = static_cast<float>(params->dirpyrequalizer.hueskin.value[1]) / 100.0f;
float b_r = static_cast<float>(params->dirpyrequalizer.hueskin.value[2]) / 100.0f;
float t_r = static_cast<float>(params->dirpyrequalizer.hueskin.value[3]) / 100.0f;
int choice = 0; //not disabled in case of ! always 0
dirpyr_equalizercam(ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scalecd); //contrast by detail adapted to CIECAM
}
}
@@ -1314,7 +1315,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
double chsacol = 327.;
int libr = 0;
int colch = 0;
float sa_t;
if(curveMode == ColorAppearanceParams::TC_MODE_BRIGHT) {
brli = 70.0;
@@ -1358,7 +1358,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
if(colch == 0) {
posc = CLIP((int)(ncie->C_p[i][j] * chsacol)); //450.0 approximative factor for s 320 for M
} else if(colch == 1) {
sa_t = 100.f * sqrt(ncie->C_p[i][j] / ncie->Q_p[i][j]); //Q_p always > 0
float sa_t = 100.f * sqrt(ncie->C_p[i][j] / ncie->Q_p[i][j]); //Q_p always > 0
posc = CLIP((int)(sa_t * chsacol));
} else /*if(colch == 2)*/ {
posc = CLIP((int)(ncie->M_p[i][j] * chsacol));
@@ -2590,15 +2590,15 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int
//if(params->dirpyrequalizer.enabled) if(execsharp) {
if(params->dirpyrequalizer.enabled /*&& execsharp*/) {
float b_l = static_cast<float>(params->dirpyrequalizer.hueskin.value[0]) / 100.0f;
float t_l = static_cast<float>(params->dirpyrequalizer.hueskin.value[1]) / 100.0f;
float b_r = static_cast<float>(params->dirpyrequalizer.hueskin.value[2]) / 100.0f;
float t_r = static_cast<float>(params->dirpyrequalizer.hueskin.value[3]) / 100.0f;
int choice = 0; // I have not suppress this statement in case of !! always to 0
// if(params->dirpyrequalizer.algo=="FI") choice=0;
// else if(params->dirpyrequalizer.algo=="LA") choice=1;
if(rtt == 1) {
float b_l = static_cast<float>(params->dirpyrequalizer.hueskin.value[0]) / 100.0f;
float t_l = static_cast<float>(params->dirpyrequalizer.hueskin.value[1]) / 100.0f;
float b_r = static_cast<float>(params->dirpyrequalizer.hueskin.value[2]) / 100.0f;
float t_r = static_cast<float>(params->dirpyrequalizer.hueskin.value[3]) / 100.0f;
int choice = 0; // I have not suppress this statement in case of !! always to 0
lab->deleteLab();
dirpyr_equalizercam(ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scalecd); //contrast by detail adapted to CIECAM
lab->reallocLab();
@@ -2999,10 +2999,6 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
{wprof[2][0], wprof[2][1], wprof[2][2]}
};
// For tonecurve histogram
float lumimulf[3] = {static_cast<float>(lumimul[0]), static_cast<float>(lumimul[1]), static_cast<float>(lumimul[2])};
bool mixchannels = (params->chmixer.red[0] != 100 || params->chmixer.red[1] != 0 || params->chmixer.red[2] != 0 ||
params->chmixer.green[0] != 0 || params->chmixer.green[1] != 100 || params->chmixer.green[2] != 0 ||
params->chmixer.blue[0] != 0 || params->chmixer.blue[1] != 0 || params->chmixer.blue[2] != 100);
@@ -3219,9 +3215,6 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
float gamvalr = 125.f;
float gamvalg = 125.f;
float gamvalb = 125.f;
double nr = 0;
double ng = 0;
double nb = 0;
bool computeMixerAuto = params->blackwhite.autoc && (autor < -5000.f);
if(bwrgam < 0) {
@@ -3260,6 +3253,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
histToneCurveCompression = log2(65536 / toneCurveHistSize);
}
// For tonecurve histogram
const float lumimulf[3] = {static_cast<float>(lumimul[0]), static_cast<float>(lumimul[1]), static_cast<float>(lumimul[2])};
#define TS 112
@@ -4406,6 +4402,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
//end auto chmix
if (computeMixerAuto) {
// auto channel-mixer
double nr = 0;
double ng = 0;
double nb = 0;
#ifdef _OPENMP
#pragma omp parallel for schedule(dynamic, 16) reduction(+:nr,ng,nb)
#endif
@@ -4938,9 +4938,6 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go
rlob = rlo;
}
//second degree
float aa, bb, cc;
float v0 = 0.15f;
//fixed value of reducac=0.3
//secondeg_end (reducac, v0, aa, bb, cc);
@@ -4951,6 +4948,9 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go
kl = (-1.f / 0.85f) * v + (1.f) / 0.85f; //Low light ==> decrease action after v=0.15
}
} else { //color
float v0 = 0.15f;
//second degree
float aa, bb, cc;
secondeg_end (reducac, v0, aa, bb, cc);
float aab, bbb;
secondeg_begin (0.7f, v0, aab, bbb);
@@ -5010,7 +5010,6 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go
// mid tones
float km;
float v0m = 0.5f; //max action
float v0mm = 0.5f; //max
if(v < v0m) {
float aam, bbm;
@@ -5018,6 +5017,7 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go
secondeg_begin (reducac, vend, aam, bbm);
km = aam * v * v + bbm * v; //verification = good
} else {
float v0mm = 0.5f; //max
float aamm, bbmm, ccmm;
secondeg_end (reducac, v0mm, aamm, bbmm, ccmm);
km = aamm * v * v + bbmm * v + ccmm; //verification good
@@ -5205,17 +5205,16 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g
kl = aab * v * v + bbb * v;
}
//rl gl bl
float RedL, GreenL, BlueL;
float krl = rl / (rl + gl + bl);
float kgl = gl / (rl + gl + bl);
float kbl = bl / (rl + gl + bl);
if(SatLow > 0.f) {
float kmgb;
//rl gl bl
float krl = rl / (rl + gl + bl);
float kgl = gl / (rl + gl + bl);
float kbl = bl / (rl + gl + bl);
float RedL, GreenL, BlueL;
if(g < 20000.f || b < 20000.f || r < 20000.f) {
kmgb = min(r, g, b); //I have tested ...0.85 compromise...
float kmgb = min(r, g, b); //I have tested ...0.85 compromise...
kl *= pow((kmgb / 20000.f), 0.85f);
}
@@ -5262,10 +5261,9 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g
kh = aa0 * v * v + bb0 * v;
}
float kmgb;
if(g > 45535.f || b > 45535.f || r > 45535.f) {
kmgb = max(r, g, b);
float kmgb = max(r, g, b);
float cora = 1.f / (45535.f - 65535.f);
float corb = 1.f - cora * 45535.f;
float cor = kmgb * cora + corb;
@@ -5277,12 +5275,12 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g
kh*=cor;*/
}
float RedH, GreenH, BlueH;
float krh = rh / (rh + gh + bh);
float kgh = gh / (rh + gh + bh);
float kbh = bh / (rh + gh + bh);
if(SatHigh > 0.f) {
float RedH, GreenH, BlueH;
float krh = rh / (rh + gh + bh);
float kgh = gh / (rh + gh + bh);
float kbh = bh / (rh + gh + bh);
RedH = 1.f + (SatHigh * krh) * kh * rlh * balanH; //1.2
if(krh > 0.f) {
@@ -5610,14 +5608,14 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu
const float amountchroma = (float) settings->amchroma;
TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params->icm.working);
double wip[3][3] = {
const double wip[3][3] = {
{wiprof[0][0], wiprof[0][1], wiprof[0][2]},
{wiprof[1][0], wiprof[1][1], wiprof[1][2]},
{wiprof[2][0], wiprof[2][1], wiprof[2][2]}
};
TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix (params->icm.working);
double wp[3][3] = {
const double wp[3][3] = {
{wprof[0][0], wprof[0][1], wprof[0][2]},
{wprof[1][0], wprof[1][1], wprof[1][2]},
{wprof[2][0], wprof[2][1], wprof[2][2]}
@@ -5774,7 +5772,6 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu
float l_r;//Luminance Lab in 0..1
l_r = Lprov1 / 100.f;
{
float khue = 1.9f; //in reserve in case of!
float valparam = float((lhCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f)); //get l_r=f(H)
float valparamneg;
valparamneg = valparam;
@@ -5788,6 +5785,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu
} else
//for negative
{
float khue = 1.9f; //in reserve in case of!
l_r *= (1.f + khue * valparamneg);
}
}
@@ -5894,7 +5892,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu
}
if (clut) { // begin C=f(L)
float factorskin, factorsat, factor, factorskinext, interm;
float factorskin, factorsat, factor, factorskinext;
float chromaCfactor = (clcurve[LL * 655.35f]) / (LL * 655.35f); //apply C=f(L)
float curf = 0.7f; //empirical coeff because curve is more progressive
float scale = 100.0f / 100.1f; //reduction in normal zone for curve C
@@ -5928,7 +5926,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu
}
if(chromaCfactor > 1.0) {
interm = (chromaCfactor - 1.0f) * 100.0f;
float interm = (chromaCfactor - 1.0f) * 100.0f;
factorskin = 1.0f + (interm * scale) / 100.0f;
factorskinext = 1.0f + (interm * scaleext) / 100.0f;
} else {
@@ -5954,7 +5952,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu
}//Lab C=f(C) pipette
if (ccut) {
float factorskin, factorsat, factor, factorskinext, interm;
float factorskin, factorsat, factor, factorskinext;
float chroma = sqrt(SQR(atmp) + SQR(btmp) + 0.001f);
float chromaCfactor = (satcurve[chroma * adjustr]) / (chroma * adjustr); //apply C=f(C)
float curf = 0.7f; //empirical coeff because curve is more progressive
@@ -5989,7 +5987,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu
}
if(chromaCfactor > 1.0) {
interm = (chromaCfactor - 1.0f) * 100.0f;
float interm = (chromaCfactor - 1.0f) * 100.0f;
factorskin = 1.0f + (interm * scale) / 100.0f;
factorskinext = 1.0f + (interm * scaleext) / 100.0f;
} else {
@@ -6649,15 +6647,15 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double
return;
}
lodev = (lodev / (log(2.f) * losum));
hidev = (hidev / (log(2.f) * hisum));
// lodev = (lodev / (log(2.f) * losum));
// hidev = (hidev / (log(2.f) * hisum));
if (octile[6] > log((float)imax + 1.f) / log2(2.f)) { //if very overxposed image
if (octile[6] > log1p((float)imax) / log2(2.f)) { //if very overxposed image
octile[6] = 1.5f * octile[5] - 0.5f * octile[4];
overex = 2;
}
if (octile[7] > log((float)imax + 1.f) / log2(2.f)) { //if overexposed
if (octile[7] > log1p((float)imax) / log2(2.f)) { //if overexposed
octile[7] = 1.5f * octile[6] - 0.5f * octile[5];
overex = 1;
}
@@ -6730,10 +6728,10 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double
median <<= histcompr;
shc <<= histcompr;
//prevent division by 0
if (lodev == 0.f) {
lodev = 1.f;
}
// //prevent division by 0
// if (lodev == 0.f) {
// lodev = 1.f;
// }
//compute exposure compensation as geometric mean of the amount that
//sets the mean or median at middle gray, and the amount that sets the estimated top
@@ -6929,7 +6927,7 @@ double ImProcFunctions::getAutoDistor (const Glib::ustring &fname, int thumb_si
int dist_result = calcDistortion (thumbGray, rawGray, width, h_thumb, 1, dist_amount);
if(dist_result == -1) { // not enough features found, try increasing max. number of features by factor 4
dist_result = calcDistortion (thumbGray, rawGray, width, h_thumb, 4, dist_amount);
calcDistortion (thumbGray, rawGray, width, h_thumb, 4, dist_amount);
}
delete thumbGray;