From f727477710e1f67fe42ec827d5c4baca9e08921f Mon Sep 17 00:00:00 2001 From: Ingo Weyrich Date: Wed, 24 Feb 2021 22:39:23 +0100 Subject: [PATCH] Make some more files cppcheck clean (#6133) * Make some more files cppcheck clean * revert change of dcrop.cc from last commit * Replace calculation: y = pow(x, 1/ (2.f * 2.f)) by y = sqrt(sqrt(x)) * Revert "Replace calculation: y = pow(x, 1/ (2.f * 2.f)) by y = sqrt(sqrt(x))" This reverts commit d639c67249f1723fa9f9e55e0442afcb862eba91. --- rtengine/cache.h | 2 +- rtengine/dcrop.cc | 17 ----------------- rtengine/impulse_denoise.cc | 6 +++--- rtengine/iplab2rgb.cc | 3 ++- rtengine/ipsharpen.cc | 4 ++-- rtengine/ipwavelet.cc | 26 ++++++++++---------------- 6 files changed, 18 insertions(+), 40 deletions(-) diff --git a/rtengine/cache.h b/rtengine/cache.h index 6c1dacf43..77a2017f3 100644 --- a/rtengine/cache.h +++ b/rtengine/cache.h @@ -65,7 +65,7 @@ public: virtual void onDestroy() = 0; }; - Cache(unsigned long _size, Hook* _hook = nullptr) : + explicit Cache(unsigned long _size, Hook* _hook = nullptr) : store_size(_size), hook(_hook) { diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 832bff104..422158da6 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -1132,7 +1132,6 @@ void Crop::update(int todo) /* if (params.icm.workingTRC == "Custom") { //exec TRC IN free const Glib::ustring profile = params.icm.workingProfile; - if (profile == "sRGB" || profile == "Adobe RGB" || profile == "ProPhoto" || profile == "WideGamut" || profile == "BruceRGB" || profile == "Beta RGB" || profile == "BestRGB" || profile == "Rec2020" || profile == "ACESp0" || profile == "ACESp1") { const int cw = baseCrop->getWidth(); const int ch = baseCrop->getHeight(); @@ -1159,22 +1158,6 @@ void Crop::update(int todo) } } - /*xref=000;yref=000; - if (colortest && cropw>115 && croph>115) - for(int j=1;j<5;j++){ - xref+=j*30;yref+=j*30; - if (settings->verbose) { - printf("after rgbProc RGB Xr%i Yr%i Skip=%d R=%f G=%f B=%f \n",xref,yref,skip, - baseCrop->r[(int)(xref/skip)][(int)(yref/skip)]/256, - baseCrop->g[(int)(xref/skip)][(int)(yref/skip)]/256, - baseCrop->b[(int)(xref/skip)][(int)(yref/skip)]/256); - printf("after rgbProc Lab Xr%i Yr%i Skip=%d l=%f a=%f b=%f \n",xref,yref,skip, - laboCrop->L[(int)(xref/skip)][(int)(yref/skip)]/327, - laboCrop->a[(int)(xref/skip)][(int)(yref/skip)]/327, - laboCrop->b[(int)(xref/skip)][(int)(yref/skip)]/327); - } - }*/ - // apply luminance operations if (todo & (M_LUMINANCE + M_COLOR)) { // //I made a little change here. Rather than have luminanceCurve (and others) use in/out lab images, we can do more if we copy right here. diff --git a/rtengine/impulse_denoise.cc b/rtengine/impulse_denoise.cc index 20229e714..8e1143c09 100644 --- a/rtengine/impulse_denoise.cc +++ b/rtengine/impulse_denoise.cc @@ -322,7 +322,7 @@ void ImProcFunctions::impulse_nrcam (CieImage* ncie, double thresh, float **buff hfnbrave += fabs(ncie->sh_p[i1][j1] - lpf[i1][j1]); } - impish[i][j] = (hpfabs > ((hfnbrave - hpfabs) * impthrDiv24)); + impish[i][j] = static_cast(hpfabs > ((hfnbrave - hpfabs) * impthrDiv24)); } #ifdef __SSE2__ @@ -353,7 +353,7 @@ void ImProcFunctions::impulse_nrcam (CieImage* ncie, double thresh, float **buff hfnbrave += fabs(ncie->sh_p[i1][j1] - lpf[i1][j1]); } - impish[i][j] = (hpfabs > ((hfnbrave - hpfabs) * impthrDiv24)); + impish[i][j] = static_cast(hpfabs > ((hfnbrave - hpfabs) * impthrDiv24)); } for (; j < width; j++) { @@ -365,7 +365,7 @@ void ImProcFunctions::impulse_nrcam (CieImage* ncie, double thresh, float **buff hfnbrave += fabs(ncie->sh_p[i1][j1] - lpf[i1][j1]); } - impish[i][j] = (hpfabs > ((hfnbrave - hpfabs) * impthrDiv24)); + impish[i][j] = static_cast(hpfabs > ((hfnbrave - hpfabs) * impthrDiv24)); } } } diff --git a/rtengine/iplab2rgb.cc b/rtengine/iplab2rgb.cc index dd89301ae..81a304fd3 100644 --- a/rtengine/iplab2rgb.cc +++ b/rtengine/iplab2rgb.cc @@ -96,7 +96,8 @@ inline void copyAndClamp(const LabImage *src, unsigned char *dst, const double r gbuffer[j] = Color::gamma2curve[G]; bbuffer[j] = Color::gamma2curve[B]; } - for (int j = 0; j < W; ++j) { + + for (j = 0; j < W; ++j) { dst[ix++] = uint16ToUint8Rounded(rbuffer[j]); dst[ix++] = uint16ToUint8Rounded(gbuffer[j]); dst[ix++] = uint16ToUint8Rounded(bbuffer[j]); diff --git a/rtengine/ipsharpen.cc b/rtengine/ipsharpen.cc index afe6f8aa3..96d42e336 100644 --- a/rtengine/ipsharpen.cc +++ b/rtengine/ipsharpen.cc @@ -543,8 +543,8 @@ BENCHFUN // calculate contrast based blend factors to reduce sharpening in regions with low contrast JaggedArray blend(W, H); - float contrast = params->sharpenMicro.contrast / 100.0; - buildBlendMask(luminance, blend, W, H, contrast); + float contrastThreshold = params->sharpenMicro.contrast / 100.0; + buildBlendMask(luminance, blend, W, H, contrastThreshold); #ifdef _OPENMP #pragma omp parallel diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index 7563ca75d..4b65dd5bc 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -1182,30 +1182,28 @@ void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const float* noisevarhue = new float[GHL * GWL]; int GW2L = (GWL + 1) / 2; - float nvlh[13] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.7f, 0.5f}; //high value - float nvll[13] = {0.1f, 0.15f, 0.2f, 0.25f, 0.3f, 0.35f, 0.4f, 0.45f, 0.7f, 0.8f, 1.f, 1.f, 1.f}; //low value + constexpr float nvlh[13] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.7f, 0.5f}; //high value + constexpr float nvll[13] = {0.1f, 0.15f, 0.2f, 0.25f, 0.3f, 0.35f, 0.4f, 0.45f, 0.7f, 0.8f, 1.f, 1.f, 1.f}; //low value - float seuillow = 3000.f;//low - float seuilhigh = 18000.f;//high - int i = 10 - cp.ballum; - float ac = (nvlh[i] - nvll[i]) / (seuillow - seuilhigh); - float bc = nvlh[i] - seuillow * ac; + constexpr float seuillow = 3000.f;//low + constexpr float seuilhigh = 18000.f;//high + const int index = 10 - cp.ballum; + const float ac = (nvlh[index] - nvll[index]) / (seuillow - seuilhigh); + const float bc = nvlh[index] - seuillow * ac; #ifdef _OPENMP #pragma omp parallel for - #endif - for (int ir = 0; ir < GHL; ir++) for (int jr = 0; jr < GWL; jr++) { float lN = labco->L[ir][jr]; if (lN < seuillow) { - noisevarlum[(ir >> 1)*GW2L + (jr >> 1)] = nvlh[i]; + noisevarlum[(ir >> 1)*GW2L + (jr >> 1)] = nvlh[index]; } else if (lN < seuilhigh) { noisevarlum[(ir >> 1)*GW2L + (jr >> 1)] = ac * lN + bc; } else { - noisevarlum[(ir >> 1)*GW2L + (jr >> 1)] = nvll[i]; + noisevarlum[(ir >> 1)*GW2L + (jr >> 1)] = nvll[index]; } } @@ -2265,11 +2263,7 @@ void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const absciss = asig * std::fabs(tempwav) + bsig; } else { absciss = amean * std::fabs(tempwav); - float k = sig; - if(sig > 1.f) { - k = SQR(sig); - } - float abs = pow(2.f * absciss, (1.f / k)); + float abs = pow(2.f * absciss, (1.f / SQR(sig))); absciss = 0.5f * abs; } float kc = wavguid.getVal(absciss) -1.f;