diff --git a/rtengine/imagedata.cc b/rtengine/imagedata.cc index a631a6c8d..5a76e4531 100644 --- a/rtengine/imagedata.cc +++ b/rtengine/imagedata.cc @@ -536,7 +536,7 @@ FrameData::FrameData(rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* if (mnote->getTag ("FocalLengthIn35mmFilm")) { focal_len35mm = mnote->getTag ("FocalLengthIn35mmFilm")->toDouble (); } - } else if (mnote && (!make.compare (0, 4, "SONY") || !make.compare (0, 6, "KONICA"))) { + } else if (!make.compare (0, 4, "SONY") || !make.compare (0, 6, "KONICA")) { if (mnote->getTag ("LensID")) { lens = mnote->getTag ("LensID")->valueToString (); if (lens == "Unknown") { @@ -554,7 +554,7 @@ FrameData::FrameData(rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* if (lens == "Unknown") { lens_from_make_and_model(); } - } else if (mnote && !make.compare (0, 9, "Panasonic")) { + } else if (!make.compare (0, 9, "Panasonic")) { if (mnote->getTag ("LensType")) { std::string panalens = mnote->getTag("LensType")->valueToString(); diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 6b50f3d3d..c4f191475 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -153,12 +153,12 @@ ImProcCoordinator::ImProcCoordinator() : pdSharpenAutoRadiusListener(nullptr), frameCountListener(nullptr), imageTypeListener(nullptr), + filmNegListener(nullptr), actListener(nullptr), adnListener(nullptr), awavListener(nullptr), dehaListener(nullptr), hListener(nullptr), - filmNegListener(nullptr), resultValid(false), params(new procparams::ProcParams), lastOutputProfile("BADFOOD"), diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index b7d7c41e5..d942afb07 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -187,9 +187,9 @@ public: void dirpyrequalizer(LabImage* lab, int scale); //Emil's wavelet - void EPDToneMapResid(float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params& cp, int W_L, int H_L, float max0, float min0); + void EPDToneMapResid(float * WavCoeffs_L0, unsigned int Iterates, int skip, const struct cont_params& cp, int W_L, int H_L, float max0); void CompressDR(float *Source, int W_L, int H_L, float Compression, float DetailBoost); - void ContrastResid(float * WavCoeffs_L0, struct cont_params &cp, int W_L, int H_L, float max0, float min0); + void ContrastResid(float * WavCoeffs_L0, const struct cont_params &cp, int W_L, int H_L, float max0); void EPDToneMap(LabImage *lab, unsigned int Iterates = 0, int skip = 1); void EPDToneMapCIE(CieImage *ncie, float a_w, float c_, int Wid, int Hei, float minQ, float maxQ, unsigned int Iterates = 0, int skip = 1); @@ -211,7 +211,7 @@ public: struct cont_params &cp, const bool useChannelA, int skip, float *meanab, float *sigmaab); void WaveletAandBAllAB(const wavelet_decomposition &WaveletCoeffs_a, const wavelet_decomposition &WaveletCoeffs_b, const cont_params &cp, FlatCurve* hhcurve, bool hhutili); - void ContAllL(float **koeLi, float *maxkoeLi, bool lipschitz, int maxlvl, LabImage * lab, float **varhue, float **varchrom, float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp, + void ContAllL(float **koeLi, float maxkoeLi, bool lipschitz, int maxlvl, LabImage * lab, float **varhue, float **varchrom, float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp, int W_L, int H_L, int skip, float *mean, float *sigma, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveSH & waOpacityCurveSH, FlatCurve* ChCurve, bool Chutili); void finalContAllL(float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, const cont_params &cp, int W_L, int H_L, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL); @@ -226,7 +226,7 @@ public: void Aver(float * HH_Coeffs, int datalen, float &averagePlus, float &averageNeg, float &max, float &min); void Sigma(float * HH_Coeffs, int datalen, float averagePlus, float averageNeg, float &sigmaPlus, float &sigmaNeg); - void calckoe(float ** WavCoeffs_LL, const cont_params& cp, float ** koeLi, int level, int dir, int W_L, int H_L, float edd, float *maxkoeLi, float **tmC = nullptr); + void calckoe(float ** WavCoeffs_LL, const cont_params& cp, float ** koeLi, int level, int dir, int W_L, int H_L, float edd, float& maxkoeLi, float **tmC = nullptr); void Median_Denoise(float **src, float **dst, int width, int height, Median medianType, int iterations, int numThreads, float **buffer = nullptr); void Median_Denoise(float **src, float **dst, float upperBound, int width, int height, Median medianType, int iterations, int numThreads, float **buffer = nullptr); diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index 47bd0f08a..f17c8f8b9 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -110,7 +110,6 @@ struct cont_params { bool lip3; bool tonemap; bool diag; - int TMmeth; float tmstrength; float balan; float sigmafin; @@ -1344,12 +1343,6 @@ void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const } else {// a and b int levwavab = levwav; - if (!exblurab && cp.chrores == 0.f && cp.blurcres == 0.f && !hhutili && params->wavelet.CLmethod == "all") { // no processing of residual ab => we probably can reduce the number of levels - while (levwavab > 0 && (((cp.CHmet == 2 && (cp.chro == 0.f || cp.mul[levwavab - 1] == 0.f)) || (cp.CHmet != 2 && (levwavab == 10 || (!cp.curv || cp.mulC[levwavab - 1] == 0.f))))) && (!cp.opaRG || levwavab == 10 || (cp.opaRG && cp.mulopaRG[levwavab - 1] == 0.f)) && ((levwavab == 10 || (cp.CHSLmet == 1 && cp.mulC[levwavab - 1] == 0.f)))) { - levwavab--; - } - } - if (cp.chromfi > 0.f || cp.chromco > 0.f) { if (levwavab < 7) { levwavab = 7; @@ -1916,102 +1909,72 @@ void ImProcFunctions::CompressDR(float *Source, int W_L, int H_L, float Compress } -void ImProcFunctions::ContrastResid(float * WavCoeffs_L0, struct cont_params &cp, int W_L, int H_L, float max0, float min0) +void ImProcFunctions::ContrastResid(float * WavCoeffs_L0, const cont_params &cp, int W_L, int H_L, float max0) { - float stren = cp.tmstrength; - float gamm = params->wavelet.gamma; - cp.TMmeth = 2; //default after testing - - if (cp.TMmeth == 1) { - min0 = 0.0f; - max0 = 32768.f; - } else if (cp.TMmeth == 2) { - min0 = 0.0f; - } + const float stren = cp.tmstrength; + const float gamm = params->wavelet.gamma; #ifdef _OPENMP #pragma omp parallel for #endif for (int i = 0; i < W_L * H_L; i++) { - WavCoeffs_L0[i] = (WavCoeffs_L0[i] - min0) / max0; - WavCoeffs_L0[i] *= gamm; - } - - float Compression = expf(-stren); //This modification turns numbers symmetric around 0 into exponents. - float DetailBoost = stren; - - if (stren < 0.0f) { - DetailBoost = 0.0f; //Go with effect of exponent only if uncompressing. + WavCoeffs_L0[i] *= (gamm / max0); } + const float Compression = std::exp(-stren); //This modification turns numbers symmetric around 0 into exponents. + const float DetailBoost = std::max(stren, 0.f); //Go with effect of exponent only if uncompressing. CompressDR(WavCoeffs_L0, W_L, H_L, Compression, DetailBoost); - + max0 /= gamm; #ifdef _OPENMP #pragma omp parallel for // removed schedule(dynamic,10) #endif for (int ii = 0; ii < W_L * H_L; ii++) { - WavCoeffs_L0[ii] = WavCoeffs_L0[ii] * max0 * (1.f / gamm) + min0; + WavCoeffs_L0[ii] *= max0; } } - - - -void ImProcFunctions::EPDToneMapResid(float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params& cp, int W_L, int H_L, float max0, float min0) +void ImProcFunctions::EPDToneMapResid(float * WavCoeffs_L0, unsigned int Iterates, int skip, const cont_params& cp, int W_L, int H_L, float max0) { - float stren = cp.tmstrength; - float edgest = params->wavelet.edgs; - float sca = params->wavelet.scale; - float gamm = params->wavelet.gamma; - int rew = 0; //params->epd.reweightingIterates; + const float stren = cp.tmstrength; + const float edgest = params->wavelet.edgs; + const float sca = params->wavelet.scale; + const float gamm = params->wavelet.gamma; + constexpr int rew = 0; //params->epd.reweightingIterates; + EdgePreservingDecomposition epd2(W_L, H_L); - cp.TMmeth = 2; //default after testing - if (cp.TMmeth == 1) { - min0 = 0.0f; - max0 = 32768.f; - } else if (cp.TMmeth == 2) { - min0 = 0.0f; - } - - // max0=32768.f; #ifdef _OPENMP #pragma omp parallel for #endif for (int i = 0; i < W_L * H_L; i++) { - WavCoeffs_L0[i] = (WavCoeffs_L0[i] - min0) / max0; - WavCoeffs_L0[i] *= gamm; + WavCoeffs_L0[i] *= (gamm / max0); } - float Compression = expf(-stren); //This modification turns numbers symmetric around 0 into exponents. - float DetailBoost = stren; - - if (stren < 0.0f) { - DetailBoost = 0.0f; //Go with effect of exponent only if uncompressing. - } + const float Compression = std::exp(-stren); //This modification turns numbers symmetric around 0 into exponents. + const float DetailBoost = std::max(stren, 0.f); //Go with effect of exponent only if uncompressing. //Auto select number of iterates. Note that p->EdgeStopping = 0 makes a Gaussian blur. if (Iterates == 0) { Iterates = (unsigned int)(edgest * 15.0f); } + epd2.CompressDynamicRange(WavCoeffs_L0, sca / skip, edgest, Compression, DetailBoost, Iterates, rew); - epd2.CompressDynamicRange(WavCoeffs_L0, (float)sca / skip, edgest, Compression, DetailBoost, Iterates, rew); - + max0 /= gamm; //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. #ifdef _OPENMP #pragma omp parallel for // removed schedule(dynamic,10) #endif for (int ii = 0; ii < W_L * H_L; ii++) { - WavCoeffs_L0[ii] = WavCoeffs_L0[ii] * max0 * (1.f / gamm) + min0; + WavCoeffs_L0[ii] *= max0; } } @@ -2039,96 +2002,35 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * const int H_L = WaveletCoeffs_L.level_H(0); float * WavCoeffs_L0 = WaveletCoeffs_L.coeff0; - float contrast = cp.contrast; + const float contrast = cp.contrast; double avedbl = 0.0; // use double precision for large summations float max0 = 0.f; - float min0 = FLT_MAX; - if (contrast != 0.f || (cp.tonemap && cp.resena)) { // contrast = 0.f means that all will be multiplied by 1.f, so we can skip this step + if (contrast != 0.f || (cp.tonemap && cp.resena)) { // contrast = 0.f means that all will be multiplied by 1.f, so we can skip this step #ifdef _OPENMP - #pragma omp parallel for reduction(+:avedbl) num_threads(wavNestedLevels) if (wavNestedLevels>1) + #pragma omp parallel for reduction(+:avedbl) reduction(max:max0) num_threads(wavNestedLevels) if (wavNestedLevels>1) #endif for (int i = 0; i < W_L * H_L; i++) { avedbl += static_cast(WavCoeffs_L0[i]); + max0 = std::max(WavCoeffs_L0[i], max0); } - -#ifdef _OPENMP - #pragma omp parallel num_threads(wavNestedLevels) if (wavNestedLevels>1) -#endif - { - float lminL = FLT_MAX; - float lmaxL = 0.f; - -#ifdef _OPENMP - #pragma omp for -#endif - - for (int i = 0; i < W_L * H_L; i++) { - if (WavCoeffs_L0[i] < lminL) { - lminL = WavCoeffs_L0[i]; - } - - if (WavCoeffs_L0[i] > lmaxL) { - lmaxL = WavCoeffs_L0[i]; - } - - } - -#ifdef _OPENMP - #pragma omp critical -#endif - { - if (lminL < min0) { - min0 = lminL; - } - - if (lmaxL > max0) { - max0 = lmaxL; - } - } - - } - } - //tone mapping - if (cp.tonemap && cp.contmet == 2 && cp.resena) { + if (cp.tonemap && cp.contmet == 2 && cp.resena) { //iterate = 5 - EPDToneMapResid(WavCoeffs_L0, 0, skip, cp, W_L, H_L, max0, min0); - + EPDToneMapResid(WavCoeffs_L0, 0, skip, cp, W_L, H_L, max0); } //end tonemapping max0 /= 327.68f; - min0 /= 327.68f; - float ave = avedbl / (double)(W_L * H_L); - float avg = ave / 32768.f; - float *koeLi[12]; - float maxkoeLi[12]; + const float ave = avedbl / (W_L * H_L); + const float avg = LIM01(ave / 32768.f); - float *koeLibuffer = nullptr; - - for (int y = 0; y < 12; y++) { - maxkoeLi[y] = 0.f; //9 - } - - koeLibuffer = new float[12 * H_L * W_L]; //12 - - for (int i = 0; i < 12; i++) { //9 - koeLi[i] = &koeLibuffer[i * W_L * H_L]; - } - - for (int j = 0; j < 12; j++) //9 - for (int i = 0; i < W_L * H_L; i++) { - koeLi[j][i] = 0.f; - } - - avg = LIM01(avg); - double contreal = 0.6 * contrast; + const double contreal = 0.6 * contrast; DiagonalCurve resid_contrast({ DCT_NURBS, 0, 0, @@ -2137,43 +2039,29 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * 1, 1 }); + if (contrast != 0.f && cp.resena && max0 > 0.f) { // contrast = 0.f means that all will be multiplied by 1.f, so we can skip this step #ifdef _OPENMP - #pragma omp parallel num_threads(wavNestedLevels) if (wavNestedLevels>1) -#endif - { - if (contrast != 0.f && cp.resena && max0 > 0.f) { // contrast = 0.f means that all will be multiplied by 1.f, so we can skip this step - { - -#ifdef _OPENMP - #pragma omp for + #pragma omp parallel for num_threads(wavNestedLevels) if (wavNestedLevels>1) #endif - for (int i = 0; i < W_L * H_L; i++) { - float buf = LIM01(WavCoeffs_L0[i] / 32768.f); - buf = resid_contrast.getVal(buf); - buf *= 32768.f; - WavCoeffs_L0[i] = buf; - } - } - } - - - if (cp.tonemap && cp.contmet == 1 && cp.resena) { - float maxp = max0 * 256.f; - float minp = min0 * 256.f; -#ifdef _OPENMP - #pragma omp single -#endif - ContrastResid(WavCoeffs_L0, cp, W_L, H_L, maxp, minp); + for (int i = 0; i < W_L * H_L; i++) { + float buf = LIM01(WavCoeffs_L0[i] / 32768.f); + buf = resid_contrast.getVal(buf); + buf *= 32768.f; + WavCoeffs_L0[i] = buf; } } - if ((cp.conres >= 0.f || cp.conresH >= 0.f) && cp.resena && !cp.oldsh) { // cp.conres = 0.f and cp.comresH = 0.f means that all will be multiplied by 1.f, so we can skip this step - LabImage *temp = nullptr; - temp = new LabImage(W_L, H_L); + if (cp.tonemap && cp.contmet == 1 && cp.resena) { + const float maxp = max0 * 256.f; + ContrastResid(WavCoeffs_L0, cp, W_L, H_L, maxp); + } + + if ((cp.conres >= 0.f || cp.conresH >= 0.f) && cp.resena && !cp.oldsh) { // cp.conres = 0.f and cp.comresH = 0.f means that all will be multiplied by 1.f, so we can skip this step + std::unique_ptr temp(new LabImage(W_L, H_L)); #ifdef _OPENMP - #pragma omp for + #pragma omp parallel for num_threads(wavNestedLevels) if (wavNestedLevels>1) #endif for (int i = 0; i < H_L; i++) { @@ -2182,12 +2070,10 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * } } - { - ImProcFunctions::shadowsHighlights(temp, true, 1, cp.conresH, cp.conres, cp.radius, skip, cp.thH, cp.th); - } + ImProcFunctions::shadowsHighlights(temp.get(), true, 1, cp.conresH, cp.conres, cp.radius, skip, cp.thH, cp.th); #ifdef _OPENMP - #pragma omp for + #pragma omp parallel for num_threads(wavNestedLevels) if (wavNestedLevels>1) #endif for (int i = 0; i < H_L; i++) { @@ -2195,18 +2081,11 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * WavCoeffs_L0[i * W_L + j] = temp->L[i][j]; } } - - delete temp; - } -#ifdef _OPENMP - #pragma omp barrier -#endif - if ((cp.conres != 0.f || cp.conresH != 0.f) && cp.resena && cp.oldsh) { // cp.conres = 0.f and cp.comresH = 0.f means that all will be multiplied by 1.f, so we can skip this step #ifdef _OPENMP - #pragma omp for nowait + #pragma omp parallel for #endif for (int i = 0; i < W_L * H_L; i++) { @@ -2277,6 +2156,20 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * int n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n32; n0 = n1 = n2 = n3 = n4 = n5 = n6 = n7 = n8 = n9 = n10 = n32 = 0; + float *koeLi[12]; + + std::unique_ptr koeLibuffer(new float[12 * H_L * W_L]); + + for (int i = 0; i < 12; i++) { + koeLi[i] = &koeLibuffer[i * W_L * H_L]; + } + + for (int j = 0; j < 12; j++) { + for (int i = 0; i < W_L * H_L; i++) { + koeLi[j][i] = 0.f; + } + } + #ifdef _OPENMP #pragma omp parallel num_threads(wavNestedLevels) if (wavNestedLevels>1) #endif @@ -2291,10 +2184,10 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * constexpr float eddlow = 15.f; float eddlipinfl = 0.005f * cp.edgsens + 0.4f; float eddlipampl = 1.f + cp.edgampl / 50.f; - + float maxkoeLi = 0.f; if (cp.detectedge) { //enabled Lipschitz control...more memory..more time... - float *tmCBuffer = new float[H_L * W_L]; + std::unique_ptr tmCBuffer(new float[H_L * W_L]); float *tmC[H_L]; for (int i = 0; i < H_L; i++) { @@ -2313,8 +2206,6 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * } } - delete [] tmCBuffer; - float aamp = 1.f + cp.eddetthrHi / 100.f; for (int lvl = 0; lvl < 4; lvl++) { @@ -2432,7 +2323,6 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs(lvl); -// ContAllL(koeLi, maxkoeLi, true, maxlvl, labco, varhue, varchrom, WavCoeffs_L, WavCoeffs_L0, lvl, dir, cp, Wlvl_L, Hlvl_L, skip, mean, sigma, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, ChCurve, Chutili); ContAllL(koeLi, maxkoeLi, true, maxlvl, labco, varhue, varchrom, WavCoeffs_L, WavCoeffs_L0, lvl, dir, cp, Wlvl_L, Hlvl_L, skip, mean, sigma, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, waOpacityCurveSH, ChCurve, Chutili); int minWL = min(Wlvl_L, Hlvl_L); @@ -2518,11 +2408,6 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * } } } - - //delete edge detection - if (koeLibuffer) { - delete [] koeLibuffer; - } } void ImProcFunctions::WaveletAandBAllAB(const wavelet_decomposition &WaveletCoeffs_a, const wavelet_decomposition &WaveletCoeffs_b, @@ -2828,7 +2713,7 @@ void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void ImProcFunctions::calckoe(float ** WavCoeffs_LL, const cont_params& cp, float *koeLi[12], int level, int dir, int W_L, int H_L, float edd, float *maxkoeLi, float **tmC) +void ImProcFunctions::calckoe(float ** WavCoeffs_LL, const cont_params& cp, float *koeLi[12], int level, int dir, int W_L, int H_L, float edd, float& maxkoeLi, float **tmC) { int borderL = 2; @@ -2954,13 +2839,13 @@ void ImProcFunctions::calckoe(float ** WavCoeffs_LL, const cont_params& cp, floa koeLi[level * 3 + dir - 1][i * W_L + j] = rtengine::min(thr2, std::fabs(tmC[i][j] / temp)); // limit maxi //it will be more complicated to calculate both Wh and Wv, but we have also Wd==> pseudo Lipschitz - if (koeLi[level * 3 + dir - 1][i * W_L + j] > maxkoeLi[level * 3 + dir - 1]) { - maxkoeLi[level * 3 + dir - 1] = koeLi[level * 3 + dir - 1][i * W_L + j]; + if (koeLi[level * 3 + dir - 1][i * W_L + j] > maxkoeLi) { + maxkoeLi = koeLi[level * 3 + dir - 1][i * W_L + j]; } - float diff = maxkoeLi[level * 3 + dir - 1] - koeLi[level * 3 + dir - 1][i * W_L + j]; + float diff = maxkoeLi - koeLi[level * 3 + dir - 1][i * W_L + j]; diff *= diffFactor; - koeLi[level * 3 + dir - 1][i * W_L + j] = maxkoeLi[level * 3 + dir - 1] - diff; + koeLi[level * 3 + dir - 1][i * W_L + j] = maxkoeLi - diff; } } @@ -3120,7 +3005,7 @@ void ImProcFunctions::finalContAllL(float ** WavCoeffs_L, float * WavCoeffs_L0, } -void ImProcFunctions::ContAllL(float *koeLi[12], float *maxkoeLi, bool lipschitz, int maxlvl, LabImage * labco, float ** varhue, float **varchrom, float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp, +void ImProcFunctions::ContAllL(float *koeLi[12], float maxkoeLi, bool lipschitz, int maxlvl, LabImage * labco, float ** varhue, float **varchrom, float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp, int W_L, int H_L, int skip, float *mean, float *sigma, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveSH & waOpacityCurveSH, FlatCurve* ChCurve, bool Chutili) { assert(level >= 0); @@ -3376,7 +3261,7 @@ void ImProcFunctions::ContAllL(float *koeLi[12], float *maxkoeLi, bool lipschitz if (lipschitz) { if (level < 4) { - edge = 1.f + (edgePrecalc - 1.f) * (koeLi[level * 3][k]) / (1.f + 0.9f * maxkoeLi[level * 3 + dir - 1]); + edge = 1.f + (edgePrecalc - 1.f) * (koeLi[level * 3][k]) / (1.f + 0.9f * maxkoeLi); } else { edge = edgePrecalc; } @@ -3482,7 +3367,7 @@ void ImProcFunctions::ContAllL(float *koeLi[12], float *maxkoeLi, bool lipschitz if (lipschitz) { if (level < 4) { - edge = 1.f + (edgePrecalc - 1.f) * (koeLi[level * 3][k]) / (1.f + 0.9f * maxkoeLi[level * 3 + dir - 1]); + edge = 1.f + (edgePrecalc - 1.f) * (koeLi[level * 3][k]) / (1.f + 0.9f * maxkoeLi); } else { edge = edgePrecalc; } diff --git a/rtengine/rawimage.cc b/rtengine/rawimage.cc index c2df70468..859486010 100644 --- a/rtengine/rawimage.cc +++ b/rtengine/rawimage.cc @@ -497,11 +497,10 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro // dcraw needs this global variable to hold pixel data image = (dcrawImage_t)calloc (static_cast(height) * static_cast(width) * sizeof * image + meta_length, 1); - meta_data = (char *) (image + static_cast(height) * static_cast(width)); - if(!image) { return 200; } + meta_data = (char *) (image + static_cast(height) * static_cast(width)); /* Issue 2467 if (setjmp (failure)) { diff --git a/rtexif/rtexif.cc b/rtexif/rtexif.cc index 95b46c2b9..b4a4650c9 100644 --- a/rtexif/rtexif.cc +++ b/rtexif/rtexif.cc @@ -3059,18 +3059,16 @@ void ExifManager::parse (bool isRaw, bool skipIgnored, bool parseJpeg) bool frameRootDetected = false; - if(!frameRootDetected) { - std::vector risTagList = root->findTags("RawImageSegmentation"); - if (!risTagList.empty()) { - for (auto ris : risTagList) { - frames.push_back(ris->getParent()); - frameRootDetected = true; + std::vector risTagList = root->findTags("RawImageSegmentation"); + if (!risTagList.empty()) { + for (auto ris : risTagList) { + frames.push_back(ris->getParent()); + frameRootDetected = true; - #if PRINT_METADATA_TREE - printf("\n--------------- FRAME (RAWIMAGESEGMENTATION) ---------------\n\n"); - ris->getParent()->printAll (); - #endif - } +#if PRINT_METADATA_TREE + printf("\n--------------- FRAME (RAWIMAGESEGMENTATION) ---------------\n\n"); + ris->getParent()->printAll (); +#endif } } diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index 102c17daf..42a2263e2 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -2446,6 +2446,8 @@ bool FileCatalog::handleShortcutKey (GdkEventKey* event) case GDK_KEY_underscore: zoomOut(); return true; + default: // do nothing, avoids a cppcheck false positive + break; } } diff --git a/rtgui/main.cc b/rtgui/main.cc index 63669f49c..b6edb3c63 100644 --- a/rtgui/main.cc +++ b/rtgui/main.cc @@ -440,7 +440,7 @@ int main (int argc, char **argv) if (argc > 1) { if (!remote && !Glib::file_test (argv1, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (argv1, Glib::FILE_TEST_IS_DIR)) { - bool stdoutRedirecttoConsole = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0000); + const bool stdoutRedirecttoConsole = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0000); // open console, if stdout is invalid if (stdoutRedirecttoConsole) { // check if parameter -w was passed. @@ -472,10 +472,9 @@ int main (int argc, char **argv) cursorInfo.bVisible = false; SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE ), &cursorInfo ); - if (stdoutRedirecttoConsole) { // if stdout is Redirect to console, we also redirect stderr to console - freopen ( "CON", "w", stdout ) ; - freopen ( "CON", "w", stderr ) ; - } + // we also redirect stderr to console + freopen ( "CON", "w", stdout ) ; + freopen ( "CON", "w", stderr ) ; freopen ( "CON", "r", stdin ) ; diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index 7452c9d72..059a1ed94 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -873,7 +873,7 @@ void Thumbnail::_loadThumbnail(bool firstTrial) if (!succ && firstTrial) { _generateThumbnailImage (); - if (cfs.supported && firstTrial) { + if (cfs.supported) { _loadThumbnail (false); }