From f9f593d343f2b9626a356c76ea2b135e3254ab29 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 2 Oct 2016 15:09:26 +0200 Subject: [PATCH 01/13] Cppcheck: Fix issues related to rtengine/FTblockDN.cc --- rtengine/FTblockDN.cc | 18 +++++++----------- rtengine/dcrop.cc | 8 ++++---- rtengine/improcfun.h | 2 +- rtengine/simpleprocess.cc | 8 ++++---- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/rtengine/FTblockDN.cc b/rtengine/FTblockDN.cc index ba7ae693e..e0d22d639 100644 --- a/rtengine/FTblockDN.cc +++ b/rtengine/FTblockDN.cc @@ -108,7 +108,7 @@ void ImProcFunctions::Median_Denoise(float **src, float **dst, const int width, medBuffer[0] = src; // we need a buffer if src == dst or if (src != dst && iterations > 1) - if (src == dst || (src != dst && iterations > 1)) { + if (src == dst || iterations > 1) { if (buffer == nullptr) { // we didn't get a buufer => create one allocBuffer = new float*[height]; @@ -853,7 +853,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef const float noisevarab_b = SQR(realblue); //input L channel - array2D *Lin; + array2D *Lin = nullptr; //wavelet denoised image LabImage * labdn = new LabImage(width, height); @@ -1678,7 +1678,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef delete labdn; - if (denoiseLuminance) { + if (Lin) { delete Lin; } @@ -2250,7 +2250,6 @@ SSEFUNCTION bool ImProcFunctions::WaveletDenoiseAll_BiShrinkL(wavelet_decomposit float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs(lvl); if (lvl == maxlvl - 1) { - float vari[4]; int edge = 0; ShrinkAllL(WaveletCoeffs_L, buffer, lvl, dir, noisevarlum, madL[lvl], nullptr, edge); } else { @@ -2613,7 +2612,7 @@ SSEFUNCTION void ImProcFunctions::ShrinkAllL(wavelet_decomposition &WaveletCoeff // printf("OK lev=%d\n",level); float mad_L = madL[dir - 1] ; - if (edge == 1) { + if (edge == 1 && vari) { noisevarlum = blurBuffer; // we need one buffer, but fortunately we don't have to allocate a new one because we can use blurBuffer for (int i = 0; i < W_L * H_L; ++i) { @@ -3044,7 +3043,7 @@ void ImProcFunctions::calcautodn_info (float &chaut, float &delta, int Nb, int l delta *= 0.15f; } else if (chaut < 650.f) { delta *= 0.1f; - } else if (chaut >= 650.f) { + } else /*if (chaut >= 650.f)*/ { delta *= 0.07f; } @@ -3082,7 +3081,7 @@ void ImProcFunctions::calcautodn_info (float &chaut, float &delta, int Nb, int l delta *= 0.3f; } else if (chaut < 650.f) { delta *= 0.2f; - } else if (chaut >= 650.f) { + } else /*if (chaut >= 650.f)*/ { delta *= 0.15f; } @@ -3107,7 +3106,7 @@ void ImProcFunctions::calcautodn_info (float &chaut, float &delta, int Nb, int l } -SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat * provicalc, const bool isRAW, LUTf &gamcurve, float gam, float gamthresh, float gamslope, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, float &nresi, float &highresi, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, bool multiThread) +SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat * provicalc, const bool isRAW, LUTf &gamcurve, float gam, float gamthresh, float gamslope, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, bool multiThread) { if ((settings->leveldnautsimpl == 1 && dnparams.Cmethod == "MAN") || (settings->leveldnautsimpl == 0 && dnparams.C2method == "MANU")) { //nothing to do @@ -3546,9 +3545,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat } comptlevel += 1; - float chresid, chmaxredresid, chmaxblueresid; - nresi = chresid; - highresi = chresid + 0.66f * (max(chmaxredresid, chmaxblueresid) - chresid); //evaluate sigma delete adecomp; delete bdecomp; delete labdn; diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 1e5aba77c..b2c2f03f1 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -321,7 +321,7 @@ void Crop::update (int todo) float maxr = 0.f; float maxb = 0.f; - float chaut, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc; + float chaut, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc; int Nb; chaut = 0.f; @@ -334,7 +334,7 @@ void Crop::update (int todo) LUTf gamcurve(65536, 0); float gam, gamthresh, gamslope; parent->ipf.RGB_denoise_infoGamCurve(params.dirpyrDenoise, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope); - parent->ipf.RGB_denoise_info(origCrop, provicalc, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, parent->imgsrc->getDirPyrDenoiseExpComp(), chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc, true); + parent->ipf.RGB_denoise_info(origCrop, provicalc, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, parent->imgsrc->getDirPyrDenoiseExpComp(), chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc, true); // printf("redy=%f skin=%f pcskin=%f\n",redyel, skinc,nsknc); // printf("DCROP skip=%d cha=%4.0f Nb=%d red=%4.0f bl=%4.0f redM=%4.0f bluM=%4.0f L=%4.0f sigL=%4.0f Ch=%4.0f Si=%4.0f\n",skip, chaut,Nb, redaut,blueaut, maxredaut, maxblueaut, lumema, sigma_L, chromina, sigma); float multip = 1.f; @@ -453,9 +453,9 @@ void Crop::update (int todo) parent->imgsrc->convertColorSpace(provicalc, params.icm, parent->currWB);//for denoise luminance curve float pondcorrec = 1.0f; - float chaut = 0.f, redaut = 0.f, blueaut = 0.f, maxredaut = 0.f, maxblueaut = 0.f, minredaut = 0.f, minblueaut = 0.f, nresi = 0.f, highresi = 0.f, chromina = 0.f, sigma = 0.f, lumema = 0.f, sigma_L = 0.f, redyel = 0.f, skinc = 0.f, nsknc = 0.f; + float chaut = 0.f, redaut = 0.f, blueaut = 0.f, maxredaut = 0.f, maxblueaut = 0.f, minredaut = 0.f, minblueaut = 0.f, chromina = 0.f, sigma = 0.f, lumema = 0.f, sigma_L = 0.f, redyel = 0.f, skinc = 0.f, nsknc = 0.f; int nb = 0; - parent->ipf.RGB_denoise_info(origCropPart, provicalc, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, parent->imgsrc->getDirPyrDenoiseExpComp(), chaut, nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc); + parent->ipf.RGB_denoise_info(origCropPart, provicalc, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, parent->imgsrc->getDirPyrDenoiseExpComp(), chaut, nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc); //printf("DCROP skip=%d cha=%f red=%f bl=%f redM=%f bluM=%f chrom=%f sigm=%f lum=%f\n",skip, chaut,redaut,blueaut, maxredaut, maxblueaut, chromina, sigma, lumema); Nb[hcr * 3 + wcr] = nb; diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 3523ee183..ce65bc2f8 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -321,7 +321,7 @@ public: void Median_Denoise( float **src, float **dst, int width, int height, Median medianType, int iterations, int numThreads, float **buffer = NULL); void RGB_denoise(int kall, Imagefloat * src, Imagefloat * dst, Imagefloat * calclum, float * ch_M, float *max_r, float *max_b, bool isRAW, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, const NoiseCurve & noiseLCurve , const NoiseCurve & noiseCCurve , float &chaut, float &redaut, float &blueaut, float &maxredaut, float & maxblueaut, float &nresi, float &highresi); void RGB_denoise_infoGamCurve(const procparams::DirPyrDenoiseParams & dnparams, const bool isRAW, LUTf &gamcurve, float &gam, float &gamthresh, float &gamslope); - void RGB_denoise_info(Imagefloat * src, Imagefloat * provicalc, bool isRAW, LUTf &gamcurve, float gam, float gamthresh, float gamslope, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float & maxblueaut, float &minredaut, float & minblueaut, float &nresi, float &highresi, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, bool multiThread = false); + void RGB_denoise_info(Imagefloat * src, Imagefloat * provicalc, bool isRAW, LUTf &gamcurve, float gam, float gamthresh, float gamslope, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float & maxblueaut, float &minredaut, float & minblueaut, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, bool multiThread = false); void RGBtile_denoise (float * fLblox, int hblproc, float noisevar_Ldetail, float * nbrwt, float * blurbuffer ); //for DCT void RGBoutput_tile_row (float *bloxrow_L, float ** Ldetail, float ** tilemask_out, int height, int width, int top ); bool WaveletDenoiseAllL(wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3], float * vari, int edge); diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 63a207beb..e12121d07 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -273,7 +273,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p float maxr = 0.f; float maxb = 0.f; float pondcorrec = 1.0f; - float chaut, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc; + float chaut, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc; int Nb; chaut = 0.f; redaut = 0.f; @@ -282,7 +282,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p maxblueaut = 0.f; chromina = 0.f; sigma = 0.f; - ipf.RGB_denoise_info(origCropPart, provicalc, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, imgsrc->getDirPyrDenoiseExpComp(), chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc); + ipf.RGB_denoise_info(origCropPart, provicalc, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, imgsrc->getDirPyrDenoiseExpComp(), chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc); float multip = 1.f; float adjustr = 1.f; @@ -490,8 +490,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p imgsrc->convertColorSpace(provicalc, params.icm, currWB);//for denoise luminance curve int nb = 0; - float chaut = 0.f, redaut = 0.f, blueaut = 0.f, maxredaut = 0.f, maxblueaut = 0.f, minredaut = 0.f, minblueaut = 0.f, nresi = 0.f, highresi = 0.f, chromina = 0.f, sigma = 0.f, lumema = 0.f, sigma_L = 0.f, redyel = 0.f, skinc = 0.f, nsknc = 0.f; - ipf.RGB_denoise_info(origCropPart, provicalc, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, imgsrc->getDirPyrDenoiseExpComp(), chaut, nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc); + float chaut = 0.f, redaut = 0.f, blueaut = 0.f, maxredaut = 0.f, maxblueaut = 0.f, minredaut = 0.f, minblueaut = 0.f, chromina = 0.f, sigma = 0.f, lumema = 0.f, sigma_L = 0.f, redyel = 0.f, skinc = 0.f, nsknc = 0.f; + ipf.RGB_denoise_info(origCropPart, provicalc, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, imgsrc->getDirPyrDenoiseExpComp(), chaut, nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc); Nb[hcr * 3 + wcr] = nb; ch_M[hcr * 3 + wcr] = chaut; max_r[hcr * 3 + wcr] = maxredaut; From 8de758f7b6338de2fa07a100f134427bc034351e Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 2 Oct 2016 15:22:42 +0200 Subject: [PATCH 02/13] Removed rtengine/hlmultipliers.cc --- rtengine/hlmultipliers.cc | 441 ------------------------------------- rtengine/rawimagesource.cc | 2 - rtengine/rawimagesource.h | 2 - 3 files changed, 445 deletions(-) delete mode 100644 rtengine/hlmultipliers.cc diff --git a/rtengine/hlmultipliers.cc b/rtengine/hlmultipliers.cc deleted file mode 100644 index 35e1d3e87..000000000 --- a/rtengine/hlmultipliers.cc +++ /dev/null @@ -1,441 +0,0 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * RawTherapee is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * RawTherapee is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with RawTherapee. If not, see . - */ -#include -#include -#include "rawimagesource.h" -#include "rawimagesource_i.h" -#include "jaggedarray.h" -#include "../rtgui/options.h" - -namespace rtengine -{ - -// computes highlight recovery multipliers. Needs a possibly downscaled image where -// the highlights are indicated by INT_MAX -void hlmultipliers (int** rec[3], int max_3[3], int dh, int dw) -{ - - // STEP I. recover color with two-color information - int phase = -1; - int k = 0; - - for (k = 0; k < 1000; k++) { - int changed = 0; - - for (int i = 1; i < dh - 1; i++) - for (int j = 1; j < dw - 1; j++) { - int co, c1, c2; - -// if (phase==2) -// phase++; -// if (phase>0)// && phase!=4) -// continue; - if (phase == -1 || phase == 0 || phase == 2) { - if (rec[0][i][j] == INT_MAX && rec[1][i][j] != INT_MAX && rec[1][i][j] >= 0 && rec[2][i][j] != INT_MAX && rec[2][i][j] >= 0) { - co = 0; - c1 = 1; - c2 = 2; - } else if (rec[1][i][j] == INT_MAX && rec[0][i][j] != INT_MAX && rec[0][i][j] >= 0 && rec[2][i][j] != INT_MAX && rec[2][i][j] >= 0) { - co = 1; - c1 = 0; - c2 = 2; - } else if (rec[2][i][j] == INT_MAX && rec[1][i][j] != INT_MAX && rec[1][i][j] >= 0 && rec[0][i][j] != INT_MAX && rec[0][i][j] >= 0) { - co = 2; - c1 = 1; - c2 = 0; - } else { - continue; - } - - double ratio[2] = {0.0, 0.0}; - int count = 0; - double rato = (double)rec[c1][i][j] / rec[c2][i][j]; - double arato = 0.0; - - if (phase == 2) { - for (int x = -1; x <= 1; x++) - for (int y = -1; y <= 1; y++) { - // average m/c color ratios in the surrounding pixels - if (rec[co][i + x][j + y] >= 0 && rec[co][i + x][j + y] != INT_MAX && rec[c1][i + x][j + y] >= 0 && rec[c1][i + x][j + y] != INT_MAX && rec[c2][i + x][j + y] > 0 && rec[c2][i + x][j + y] != INT_MAX) { - double ratt = (double)rec[c1][i + x][j + y] / rec[c2][i + x][j + y]; - - if (ratt > rato * 1.2 || ratt < rato / 1.2 || rec[co][i + x][j + y] < max_3[co] * 1 / 2) { - continue; - } - - ratio[0] += (double)rec[c1][i + x][j + y] / rec[co][i + x][j + y]; - ratio[1] += (double)rec[c2][i + x][j + y] / rec[co][i + x][j + y]; - count++; - } - } - } else if (phase == -1) { - for (int x = -1; x <= 1; x++) - for (int y = -1; y <= 1; y++) { - // average m/c color ratios in the surrounding pixels - if (rec[co][i + x][j + y] >= 0 && rec[co][i + x][j + y] != INT_MAX && rec[c1][i + x][j + y] >= 0 && rec[c1][i + x][j + y] != INT_MAX && rec[c2][i + x][j + y] > 0 && rec[c2][i + x][j + y] != INT_MAX) { - double ratt = (double)rec[c1][i + x][j + y] / rec[c2][i + x][j + y]; - - if (ratt > rato * 1.05 || ratt < rato / 1.05 || rec[co][i + x][j + y] < max_3[co] * 4 / 5) { - continue; - } - - arato += ratt; - ratio[0] += (double)rec[c1][i + x][j + y] / rec[co][i + x][j + y]; - ratio[1] += (double)rec[c2][i + x][j + y] / rec[co][i + x][j + y]; - - count++; - } - } - } else { - for (int x = -1; x <= 1; x++) - for (int y = -1; y <= 1; y++) { - // average m/c color ratios in the surrounding pixels - if (rec[co][i + x][j + y] >= 0 && rec[co][i + x][j + y] != INT_MAX && rec[c1][i + x][j + y] >= 0 && rec[c1][i + x][j + y] != INT_MAX && rec[c2][i + x][j + y] > 0 && rec[c2][i + x][j + y] != INT_MAX) { - double ratt = (double)rec[c1][i + x][j + y] / rec[c2][i + x][j + y]; - - if (ratt > rato * 1.1 || ratt < rato / 1.1 || rec[co][i + x][j + y] < max_3[co] * 3 / 4) { - continue; - } - - arato += ratt; - ratio[0] += (double)rec[c1][i + x][j + y] / rec[co][i + x][j + y]; - ratio[1] += (double)rec[c2][i + x][j + y] / rec[co][i + x][j + y]; - - count++; - } - } - } - - // compute new pixel values from the surrounding color ratios - if (count > 1) { //(phase==0 && count>1) || (phase==2 && count>1)) { - rec[co][i][j] = -(int)((rec[c1][i][j] / ratio[0] * count + rec[c2][i][j] / ratio[1] * count) / 2); - changed++; - } - } else if (phase == 1 || phase == 3) { - if (rec[0][i][j] == INT_MAX && rec[1][i][j] == INT_MAX && rec[2][i][j] != INT_MAX && rec[2][i][j] >= 0) { - co = 2; - c1 = 0; - c2 = 1; - } else if (rec[0][i][j] == INT_MAX && rec[2][i][j] == INT_MAX && rec[1][i][j] != INT_MAX && rec[1][i][j] >= 0) { - co = 1; - c1 = 0; - c2 = 2; - } else if (rec[1][i][j] == INT_MAX && rec[2][i][j] == INT_MAX && rec[0][i][j] != INT_MAX && rec[0][i][j] >= 0) { - co = 0; - c1 = 1; - c2 = 2; - } else { - continue; - } - - double ratio[2] = {0.0, 0.0}; - int count[2] = {0, 0}; - - for (int x = -1; x <= 1; x++) - for (int y = -1; y <= 1; y++) { - // average m/c color ratios in the surrounding pixels - if (rec[co][i + x][j + y] >= 0 && rec[co][i + x][j + y] != INT_MAX && rec[c1][i + x][j + y] > 0 && rec[c1][i + x][j + y] != INT_MAX) { - if ((phase == 1 && rec[c1][i + x][j + y] < max_3[c1] * 3 / 4) || (phase == 3 && rec[c1][i + x][j + y] < max_3[c1] * 1 / 2)) { - continue; - } - - ratio[0] += (double)rec[co][i + x][j + y] / rec[c1][i + x][j + y]; - count[0] ++; - } - - if (rec[co][i + x][j + y] >= 0 && rec[co][i + x][j + y] != INT_MAX && rec[c2][i + x][j + y] > 0 && rec[c2][i + x][j + y] != INT_MAX) { - if ((phase == 1 && rec[c2][i + x][j + y] < max_3[c2] * 3 / 4) || (phase == 3 && rec[c2][i + x][j + y] < max_3[c2] * 1 / 2)) -// if (/*phase!=3 && */rec[c2][i+x][j+y] 2) || (phase == 3 && count[0] > 1)) { - rec[c1][i][j] = - (int) ((double)rec[co][i][j] / ratio[0] * count[0]); - changed++; - } - - if ((phase == 1 && count[1] > 2) || (phase == 3 && count[1] > 1)) { - rec[c2][i][j] = - (int) ((double)rec[co][i][j] / ratio[1] * count[1]); - changed++; - } - } else { - int val = 0; - int num = 0; - - for (int c = 0; c < 3; c++) - if (rec[c][i][j] != INT_MAX) { - val += rec[c][i][j]; - num++; - } - - if (num < 3 && num > 0) { - for (int c = 0; c < 3; c++) { - rec[c][i][j] = val / num; - } - } - } - } - - - bool change = false; - - for (int i = 1; i < dh - 1; i++) - for (int j = 1; j < dw - 1; j++) - for (int c = 0; c < 3; c++) { - if (rec[c][i][j] < 0) { - rec[c][i][j] = -rec[c][i][j]; - change = true; - } - } - - if (!change && phase < 4) { - phase++; - - if( options.rtSettings.verbose ) { - printf ("phc %d: %d\n", phase, k); - } - } else if (!change) { - break; - } - - if (k % 20 == 0 && options.rtSettings.verbose ) { - printf ("changed %d\n", changed); - } - } - - if( options.rtSettings.verbose ) { - printf ("Highlight recovery ends in %d iterations\n", k); - } - - int maxval = max(max_3[0], max_3[1], max_3[2]); - - for (int i = 0; i < dh; i++) - for (int j = 0; j < dw; j++) - if (rec[0][i][j] == INT_MAX || rec[1][i][j] == INT_MAX || rec[2][i][j] == INT_MAX) { - rec[0][i][j] = maxval; - rec[1][i][j] = maxval; - rec[2][i][j] = maxval; - - } -} - -void RawImageSource::HLRecovery_ColorPropagation (float* red, float* green, float* blue, int i, int sx1, int width, int skip) -{ - - int blr = (i + HR_SCALE / 2) / HR_SCALE - 1; - - if (blr < 0 || blr >= H / HR_SCALE - 2) { - return; - } - - double mr1 = 1.0 - ((double)((i + HR_SCALE / 2) % HR_SCALE) / HR_SCALE + 0.5 / HR_SCALE); - int maxcol = W / HR_SCALE - 2; - - for (int j = sx1, jx = 0; jx < width; j += skip, jx++) { - if (needhr[i][j]) { - int blc = (j + HR_SCALE / 2) / HR_SCALE - 1; - - if (blc < 0 || blc >= maxcol) { - continue; - } - - double mc1 = 1.0 - ((double)((j + HR_SCALE / 2) % HR_SCALE) / HR_SCALE + 0.5 / HR_SCALE); - double mulr = mr1 * mc1 * hrmap[0][blr][blc] + mr1 * (1.0 - mc1) * hrmap[0][blr][blc + 1] + (1.0 - mr1) * mc1 * hrmap[0][blr + 1][blc] + (1.0 - mr1) * (1.0 - mc1) * hrmap[0][blr + 1][blc + 1]; - double mulg = mr1 * mc1 * hrmap[1][blr][blc] + mr1 * (1.0 - mc1) * hrmap[1][blr][blc + 1] + (1.0 - mr1) * mc1 * hrmap[1][blr + 1][blc] + (1.0 - mr1) * (1.0 - mc1) * hrmap[1][blr + 1][blc + 1]; - double mulb = mr1 * mc1 * hrmap[2][blr][blc] + mr1 * (1.0 - mc1) * hrmap[2][blr][blc + 1] + (1.0 - mr1) * mc1 * hrmap[2][blr + 1][blc] + (1.0 - mr1) * (1.0 - mc1) * hrmap[2][blr + 1][blc + 1]; - red[jx] = (red[jx] * mulr); - green[jx] = (green[jx] * mulg); - blue[jx] = (blue[jx] * mulb); - } else { - red[jx] = (red[jx]); - green[jx] = (green[jx]); - blue[jx] = (blue[jx]); - } - } -} - -void RawImageSource::updateHLRecoveryMap_ColorPropagation () -{ - - // detect maximal pixel values - float* red = new float[W]; - float* blue = new float[W]; - int maxr = 0, maxg = 0, maxb = 0; - - for (int i = 32; i < H - 32; i++) { - interpolate_row_rb (red, blue, green[i - 1], green[i], green[i + 1], i); - - for (int j = 32; j < W - 32; j++) { - if ((ri->ISRED(i, j) || ri->getSensorType() != ST_BAYER) && red[j] > maxr) { - maxr = red[j]; - } - - if ((ri->ISGREEN(i, j) || ri->getSensorType() != ST_BAYER) && green[i][j] > maxg) { - maxg = green[i][j]; - } - - if ((ri->ISBLUE(i, j) || ri->getSensorType() != ST_BAYER) && blue[j] > maxb) { - maxb = blue[j]; - } - } - } - - delete [] red; - delete [] blue; - - maxr = maxr * 19 / 20; - maxg = maxg * 19 / 20; - maxb = maxb * 19 / 20; - max_3[0] = maxr; - max_3[1] = maxg; - max_3[2] = maxb; - - // downscale image - int dw = W / HR_SCALE; - int dh = H / HR_SCALE; - Image16* ds = new Image16 (dw, dh); - - // overburnt areas - int** rec[3]; - - for (int i = 0; i < 3; i++) { - rec[i] = allocJaggedArray (dw, dh); - } - - float* reds[HR_SCALE]; - float* blues[HR_SCALE]; - - for (int i = 0; i < HR_SCALE; i++) { - reds[i] = new float[W]; - blues[i] = new float[W]; - } - - if (needhr) { - freeJaggedArray(needhr); - } - - needhr = allocJaggedArray (W, H); - - for (int i = 0; i < dh; i++) { - for (int j = 0; j < HR_SCALE; j++) { - interpolate_row_rb (reds[j], blues[j], green[HR_SCALE * i + j - 1], green[HR_SCALE * i + j], green[HR_SCALE * i + j + 1], HR_SCALE * i + j); - - for (int k = 0; k < W; k++) - if (reds[j][k] >= max_3[0] || green[HR_SCALE * i + j][k] >= max_3[1] || blues[j][k] >= max_3[2]) { - needhr[HR_SCALE * i + j][k] = 1; - } else { - needhr[HR_SCALE * i + j][k] = 0; - } - } - - for (int j = 0; j < dw; j++) { - int sumr = 0; - int cr = 0; - int sumg = 0; - int cg = 0; - int sumb = 0; - int cb = 0; - - for (int x = 0; x < HR_SCALE; x++) - for (int y = 0; y < HR_SCALE; y++) { - int ix = HR_SCALE * i + x; - int jy = HR_SCALE * j + y; - sumr += reds[x][jy]; - - if (reds[x][jy] < maxr) { - cr++; - } - - sumg += green[ix][jy]; - - if (green[ix][jy] < maxg) { - cg++; - } - - sumb += blues[x][jy]; - - if (blues[x][jy] < maxb) { - cb++; - } - } - - if (cr < HR_SCALE * HR_SCALE) { - rec[0][i][j] = INT_MAX; - } else { - rec[0][i][j] = sumr / HR_SCALE / HR_SCALE; - } - - if (cg < HR_SCALE * HR_SCALE) { - rec[1][i][j] = INT_MAX; - } else { - rec[1][i][j] = sumg / HR_SCALE / HR_SCALE; - } - - if (cb < HR_SCALE * HR_SCALE) { - rec[2][i][j] = INT_MAX; - } else { - rec[2][i][j] = sumb / HR_SCALE / HR_SCALE; - } - - ds->r(i, j) = sumr / HR_SCALE / HR_SCALE; - ds->g(i, j) = sumg / HR_SCALE / HR_SCALE; - ds->b(i, j) = sumb / HR_SCALE / HR_SCALE; - } - } - - for (int i = 0; i < HR_SCALE; i++) { - delete [] reds[i]; - delete [] blues[i]; - } - - hlmultipliers (rec, max_3, dh, dw); - - if (hrmap[0] != NULL) { - freeJaggedArray (hrmap[0]); - freeJaggedArray (hrmap[1]); - freeJaggedArray (hrmap[2]); - } - - hrmap[0] = allocJaggedArray (dw, dh); - hrmap[1] = allocJaggedArray (dw, dh); - hrmap[2] = allocJaggedArray (dw, dh); - - for (int i = 0; i < dh; i++) - for (int j = 0; j < dw; j++) { - hrmap[0][i][j] = ds->r(i, j) > 0 ? (double)rec[0][i][j] / ds->r(i, j) : 1.0; - hrmap[1][i][j] = ds->g(i, j) > 0 ? (double)rec[1][i][j] / ds->g(i, j) : 1.0; - hrmap[2][i][j] = ds->b(i, j) > 0 ? (double)rec[2][i][j] / ds->b(i, j) : 1.0; - } - - delete ds; - - freeJaggedArray (rec[0]); - freeJaggedArray (rec[1]); - freeJaggedArray (rec[2]); -} - -} - diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index d2bdf9763..dcf7c1207 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -4403,8 +4403,6 @@ void RawImageSource::hlRecovery (std::string method, float* red, float* green, f } else if (method == "CIELab blending") { HLRecovery_CIELab (red, green, blue, red, green, blue, width, 65535.0, imatrices.xyz_cam, imatrices.cam_xyz); } - /*else if (method=="Color") - HLRecovery_ColorPropagation (red, green, blue, i, sx1, width, skip);*/ else if (method == "Blend") { // derived from Dcraw HLRecovery_blend(red, green, blue, width, 65535.0, hlmax); } diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index e682f0e79..8f6552a74 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -101,8 +101,6 @@ protected: void transformRect (PreviewProps pp, int tran, int &sx1, int &sy1, int &width, int &height, int &fw); void transformPosition (int x, int y, int tran, int& tx, int& ty); - void updateHLRecoveryMap_ColorPropagation (); - void HLRecovery_ColorPropagation (float* red, float* green, float* blue, int i, int sx1, int width, int skip); unsigned FC(int row, int col) { return ri->FC(row, col); From ccd9002c3abc504e3a25b7bbf0489b90b4cf808e Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 2 Oct 2016 23:33:00 +0200 Subject: [PATCH 03/13] Cppcheck: Solve issues related to copy constructor --- rtengine/EdgePreserveLab.cc | 264 ------------------------- rtengine/EdgePreserveLab.h | 77 -------- rtengine/EdgePreservingDecomposition.h | 2 + rtengine/LUT.h | 2 + rtengine/array2D.h | 2 + rtengine/cieimage.h | 2 + rtengine/cplx_wavelet_dec.h | 2 + rtengine/improcfun.cc | 4 +- rtengine/iplab2rgb.cc | 5 +- rtengine/ipwavelet.cc | 2 +- rtengine/rawimage.h | 3 + rtengine/shmap.h | 2 + rtexif/rtexif.h | 2 + rtgui/previewloader.cc | 2 + rtgui/previewloader.h | 2 + rtgui/profilestore.h | 2 + rtgui/thumbimageupdater.cc | 2 + rtgui/thumbimageupdater.h | 2 + 18 files changed, 33 insertions(+), 346 deletions(-) delete mode 100644 rtengine/EdgePreserveLab.cc delete mode 100644 rtengine/EdgePreserveLab.h diff --git a/rtengine/EdgePreserveLab.cc b/rtengine/EdgePreserveLab.cc deleted file mode 100644 index 1f063ec0c..000000000 --- a/rtengine/EdgePreserveLab.cc +++ /dev/null @@ -1,264 +0,0 @@ -#include "EdgePreserveLab.h" -#include "boxblur.h" -#include - -#ifdef _OPENMP -#include -#endif - -//#define MAX(a,b) ((a)<(b)?(b):(a)) -//#define MIN(a,b) ((a)>(b)?(b):(a)) - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -EdgePreserveLab::EdgePreserveLab(unsigned int width, unsigned int height) -{ - w = width; - h = height; - n = w * h; - - //Initialize the matrix just once at construction. - A = new MultiDiagonalSymmetricMatrix(n, 5); - - if(!( - A->CreateDiagonal(0, 0) && - A->CreateDiagonal(1, 1) && - A->CreateDiagonal(2, w - 1) && - A->CreateDiagonal(3, w) && - A->CreateDiagonal(4, w + 1))) { - delete A; - A = NULL; - printf("Error in EdgePreserveLab construction: out of memory.\n"); - } else { - a0 = A->Diagonals[0]; - a_1 = A->Diagonals[1]; - a_w1 = A->Diagonals[2]; - a_w = A->Diagonals[3]; - a_w_1 = A->Diagonals[4]; - } -} - -EdgePreserveLab::~EdgePreserveLab() -{ - delete A; -} - -float *EdgePreserveLab::CreateBlur(float *Source, float LScale, float abScale, float EdgeStoppingLuma, float EdgeStoppingChroma, unsigned int Iterates, float *Blur, bool UseBlurForEdgeStop) -{ - if(Blur == NULL) - UseBlurForEdgeStop = false, //Use source if there's no supplied Blur. - Blur = new float[3 * n]; - - if(LScale == 0.0f) { - memcpy(Blur, Source, 3 * n * sizeof(float)); - return Blur; - } - - //Create the edge stopping function a, rotationally symmetric and just one instead of (ax, ay). Maybe don't need Blur yet, so use its memory. - float *a, *b, *g; - - if(UseBlurForEdgeStop) { - a = new float[n], g = Blur; - } else { - a = Blur, g = Source; - } - - //b = new float[n]; - - unsigned int x, y, i; - unsigned int w1 = w - 1, h1 = h - 1; - float eps = 0.0001f; - float scL = powf(100.0f, LScale); - float scab = powf(200.0f, abScale); - - float * var = new float[w * h]; - rtengine::boxvar(g, var, 1, 1, w, h); - -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for(y = 0; y < h1; y++) { - float *rg = &g[w * y]; - - for(x = 0; x < w1; x++) { - //Estimate the central difference gradient in the center of a four pixel square. (gx, gy) is actually 2*gradient. - /*float gx = (fabs((rg[x + 1] - rg[x]) + (rg[x + w + 1] - rg[x + w]))); - float gy = (fabs((rg[x + w] - rg[x]) + (rg[x + w + 1] - rg[x + 1]))); - - //TODO: combine this with gx, gy if not needing separate quantities - float hx = (fabs((rg[x + 1 + n] - rg[x + n]) + (rg[x + w + 1 + n] - rg[x + w + n])) + \ - fabs((rg[x + 1 + 2*n] - rg[x + 2*n]) + (rg[x + w + 1 + 2*n] - rg[x + w + 2*n]))); - float hy = (fabs((rg[x + w + n] - rg[x + n]) + (rg[x + w + 1 + n] - rg[x + 1 + n])) + \ - fabs((rg[x + w + 2*n] - rg[x + 2*n]) + (rg[x + w + 1 + 2*n] - rg[x + 1 + 2*n]))); - */ - //float gradtot = (gx+gy+hx+hy); - //gradhisto[MAX(0,MIN(32767,(int)gradtot))] ++; - - //Apply power to the magnitude of the gradient to get the edge stopping function. - //a[x + w*y] = scL*expf(-100.0f*(gx + gy + hx + hy)/(EdgeStoppingLuma)); - //a[x + w*y] = scL*expf(-var[y*w+x]/SQR(0.02*EdgeStoppingLuma));///(0.1+rg[x]); - a[x + w * y] = scL * expf(-50.0f * sqrt(var[y * w + x]) / (EdgeStoppingLuma + eps)); ///(0.1+rg[x]); - - //b[x + w*y] = (scab)*expf(-20.0f*(gx + gy + Lave*(hx + hy))/(EdgeStoppingChroma)); - //b[x + w*y] = (scab)*expf(-400.0f*SQR(gx + gy + Lave*(hx + hy))/SQR(EdgeStoppingChroma));; - - } - } - - /* Now setup the linear problem. I use the Maxima CAS, here's code for making an FEM formulation for the smoothness term: - p(x, y) := (1 - x)*(1 - y); - P(m, n) := A[m][n]*p(x, y) + A[m + 1][n]*p(1 - x, y) + A[m + 1][n + 1]*p(1 - x, 1 - y) + A[m][n + 1]*p(x, 1 - y); - Integrate(f) := integrate(integrate(f, x, 0, 1), y, 0, 1); - - Integrate(diff(P(u, v), x)*diff(p(x, y), x) + diff(P(u, v), y)*diff(p(x, y), y)); - Integrate(diff(P(u - 1, v), x)*diff(p(1 - x, y), x) + diff(P(u - 1, v), y)*diff(p(1 - x, y), y)); - Integrate(diff(P(u - 1, v - 1), x)*diff(p(1 - x, 1 - y), x) + diff(P(u - 1, v - 1), y)*diff(p(1 - x, 1 - y), y)); - Integrate(diff(P(u, v - 1), x)*diff(p(x, 1 - y), x) + diff(P(u, v - 1), y)*diff(p(x, 1 - y), y)); - So yeah. Use the numeric results of that to fill the matrix A.*/ - memset(a_1, 0, A->DiagonalLength(1)*sizeof(float)); - memset(a_w1, 0, A->DiagonalLength(w - 1)*sizeof(float)); - memset(a_w, 0, A->DiagonalLength(w)*sizeof(float)); - memset(a_w_1, 0, A->DiagonalLength(w + 1)*sizeof(float)); - -//TODO: OMP here? - for(i = y = 0; y != h; y++) { - for(x = 0; x != w; x++, i++) { - float ac; - a0[i] = 1.0; - - //Remember, only fill the lower triangle. Memory for upper is never made. It's symmetric. Trust. - if(x > 0 && y > 0) - ac = a[i - w - 1] / 6.0f, - a_w_1[i - w - 1] -= 2.0f * ac, a_w[i - w] -= ac, - a_1[i - 1] -= ac, a0[i] += 4.0f * ac; - - if(x < w1 && y > 0) - ac = a[i - w] / 6.0f, - a_w[i - w] -= ac, a_w1[i - w + 1] -= 2.0f * ac, - a0[i] += 4.0f * ac; - - if(x > 0 && y < h1) - ac = a[i - 1] / 6.0f, - a_1[i - 1] -= ac, a0[i] += 4.0f * ac; - - if(x < w1 && y < h1) { - a0[i] += 4.0f * a[i] / 6.0f; - } - } - } - - if(UseBlurForEdgeStop) { - delete[] a; - } - - - //Solve & return. - A->CreateIncompleteCholeskyFactorization(1); //Fill-in of 1 seems to work really good. More doesn't really help and less hurts (slightly). - - if(!UseBlurForEdgeStop) { - memcpy(Blur, Source, 3 * n * sizeof(float)); - } - - // blur L channel - SparseConjugateGradient(A->PassThroughVectorProduct, Source, n, false, Blur, 0.0f, (void *)A, Iterates, A->PassThroughCholeskyBackSolve); - - //reset A for ab channels - /*memset(a_1, 0, A->DiagonalLength(1)*sizeof(float)); - memset(a_w1, 0, A->DiagonalLength(w - 1)*sizeof(float)); - memset(a_w, 0, A->DiagonalLength(w)*sizeof(float)); - memset(a_w_1, 0, A->DiagonalLength(w + 1)*sizeof(float)); - for(i = y = 0; y != h; y++){ - for(x = 0; x != w; x++, i++){ - float ac; - a0[i] = 1.0; - - //Remember, only fill the lower triangle. Memory for upper is never made. It's symmetric. Trust. - if(x > 0 && y > 0) - ac = b[i - w - 1]/6.0f, - a_w_1[i - w - 1] -= 2.0f*ac, a_w[i - w] -= ac, - a_1[i - 1] -= ac, a0[i] += 4.0f*ac; - - if(x < w1 && y > 0) - ac = b[i - w]/6.0f, - a_w[i - w] -= ac, a_w1[i - w + 1] -= 2.0f*ac, - a0[i] += 4.0f*ac; - - if(x > 0 && y < h1) - ac = b[i - 1]/6.0f, - a_1[i - 1] -= ac, a0[i] += 4.0f*ac; - - if(x < w1 && y < h1) - a0[i] += 4.0f*b[i]/6.0f; - } - }*/ - /*if(UseBlurForEdgeStop)*/ //delete[] b; - - // blur ab channels - //A->CreateIncompleteCholeskyFactorization(1); //Fill-in of 1 seems to work really good. More doesn't really help and less hurts (slightly). - //SparseConjugateGradient(A->PassThroughVectorProduct, Source+n, n, false, Blur+n, 0.0f, (void *)A, Iterates, A->PassThroughCholeskyBackSolve); - //SparseConjugateGradient(A->PassThroughVectorProduct, Source+2*n, n, false, Blur+2*n, 0.0f, (void *)A, Iterates, A->PassThroughCholeskyBackSolve); - - A->KillIncompleteCholeskyFactorization(); - return Blur; -} - -float *EdgePreserveLab::CreateIteratedBlur(float *Source, float LScale, float abScale, float EdgeStoppingLuma, float EdgeStoppingChroma, unsigned int Iterates, unsigned int Reweightings, float *Blur) -{ - //Simpler outcome? - if(Reweightings == 0) { - return CreateBlur(Source, LScale, abScale, EdgeStoppingLuma, EdgeStoppingChroma, Iterates, Blur); - } - - //Create a blur here, initialize. - if(Blur == NULL) { - Blur = new float[3 * n]; - } - - memcpy(Blur, Source, 3 * n * sizeof(float)); - - //Iteratively improve the blur. - Reweightings++; - - for(unsigned int i = 0; i != Reweightings; i++) { - CreateBlur(Source, LScale, abScale, EdgeStoppingLuma, EdgeStoppingChroma, Iterates, Blur, true); - } - - return Blur; -} - -float *EdgePreserveLab::CompressDynamicRange(float *Source, float LScale, float abScale, float EdgeStoppingLuma, float EdgeStoppingChroma, float CompressionExponent, float DetailBoost, unsigned int Iterates, unsigned int Reweightings, float *Compressed) -{ - //We're working with luminance, which does better logarithmic. - unsigned int i; - //for(i = 0; i != n; i++) - // Source[i] = logf(Source[i] + 0.0001f); - - //Blur. Also setup memory for Compressed (we can just use u since each element of u is used in one calculation). - float *u = CreateIteratedBlur(Source, LScale, abScale, EdgeStoppingLuma, EdgeStoppingChroma, Iterates, Reweightings); - - if(Compressed == NULL) { - Compressed = u; - } - - //Apply compression, detail boost, unlogging. Compression is done on the logged data and detail boost on unlogged. - for(i = 0; i != n; i++) { - //float ce = expf(Source[i] + u[i]*(CompressionExponent - 1.0f)) - 0.0001f; - //float ue = expf(u[i]) - 0.0001f; - //Source[i] = expf(Source[i]) - 0.0001f; - //Compressed[i] = ce + DetailBoost*(Source[i] - ue); - Compressed[i] = u[i];//ue;//for testing, to display blur - } - - if(Compressed != u) { - delete[] u; - } - - return Compressed; -} - - - - diff --git a/rtengine/EdgePreserveLab.h b/rtengine/EdgePreserveLab.h deleted file mode 100644 index e365956c5..000000000 --- a/rtengine/EdgePreserveLab.h +++ /dev/null @@ -1,77 +0,0 @@ -#pragma once -/* -The EdgePreserveLab files contain standard C++ (standard except the first line) code for creating and, to a -limited extent (create your own uses!), messing with multi scale edge preserving decompositions of a 32 bit single channel -image. As a byproduct it contains a lot of linear algebra which can be useful for optimization problems that -you want to solve in rectangles on rectangular grids. - -Anyway. Basically, this is an implementation of what's presented in the following papers: - Edge-Preserving Decompositions for Multi-Scale Tone and Detail Manipulation - An Iterative Solution Method for Linear Systems of Which the Coefficient Matrix is a Symetric M-Matrix - Color correction for tone mapping - Wikipedia, the free encyclopedia - -First one is most of what matters, next two are details, last everything else. I did a few things differently, especially: - Reformulated the minimization with finite elements instead of finite differences. This results in better conditioning, - slightly better accuracy (less artifacts), the possibility of a better picked edge stopping function, but more memory consumption. - - A single rotationally invariant edge stopping function is used instead of two non-invariant ones. - - Incomplete Cholseky factorization instead of Szeliski's LAHBF. Slower, but not subject to any patents. - - For tone mapping, original images are decomposed instead of their logarithms, and just one decomposition is made; - I find that this way works plenty good (theirs isn't better or worse... just different) and is simpler. - -Written by ben_pcc in Portland, Oregon, USA; code modified by Emil Martinec. - - // EdgePreserveLab.h and EdgePreserveLab.cpp are free software: - // you can redistribute it and/or modify it - // under the terms of the GNU General Public License as published by - // the Free Software Foundation, either version 3 of the License, or - // (at your option) any later version. - // - // This program is distributed in the hope that it will be useful, - // but WITHOUT ANY WARRANTY; without even the implied warranty of - // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - // GNU General Public License for more details. - // - // You should have received a copy of the GNU General Public License - // along with this program. If not, see . - -*/ - - - -#include -#include -#include -#include "EdgePreservingDecomposition.h" - -class EdgePreserveLab -{ -public: - EdgePreserveLab(unsigned int width, unsigned int height); - ~EdgePreserveLab(); - - //Create an edge preserving blur of Source. Will create and return, or fill into Blur if not NULL. In place not ok. - //If UseBlurForEdgeStop is true, supplied not NULL Blur is used to calculate the edge stopping function instead of Source. - float *CreateBlur(float *Source, float LScale, float abScale, float EdgeStoppingLuma, float EdgeStoppingChroma, unsigned int Iterates, float *Blur = NULL, bool UseBlurForEdgeStop = false); - - //Iterates CreateBlur such that the smoothness term approaches a specific norm via iteratively reweighted least squares. In place not ok. - float *CreateIteratedBlur(float *Source, float LScale, float abScale, float EdgeStoppingLuma, float EdgeStoppingChroma, unsigned int Iterates, unsigned int Reweightings, float *Blur = NULL); - - /*Lowers global contrast while preserving or boosting local contrast. Can fill into Compressed. The smaller Compression - the more compression is applied, with Compression = 1 giving no effect and above 1 the opposite effect. You can totally - use Compression = 1 and play with DetailBoost for some really sweet unsharp masking. If working on luma/grey, consider giving it a logarithm. - In place calculation to save memory (Source == Compressed) is totally ok. Reweightings > 0 invokes CreateIteratedBlur instead of CreateBlur. */ - float *CompressDynamicRange(float *Source, float LScale = 1.0f, float abScale = 5.0f, float EdgeStoppingLuma = 1.0f, float EdgeStoppingChroma = 1.0f, - float CompressionExponent = 0.8f, float DetailBoost = 0.1f, unsigned int Iterates = 20, - unsigned int Reweightings = 0, float *Compressed = NULL); - -private: - MultiDiagonalSymmetricMatrix *A; //The equations are simple enough to not mandate a matrix class, but fast solution NEEDS a complicated preconditioner. - unsigned int w, h, n; - - //Convenient access to the data in A. - float *a0, *a_1, *a_w, *a_w_1, *a_w1; -}; diff --git a/rtengine/EdgePreservingDecomposition.h b/rtengine/EdgePreservingDecomposition.h index 558caa5db..a369bdf4d 100644 --- a/rtengine/EdgePreservingDecomposition.h +++ b/rtengine/EdgePreservingDecomposition.h @@ -60,6 +60,7 @@ class MultiDiagonalSymmetricMatrix { public: MultiDiagonalSymmetricMatrix(int Dimension, int NumberOfDiagonalsInLowerTriangle); + MultiDiagonalSymmetricMatrix(const MultiDiagonalSymmetricMatrix&) = delete; ~MultiDiagonalSymmetricMatrix(); /* Storage of matrix data, and a function to create memory for Diagonals[index]. @@ -118,6 +119,7 @@ class EdgePreservingDecomposition { public: EdgePreservingDecomposition(int width, int height); + EdgePreservingDecomposition(const EdgePreservingDecomposition&) = delete; ~EdgePreservingDecomposition(); //Create an edge preserving blur of Source. Will create and return, or fill into Blur if not NULL. In place not ok. diff --git a/rtengine/LUT.h b/rtengine/LUT.h index 24f883766..c570fe671 100644 --- a/rtengine/LUT.h +++ b/rtengine/LUT.h @@ -167,6 +167,8 @@ public: reset(); } + LUT(const LUT&) = delete; + ~LUT() { if (owner) { diff --git a/rtengine/array2D.h b/rtengine/array2D.h index f9d92ac36..75d784cbc 100644 --- a/rtengine/array2D.h +++ b/rtengine/array2D.h @@ -167,6 +167,8 @@ public: } } + array2D(const array2D&) = delete; + // destructor ~array2D() { diff --git a/rtengine/cieimage.h b/rtengine/cieimage.h index a97622325..d8cf45cf8 100644 --- a/rtengine/cieimage.h +++ b/rtengine/cieimage.h @@ -41,6 +41,8 @@ public: float** h_p; CieImage (int w, int h); + CieImage (const CieImage&) = delete; + ~CieImage (); //Copies image data in Img into this instance. diff --git a/rtengine/cplx_wavelet_dec.h b/rtengine/cplx_wavelet_dec.h index 0ab01be57..c5267897c 100644 --- a/rtengine/cplx_wavelet_dec.h +++ b/rtengine/cplx_wavelet_dec.h @@ -58,6 +58,8 @@ public: template wavelet_decomposition(E * src, int width, int height, int maxlvl, int subsampling, int skipcrop = 1, int numThreads = 1, int Daub4Len = 6); + wavelet_decomposition(const wavelet_decomposition&) = delete; + ~wavelet_decomposition(); internal_type ** level_coeffs(int level) const diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index b832951c3..1f41dd6b4 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -6375,7 +6375,7 @@ void ImProcFunctions::EPDToneMapCIE(CieImage *ncie, float a_w, float c_, float w Qpro = maxQ; } - EdgePreservingDecomposition epd = EdgePreservingDecomposition(Wid, Hei); + EdgePreservingDecomposition epd(Wid, Hei); #pragma omp parallel for @@ -6479,7 +6479,7 @@ void ImProcFunctions::EPDToneMap(LabImage *lab, unsigned int Iterates, int skip) float *a = lab->a[0]; float *b = lab->b[0]; unsigned int i, N = lab->W * lab->H; - EdgePreservingDecomposition epd = EdgePreservingDecomposition(lab->W, lab->H); + EdgePreservingDecomposition epd(lab->W, lab->H); //Due to the taking of logarithms, L must be nonnegative. Further, scale to 0 to 1 using nominal range of L, 0 to 15 bit. float minL = FLT_MAX; diff --git a/rtengine/iplab2rgb.cc b/rtengine/iplab2rgb.cc index 4c2da72a4..9e81f4f90 100644 --- a/rtengine/iplab2rgb.cc +++ b/rtengine/iplab2rgb.cc @@ -338,13 +338,11 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int Image16* image = new Image16 (cw, ch); float p1, p2, p3, p4, p5, p6; //primaries - double g_a0, g_a1, g_a2, g_a3, g_a4, g_a5; //gamma parameters double pwr; double ts; ga6 = 0.0; pwr = 1.0 / gampos; ts = slpos; - int mode = 0, imax = 0; int t50; int select_temp = 1; //5003K @@ -475,6 +473,9 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int slpos = eps; } + double g_a0, g_a1, g_a2, g_a3, g_a4, g_a5; //gamma parameters + int mode = 0, imax = 0; + Color::calcGamma(pwr, ts, mode, imax, g_a0, g_a1, g_a2, g_a3, g_a4, g_a5); // call to calcGamma with selected gamma and slope : return parameters for LCMS2 ga4 = g_a3 * ts; ga0 = gampos; diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index d5aa54890..fd682d1d5 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -1647,7 +1647,7 @@ void ImProcFunctions::EPDToneMapResid(float * WavCoeffs_L0, unsigned int Iterat float sca = params->epd.scale; float gamm = params->wavelet.gamma; float rew = params->epd.reweightingIterates; - EdgePreservingDecomposition epd2 = EdgePreservingDecomposition(W_L, H_L); + EdgePreservingDecomposition epd2(W_L, H_L); cp.TMmeth = 2; //default after testing if(cp.TMmeth == 1) { diff --git a/rtengine/rawimage.h b/rtengine/rawimage.h index 86965a612..efb2dacc4 100644 --- a/rtengine/rawimage.h +++ b/rtengine/rawimage.h @@ -48,6 +48,9 @@ public: pm = new base_t [h * w ]; memset(pm, 0, h * w * base_t_size ); } + + PixelsMap(const PixelsMap&) = delete; + ~PixelsMap() { delete [] pm; diff --git a/rtengine/shmap.h b/rtengine/shmap.h index 97a394927..990193378 100644 --- a/rtengine/shmap.h +++ b/rtengine/shmap.h @@ -33,6 +33,8 @@ public: float max_f, min_f, avg; SHMap (int w, int h, bool multiThread); + SHMap(const SHMap&) = delete; + ~SHMap (); void update (Imagefloat* img, double radius, double lumi[3], bool hq, int skip); diff --git a/rtexif/rtexif.h b/rtexif/rtexif.h index 7777331e9..fcccd1161 100644 --- a/rtexif/rtexif.h +++ b/rtexif/rtexif.h @@ -202,6 +202,8 @@ public: Tag (TagDirectory* parent, const TagAttrib* attr, unsigned char *data, TagType t); Tag (TagDirectory* parent, const TagAttrib* attr, int data, TagType t); // create a new tag from array (used Tag (TagDirectory* parent, const TagAttrib* attr, const char* data); // create a new tag from array (used + Tag(const Tag&) = delete; + ~Tag (); void initType (unsigned char *data, TagType type); void initInt (int data, TagType t, int count = 1); diff --git a/rtgui/previewloader.cc b/rtgui/previewloader.cc index 02082f7a7..e7c3d4fac 100644 --- a/rtgui/previewloader.cc +++ b/rtgui/previewloader.cc @@ -80,6 +80,8 @@ public: threadPool_ = new Glib::ThreadPool(threadCount, 0); } + Impl(const Impl&) = delete; + Glib::ThreadPool* threadPool_; MyMutex mutex_; JobSet jobs_; diff --git a/rtgui/previewloader.h b/rtgui/previewloader.h index 762776ae7..05669d399 100644 --- a/rtgui/previewloader.h +++ b/rtgui/previewloader.h @@ -45,6 +45,8 @@ class PreviewLoader { public: + PreviewLoader(const PreviewLoader&) = delete; + /** * @brief Singleton entry point. * diff --git a/rtgui/profilestore.h b/rtgui/profilestore.h index 2928a01ef..d7b85b5f5 100644 --- a/rtgui/profilestore.h +++ b/rtgui/profilestore.h @@ -176,6 +176,8 @@ private: public: ProfileStore(); + ProfileStore (const ProfileStore&) = delete; + ~ProfileStore(); bool init (); void parseProfiles (); diff --git a/rtgui/thumbimageupdater.cc b/rtgui/thumbimageupdater.cc index 29160236e..a247af5f8 100644 --- a/rtgui/thumbimageupdater.cc +++ b/rtgui/thumbimageupdater.cc @@ -78,6 +78,8 @@ public: threadPool_ = new Glib::ThreadPool(threadCount, 0); } + Impl(const Impl&) = delete; + Glib::ThreadPool* threadPool_; // Need to be a Glib::Threads::Mutex because used in a Glib::Threads::Cond object... diff --git a/rtgui/thumbimageupdater.h b/rtgui/thumbimageupdater.h index ea9cff6d7..8d1fc2cc5 100644 --- a/rtgui/thumbimageupdater.h +++ b/rtgui/thumbimageupdater.h @@ -46,6 +46,8 @@ class ThumbImageUpdater public: + ThumbImageUpdater(const ThumbImageUpdater&) = delete; + /** * @brief Singleton entry point. * From 3552fd4161a3de144914a4b6696eef4c98bd8ff8 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 3 Oct 2016 00:54:02 +0200 Subject: [PATCH 04/13] Cppcheck: Fix issues related to explicit constructors --- rtengine/StopWatch.h | 2 +- rtengine/alignedbuffer.h | 2 +- rtengine/colortemp.h | 2 +- rtengine/coord.h | 4 ++-- rtengine/dcp.h | 2 +- rtengine/iccstore.h | 4 ++-- rtengine/lcp.h | 2 +- rtengine/pipettebuffer.h | 2 +- rtengine/rawimage.h | 2 +- rtgui/batchqueue.h | 2 +- rtgui/batchqueuebuttonset.h | 2 +- rtgui/batchqueuepanel.h | 2 +- rtgui/batchtoolpanelcoord.h | 2 +- rtgui/coloredbar.h | 2 +- rtgui/curveeditorgroup.h | 2 +- rtgui/edit.h | 2 +- rtgui/editorpanel.h | 2 +- rtgui/editwindow.cc | 2 +- rtgui/editwindow.h | 2 +- rtgui/filecatalog.h | 2 +- rtgui/filethumbnailbuttonset.h | 2 +- rtgui/guiutils.h | 4 ++-- rtgui/histogrampanel.h | 2 +- rtgui/history.h | 2 +- rtgui/ilabel.h | 2 +- rtgui/imagearea.h | 2 +- rtgui/indclippedpanel.h | 2 +- rtgui/inspector.h | 2 +- rtgui/paramsedited.h | 2 +- rtgui/partialpastedlg.h | 2 +- rtgui/popuptogglebutton.h | 2 +- rtgui/preferences.h | 2 +- rtgui/previewmodepanel.h | 2 +- rtgui/profilepanel.h | 2 +- rtgui/profilestore.h | 2 +- rtgui/progressconnector.h | 2 +- rtgui/renamedlg.h | 4 ++-- rtgui/saveasdlg.h | 2 +- rtgui/splash.h | 2 +- rtgui/thumbbrowserentrybase.h | 2 +- rtgui/zoompanel.h | 2 +- 41 files changed, 45 insertions(+), 45 deletions(-) diff --git a/rtengine/StopWatch.h b/rtengine/StopWatch.h index 2b3ff1baf..ac4a4d16c 100644 --- a/rtengine/StopWatch.h +++ b/rtengine/StopWatch.h @@ -37,7 +37,7 @@ public: { stopped = false; } - StopWatch( const char* msg) + explicit StopWatch( const char* msg ) { message = msg; start(); diff --git a/rtengine/alignedbuffer.h b/rtengine/alignedbuffer.h index ac8471b7e..fbbf83523 100644 --- a/rtengine/alignedbuffer.h +++ b/rtengine/alignedbuffer.h @@ -143,7 +143,7 @@ private: size_t size; public: - AlignedBufferMP(size_t sizeP) + explicit AlignedBufferMP(size_t sizeP) { size = sizeP; } diff --git a/rtengine/colortemp.h b/rtengine/colortemp.h index a1a805092..cd3e422e9 100644 --- a/rtengine/colortemp.h +++ b/rtengine/colortemp.h @@ -53,7 +53,7 @@ private: public: ColorTemp () : temp(-1.), green(-1.), equal (1.), method("Custom") {} - ColorTemp (double e) : temp(-1.), green(-1.), equal (e), method("Custom") {} + explicit ColorTemp (double e) : temp(-1.), green(-1.), equal (e), method("Custom") {} ColorTemp (double t, double g, double e, const Glib::ustring &m); ColorTemp (double mulr, double mulg, double mulb, double e); diff --git a/rtengine/coord.h b/rtengine/coord.h index 2242cec1e..8b6c0cf6a 100644 --- a/rtengine/coord.h +++ b/rtengine/coord.h @@ -35,7 +35,7 @@ struct Coord Coord () = default; Coord (const int x, const int y); Coord (const Coord& other) = default; - Coord (const PolarCoord& other); + explicit Coord (const PolarCoord& other); Coord& operator= (const Coord& other) = default; Coord& operator= (const PolarCoord& other); @@ -66,7 +66,7 @@ struct PolarCoord PolarCoord () = default; PolarCoord (const double radius, const double angle); PolarCoord (const PolarCoord& other) = default; - PolarCoord (const Coord& other); + explicit PolarCoord (const Coord& other); PolarCoord& operator= (const PolarCoord& other) = default; PolarCoord& operator= (const Coord& other); diff --git a/rtengine/dcp.h b/rtengine/dcp.h index 11e368b80..ffc1e33ce 100644 --- a/rtengine/dcp.h +++ b/rtengine/dcp.h @@ -63,7 +63,7 @@ public: using Triple = std::array; using Matrix = std::array; - DCPProfile(const Glib::ustring& filename); + explicit DCPProfile(const Glib::ustring& filename); ~DCPProfile(); explicit operator bool() const; diff --git a/rtengine/iccstore.h b/rtengine/iccstore.h index 8b6e6465c..05281f9df 100644 --- a/rtengine/iccstore.h +++ b/rtengine/iccstore.h @@ -43,8 +43,8 @@ public: ProfileContent (const ProfileContent& other); ProfileContent& operator= (const rtengine::ProfileContent& other); - ProfileContent (const Glib::ustring& fileName); - ProfileContent (cmsHPROFILE hProfile); + explicit ProfileContent (const Glib::ustring& fileName); + explicit ProfileContent (cmsHPROFILE hProfile); cmsHPROFILE toProfile () const; }; diff --git a/rtengine/lcp.h b/rtengine/lcp.h index fa60a6013..15d51d556 100644 --- a/rtengine/lcp.h +++ b/rtengine/lcp.h @@ -89,7 +89,7 @@ public: static const int MaxPersModelCount = 3000; LCPPersModel* aPersModel[MaxPersModelCount]; // Do NOT use std::list or something, it's buggy in GCC! - LCPProfile(Glib::ustring fname); + explicit LCPProfile(Glib::ustring fname); void calcParams(int mode, float focalLength, float focusDist, float aperture, LCPModelCommon *pCorr1, LCPModelCommon *pCorr2, LCPModelCommon *pCorr3) const; // Interpolates between the persModels frames diff --git a/rtengine/pipettebuffer.h b/rtengine/pipettebuffer.h index e6db8eb68..139438e1d 100644 --- a/rtengine/pipettebuffer.h +++ b/rtengine/pipettebuffer.h @@ -50,7 +50,7 @@ protected: void flush(); public: - PipetteBuffer(::EditDataProvider *dataProvider); + explicit PipetteBuffer(::EditDataProvider *dataProvider); ~PipetteBuffer(); /** @brief Getter to know if the pipette buffer is correctly filled */ diff --git a/rtengine/rawimage.h b/rtengine/rawimage.h index efb2dacc4..26ddbfd1b 100644 --- a/rtengine/rawimage.h +++ b/rtengine/rawimage.h @@ -102,7 +102,7 @@ class RawImage: public DCraw { public: - RawImage( const Glib::ustring &name ); + explicit RawImage( const Glib::ustring &name ); ~RawImage(); int loadRaw (bool loadData = true, bool closeFile = true, ProgressListener *plistener = 0, double progressRange = 1.0); diff --git a/rtgui/batchqueue.h b/rtgui/batchqueue.h index 3bf3cb228..fad2b6a25 100644 --- a/rtgui/batchqueue.h +++ b/rtgui/batchqueue.h @@ -68,7 +68,7 @@ protected: void notifyListener (bool queueEmptied); public: - BatchQueue (FileCatalog* aFileCatalog); + explicit BatchQueue (FileCatalog* aFileCatalog); ~BatchQueue (); void addEntries (const std::vector& entries, bool head = false, bool save = true); diff --git a/rtgui/batchqueuebuttonset.h b/rtgui/batchqueuebuttonset.h index cb6ccda56..bef125bb6 100644 --- a/rtgui/batchqueuebuttonset.h +++ b/rtgui/batchqueuebuttonset.h @@ -33,7 +33,7 @@ public: static Cairo::RefPtr headIcon; static Cairo::RefPtr tailIcon; - BatchQueueButtonSet (BatchQueueEntry* myEntry); + explicit BatchQueueButtonSet (BatchQueueEntry* myEntry); }; #endif diff --git a/rtgui/batchqueuepanel.h b/rtgui/batchqueuepanel.h index 997514bef..675745b8a 100644 --- a/rtgui/batchqueuepanel.h +++ b/rtgui/batchqueuepanel.h @@ -55,7 +55,7 @@ class BatchQueuePanel : public Gtk::VBox, public: - BatchQueuePanel (FileCatalog* aFileCatalog); + explicit BatchQueuePanel (FileCatalog* aFileCatalog); void setParent (RTWindow* p) { diff --git a/rtgui/batchtoolpanelcoord.h b/rtgui/batchtoolpanelcoord.h index e064452b2..0c12aa311 100644 --- a/rtgui/batchtoolpanelcoord.h +++ b/rtgui/batchtoolpanelcoord.h @@ -48,7 +48,7 @@ protected: public: - BatchToolPanelCoordinator (FilePanel* parent); + explicit BatchToolPanelCoordinator (FilePanel* parent); // FileSelectionChangeListener interface void selectionChanged (const std::vector& selected); diff --git a/rtgui/coloredbar.h b/rtgui/coloredbar.h index 917085e3c..237cd8595 100644 --- a/rtgui/coloredbar.h +++ b/rtgui/coloredbar.h @@ -37,7 +37,7 @@ protected: std::vector bgGradient; public: - ColoredBar (eRTOrientation orient); + explicit ColoredBar (eRTOrientation orient); void expose(Glib::RefPtr destWindow); void expose(Cairo::RefPtr destSurface); diff --git a/rtgui/curveeditorgroup.h b/rtgui/curveeditorgroup.h index 09cbb8167..f4ca3e8ed 100644 --- a/rtgui/curveeditorgroup.h +++ b/rtgui/curveeditorgroup.h @@ -154,7 +154,7 @@ protected: * This variable will be updated with actions in the * dialogs. */ - CurveEditorSubGroup(Glib::ustring& curveDir); + explicit CurveEditorSubGroup(Glib::ustring& curveDir); Glib::ustring outputFile (); Glib::ustring inputFile (); diff --git a/rtgui/edit.h b/rtgui/edit.h index c49c45408..1ca3894b8 100644 --- a/rtgui/edit.h +++ b/rtgui/edit.h @@ -463,7 +463,7 @@ protected: } action; /// object mode only, ignored in Pipette mode public: - EditSubscriber (EditType editType); + explicit EditSubscriber (EditType editType); virtual ~EditSubscriber () {} void setEditProvider(EditDataProvider *provider); diff --git a/rtgui/editorpanel.h b/rtgui/editorpanel.h index e506e1583..09faca7d3 100644 --- a/rtgui/editorpanel.h +++ b/rtgui/editorpanel.h @@ -138,7 +138,7 @@ protected: public: - EditorPanel (FilePanel* filePanel = NULL); + explicit EditorPanel (FilePanel* filePanel = NULL); virtual ~EditorPanel (); void open (Thumbnail* tmb, rtengine::InitialImage* isrc); diff --git a/rtgui/editwindow.cc b/rtgui/editwindow.cc index 605e915af..3115d9c1f 100644 --- a/rtgui/editwindow.cc +++ b/rtgui/editwindow.cc @@ -37,7 +37,7 @@ EditWindow* EditWindow::getInstance(RTWindow* p) { EditWindow editWnd; - EditWindowInstance(RTWindow* p) : editWnd(p) + explicit EditWindowInstance(RTWindow* p) : editWnd(p) { // Determine the other display and maximize the window on that const Glib::RefPtr< Gdk::Window >& wnd = p->get_window(); diff --git a/rtgui/editwindow.h b/rtgui/editwindow.h index fa47de489..9315b0eb9 100644 --- a/rtgui/editwindow.h +++ b/rtgui/editwindow.h @@ -42,7 +42,7 @@ public: // Should only be created once, auto-creates window on correct display static EditWindow* getInstance(RTWindow* p); - EditWindow (RTWindow* p); + explicit EditWindow (RTWindow* p); void addEditorPanel (EditorPanel* ep, const std::string &name); void remEditorPanel (EditorPanel* ep); diff --git a/rtgui/filecatalog.h b/rtgui/filecatalog.h index b7ea1802f..eb23e65a6 100644 --- a/rtgui/filecatalog.h +++ b/rtgui/filecatalog.h @@ -43,7 +43,7 @@ class DirEntry public: Glib::ustring fullName; - DirEntry (const Glib::ustring& n) : fullName (n) {} + explicit DirEntry (const Glib::ustring& n) : fullName (n) {} bool operator< (DirEntry& other) { diff --git a/rtgui/filethumbnailbuttonset.h b/rtgui/filethumbnailbuttonset.h index b152c3853..a83bacf7b 100644 --- a/rtgui/filethumbnailbuttonset.h +++ b/rtgui/filethumbnailbuttonset.h @@ -44,7 +44,7 @@ public: static Cairo::RefPtr colorLabelIcon_4; static Cairo::RefPtr colorLabelIcon_5; - FileThumbnailButtonSet (FileBrowserEntry* myEntry); + explicit FileThumbnailButtonSet (FileBrowserEntry* myEntry); void setRank (int stars); void setColorLabel (int colorlabel); void setInTrash (bool inTrash); diff --git a/rtgui/guiutils.h b/rtgui/guiutils.h index f91bb0245..3e5f0dd0a 100644 --- a/rtgui/guiutils.h +++ b/rtgui/guiutils.h @@ -79,7 +79,7 @@ public: class ConnectionBlocker { public: - ConnectionBlocker (sigc::connection& connection) : connection (connection) + explicit ConnectionBlocker (sigc::connection& connection) : connection (connection) { wasBlocked = connection.block(); } @@ -101,7 +101,7 @@ private: Gtk::Container *pC; public: - ExpanderBox( Gtk::Container *p); + explicit ExpanderBox( Gtk::Container *p); ~ExpanderBox( ) { delete pC; diff --git a/rtgui/histogrampanel.h b/rtgui/histogrampanel.h index 16a0747e3..60cb1a444 100644 --- a/rtgui/histogrampanel.h +++ b/rtgui/histogrampanel.h @@ -144,7 +144,7 @@ protected: public: - HistogramArea(FullModeListener *fml = NULL); + explicit HistogramArea(FullModeListener *fml = NULL); ~HistogramArea(); void renderHistogram (); diff --git a/rtgui/history.h b/rtgui/history.h index 760444b5f..23a7c30ae 100644 --- a/rtgui/history.h +++ b/rtgui/history.h @@ -95,7 +95,7 @@ protected: public: - History (bool bookmarkSupport = true); + explicit History (bool bookmarkSupport = true); void setProfileChangeListener (ProfileChangeListener* tpc_) { diff --git a/rtgui/ilabel.h b/rtgui/ilabel.h index aef5eb2ed..ab8f656cc 100644 --- a/rtgui/ilabel.h +++ b/rtgui/ilabel.h @@ -27,7 +27,7 @@ class ILabel : public Gtk::DrawingArea Glib::ustring label; public: - ILabel (Glib::ustring lab); + explicit ILabel (Glib::ustring lab); bool on_expose_event(GdkEventExpose* event); void on_realize(); void on_style_changed (const Glib::RefPtr& style); diff --git a/rtgui/imagearea.h b/rtgui/imagearea.h index bd2c19093..707729a6a 100644 --- a/rtgui/imagearea.h +++ b/rtgui/imagearea.h @@ -70,7 +70,7 @@ public: PreviewModePanel* previewModePanel; ImageArea* iLinkedImageArea; // used to set a reference to the Before image area, which is set when before/after view is enabled - ImageArea (ImageAreaPanel* p); + explicit ImageArea (ImageAreaPanel* p); ~ImageArea (); void setImProcCoordinator (rtengine::StagedImageProcessor* ipc_); diff --git a/rtgui/indclippedpanel.h b/rtgui/indclippedpanel.h index 199a9f620..3a6bc5296 100644 --- a/rtgui/indclippedpanel.h +++ b/rtgui/indclippedpanel.h @@ -30,7 +30,7 @@ protected: ImageArea* imageArea; public: - IndicateClippedPanel (ImageArea* ia); + explicit IndicateClippedPanel (ImageArea* ia); void buttonToggled (); diff --git a/rtgui/inspector.h b/rtgui/inspector.h index ce2da9aeb..4d275abd5 100644 --- a/rtgui/inspector.h +++ b/rtgui/inspector.h @@ -34,7 +34,7 @@ public: int currTransform; // coarse rotation from RT, not from shot orientation bool fromRaw; - InspectorBuffer(const Glib::ustring &imgagePath); + explicit InspectorBuffer(const Glib::ustring &imgagePath); //~InspectorBuffer(); }; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index f8d18ae57..503d6ee29 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -783,7 +783,7 @@ public: bool exif; bool iptc; - ParamsEdited (bool value = false); + explicit ParamsEdited (bool value = false); void set (bool v); void initFrom (const std::vector& src); diff --git a/rtgui/partialpastedlg.h b/rtgui/partialpastedlg.h index 7376e1481..57d77f532 100644 --- a/rtgui/partialpastedlg.h +++ b/rtgui/partialpastedlg.h @@ -132,7 +132,7 @@ public: sigc::connection raw_caredConn, raw_cablueConn, raw_ca_autocorrectConn, raw_hotpix_filtConn, raw_deadpix_filtConn, raw_linenoiseConn, raw_greenthreshConn, raw_ccStepsConn, raw_methodConn, raw_dcb_iterationsConn, raw_lmmse_iterationsConn, raw_dcb_enhanceConn, raw_exposConn, raw_preserConn, raw_blackConn; public: - PartialPasteDlg (Glib::ustring title); + explicit PartialPasteDlg (Glib::ustring title); void applyPaste (rtengine::procparams::ProcParams* dstPP, ParamsEdited* dstPE, const rtengine::procparams::ProcParams* srcPP, const ParamsEdited* srcPE = NULL); diff --git a/rtgui/popuptogglebutton.h b/rtgui/popuptogglebutton.h index 930fae4f2..58a7ff82a 100644 --- a/rtgui/popuptogglebutton.h +++ b/rtgui/popuptogglebutton.h @@ -28,7 +28,7 @@ class PopUpToggleButton : public Gtk::ToggleButton, public PopUpCommon { public: - PopUpToggleButton (const Glib::ustring& label = ""); + explicit PopUpToggleButton (const Glib::ustring& label = ""); void show (); void set_tooltip_text (const Glib::ustring &text); }; diff --git a/rtgui/preferences.h b/rtgui/preferences.h index 1cfb435cf..c9c5ca08c 100644 --- a/rtgui/preferences.h +++ b/rtgui/preferences.h @@ -229,7 +229,7 @@ protected: Gtk::Widget* getSoundPanel (); public: - Preferences (RTWindow *rtwindow); + explicit Preferences (RTWindow *rtwindow); ~Preferences (); void savePressed (); diff --git a/rtgui/previewmodepanel.h b/rtgui/previewmodepanel.h index 10906c30f..d3bf3c8e4 100644 --- a/rtgui/previewmodepanel.h +++ b/rtgui/previewmodepanel.h @@ -47,7 +47,7 @@ protected: Gtk::Image* iBC2, *igBC2; public: - PreviewModePanel (ImageArea* ia); + explicit PreviewModePanel (ImageArea* ia); ~PreviewModePanel(); void toggleR (); diff --git a/rtgui/profilepanel.h b/rtgui/profilepanel.h index 9bcc79196..f80438aac 100644 --- a/rtgui/profilepanel.h +++ b/rtgui/profilepanel.h @@ -69,7 +69,7 @@ protected: public: - ProfilePanel (bool readOnly = false); + explicit ProfilePanel (bool readOnly = false); virtual ~ProfilePanel (); void setProfileChangeListener (ProfileChangeListener* ppl) diff --git a/rtgui/profilestore.h b/rtgui/profilestore.h index d7b85b5f5..0304db330 100644 --- a/rtgui/profilestore.h +++ b/rtgui/profilestore.h @@ -108,7 +108,7 @@ public: * * @param entry Pointer to the ProfileStoreEntry object, be it a directory or a file */ - ProfileStoreLabel(const ProfileStoreEntry *entry); + explicit ProfileStoreLabel(const ProfileStoreEntry *entry); ProfileStoreLabel (const ProfileStoreLabel &other); }; diff --git a/rtgui/progressconnector.h b/rtgui/progressconnector.h index ffa4bee67..2e235fa82 100644 --- a/rtgui/progressconnector.h +++ b/rtgui/progressconnector.h @@ -32,7 +32,7 @@ class PLDBridge : public rtengine::ProgressListener rtengine::ProgressListener* pl; public: - PLDBridge ( rtengine::ProgressListener* pb) + explicit PLDBridge ( rtengine::ProgressListener* pb) : pl(pb) {} // ProgressListener interface diff --git a/rtgui/renamedlg.h b/rtgui/renamedlg.h index a5dec4efa..8de7fe013 100644 --- a/rtgui/renamedlg.h +++ b/rtgui/renamedlg.h @@ -55,7 +55,7 @@ protected: void fillTemplateList (); public: - RenameDialog (Gtk::Window* parent); + explicit RenameDialog (Gtk::Window* parent); void initName (const Glib::ustring& iname, const CacheImageData* cid); Glib::ustring getNewName (); @@ -79,7 +79,7 @@ protected: void refreshTemplateList (); public: - RenameTemplateEditor (Gtk::Window* parent); + explicit RenameTemplateEditor (Gtk::Window* parent); Glib::ustring getSelectedTemplate (); diff --git a/rtgui/saveasdlg.h b/rtgui/saveasdlg.h index 4727b574c..188d915fb 100644 --- a/rtgui/saveasdlg.h +++ b/rtgui/saveasdlg.h @@ -45,7 +45,7 @@ protected: void putToQueueClicked (); public: - SaveAsDialog (Glib::ustring initialDir); + explicit SaveAsDialog (Glib::ustring initialDir); Glib::ustring getFileName (); Glib::ustring getDirectory (); diff --git a/rtgui/splash.h b/rtgui/splash.h index 5e3d5e1b4..9fe6d8220 100644 --- a/rtgui/splash.h +++ b/rtgui/splash.h @@ -46,7 +46,7 @@ private: public: Splash (Gtk::Window& parent, int maxtime); - Splash (Gtk::Window& parent); + explicit Splash (Gtk::Window& parent); bool hasReleaseNotes() { diff --git a/rtgui/thumbbrowserentrybase.h b/rtgui/thumbbrowserentrybase.h index 1b7f0691a..59b2c022f 100644 --- a/rtgui/thumbbrowserentrybase.h +++ b/rtgui/thumbbrowserentrybase.h @@ -107,7 +107,7 @@ public: bool updatepriority; eWithFilename withFilename; - ThumbBrowserEntryBase (const Glib::ustring& fname); + explicit ThumbBrowserEntryBase (const Glib::ustring& fname); virtual ~ThumbBrowserEntryBase (); void setParent (ThumbBrowserBase* l) diff --git a/rtgui/zoompanel.h b/rtgui/zoompanel.h index aa4d9177f..bcfbc2b34 100644 --- a/rtgui/zoompanel.h +++ b/rtgui/zoompanel.h @@ -38,7 +38,7 @@ protected: public: - ZoomPanel (ImageArea* iarea); + explicit ZoomPanel (ImageArea* iarea); void zoomInClicked (); void zoomOutClicked (); From 3bef6cb8de11b1898b5587d75c8bd3829c560725 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 3 Oct 2016 01:56:22 +0200 Subject: [PATCH 05/13] Cppcheck: Fixed almost all performance hints --- rtengine/colortemp.cc | 2 +- rtengine/colortemp.h | 2 +- rtengine/ex2simple.cc | 150 ------------------------------------- rtengine/klt/convolve.cc | 4 +- rtengine/rawimagesource.cc | 2 +- rtengine/rawimagesource.h | 4 +- 6 files changed, 7 insertions(+), 157 deletions(-) delete mode 100644 rtengine/ex2simple.cc diff --git a/rtengine/colortemp.cc b/rtengine/colortemp.cc index 8d3847e79..2612d3148 100644 --- a/rtengine/colortemp.cc +++ b/rtengine/colortemp.cc @@ -1025,7 +1025,7 @@ void ColorTemp::cieCAT02(double Xw, double Yw, double Zw, double &CAM02BB00, dou } -void ColorTemp::temp2mulxyz (double tem, double gree, std::string method , double &Xxyz, double &Zxyz) +void ColorTemp::temp2mulxyz (double tem, double gree, const std::string &method, double &Xxyz, double &Zxyz) { double xD, yD, x_D, y_D, interm; double x, y, z; diff --git a/rtengine/colortemp.h b/rtengine/colortemp.h index cd3e422e9..33a2b1b04 100644 --- a/rtengine/colortemp.h +++ b/rtengine/colortemp.h @@ -92,7 +92,7 @@ public: } void mul2temp (const double rmul, const double gmul, const double bmul, const double equal, double& temp, double& green) const; - static void temp2mulxyz (double tem, double gree, std::string method, double &Xxyz, double &Zxyz); + static void temp2mulxyz (double tem, double gree, const std::string &method, double &Xxyz, double &Zxyz); static void cieCAT02(double Xw, double Yw, double Zw, double &CAM02BB00, double &CAM02BB01, double &CAM02BB02, double &CAM02BB10, double &CAM02BB11, double &CAM02BB12, double &CAM02BB20, double &CAM02BB21, double &CAM02BB22, double adap ); //static void CAT02 (Imagefloat* baseImg, const ProcParams* params); diff --git a/rtengine/ex2simple.cc b/rtengine/ex2simple.cc deleted file mode 100644 index 1a83526e7..000000000 --- a/rtengine/ex2simple.cc +++ /dev/null @@ -1,150 +0,0 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * RawTherapee is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * RawTherapee is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with RawTherapee. If not, see . - */ -#include "rtengine.h" -#include -//#include -#include - -class PListener : public rtengine::ProgressListener -{ - -public: - void setProgressStr (Glib::ustring str) - { - std::cout << str << std::endl; - } - void setProgress (double p) - { - std::cout << p << std::endl; - } -}; - -class MyPrevImgListener : public rtengine::PreviewImageListener -{ - - IImage8* i; - -public: - // this method is called when the staged image processor creates a new image to store the resulting preview image (this does not happen too often) - // usually you just have to store it - void setImage (IImage8* img, double scale, procparams::CropParams cp) - { - i = img; - } - // if the staged image processor wants to delete the image that stores the preview image, it calls this method. You have to destroy the image. - void delImage (IImage8* img) - { - if (img) { - // make sure we dont use this image in an other thread - IImage8* temp = i; - i->getMutex().lock (); - i = NULL; - temp->getMutex().unlock (); - // free it - img->free (); - } - } - // if the preview image changes, this method is called - void imageReady (procparams::CropParams cp) - { - // initiate a redraw in the background and return as fast as possible - } - // a possible redraw function: - //void redraw () { - // if (i) { - // i->lock (); - // int w = i->getWidth (); - // int h = i->getHeigt (); - // const char* data = i->getData (); - // ... draw it ... - // i->unlock (); - // } - // } -}; - -int main (int argc, char* argv[]) -{ - - if (argc < 4) { - std::cout << "Usage: rtcmd " << std::endl; - exit(1); - } - - Glib::thread_init (); - - // create and fill settings - rtengine::Settings* s = rtengine::Settings::create (); - s->demosaicMethod = "hphd"; - s->colorCorrectionSteps = 2; - s->iccDirectory = ""; - s->colorimetricIntent = 1; - s->monitorProfile = ""; - // init rtengine - rtengine::init (s); - // the settings can be modified later through the "s" pointer without calling any api function - - // Create a listener object. Any class is appropriate that inherits from rtengine::ProgressListener - PListener pl; - - // Load the image given in the first command line parameter - rtengine::InitialImage* ii; - int errorCode; - ii = rtengine::InitialImage::load (argv[1], true, errorCode, &pl); - - if (!ii) { - ii = rtengine::InitialImage::load (argv[1], false, errorCode, &pl); - } - - if (!ii) { - std::cout << "Input file not supported." << std::endl; - exit(2); - } - - /* Second scenario. Create a stagedimageprocessor with a preview scale of 1:5 and change few things */ - MyPrevImgListener myPrevImgListener; - - StagedImageProcessor* ipc = StagedImageProcessor::create (ii); - ipc->setProgressListener (&pl); - ipc->setPreviewImageListener (&myPrevImgListener); - ipc->setPreviewScale (5); // preview scale = 1:5 - // you can add a histogram listener, too, that is notified when the histogram changes - // ipc->setHistogramListener (...); - // you can add autoexplistener that is notified about the exposure settings when the auto exp algorithm finishes - // ipc->setAutoExpListener (curve); - // you can add sizelistener if you want to be notified when the size of the final image changes (due to rotation/resize/etc) - // ipc->setSizeListener (crop); - - // if you want to change the settings you have to ask for the procparams structure of the staged image processor - // you have to tell it what has changed. At the first time tell it EvPhotoLoaded so a full processing will be performed - rtengine::procparams::ProcParams* params = ipc->beginUpdateParams (); - // change this and that... - params->toneCurve.brightness = 1.0; - // you can load it, too, from a file: params->load (argv[2]); - // finally you have to call this non-blocking method, and the image processing starts in the background. When finished, the preview image listener will be notified - ipc->endUpdateParams (rtengine::EvPhotoLoaded); - // you can go on with changing of the settings, following the gui actions - // now we know that only the brightness has changed compared to the previous settings, to only a part of the processing has to be repeated - params = ipc->beginUpdateParams (); - params->toneCurve.brightness = 1.2; - ipc->endUpdateParams (rtengine::EvBrightness); - - // ... and so on. If you dont need it any more, you can destroy it (make sure that no processing is happening when you destroy it!) - StagedImageProcessor::destroy (ipc); -} - diff --git a/rtengine/klt/convolve.cc b/rtengine/klt/convolve.cc index b6041a7a6..7a2785cca 100644 --- a/rtengine/klt/convolve.cc +++ b/rtengine/klt/convolve.cc @@ -250,8 +250,8 @@ static void _convolveImageVert( static void _convolveSeparate( _KLT_FloatImage imgin, - ConvolutionKernel horiz_kernel, - ConvolutionKernel vert_kernel, + const ConvolutionKernel &horiz_kernel, + const ConvolutionKernel &vert_kernel, _KLT_FloatImage imgout) { /* Create temporary image */ diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index dcf7c1207..31deac244 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -4395,7 +4395,7 @@ void RawImageSource::HLRecovery_CIELab (float* rin, float* gin, float* bin, floa //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::hlRecovery (std::string method, float* red, float* green, float* blue, int width, float* hlmax ) +void RawImageSource::hlRecovery (const std::string &method, float* red, float* green, float* blue, int width, float* hlmax ) { if (method == "Luminance") { diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index 8f6552a74..60887d9cd 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -97,7 +97,7 @@ protected: void hphd_horizontal (float** hpmap, int row_from, int row_to); void hphd_green (float** hpmap); void processFalseColorCorrectionThread (Imagefloat* im, array2D &rbconv_Y, array2D &rbconv_I, array2D &rbconv_Q, array2D &rbout_I, array2D &rbout_Q, const int row_from, const int row_to); - void hlRecovery (std::string method, float* red, float* green, float* blue, int width, float* hlmax); + void hlRecovery (const std::string &method, float* red, float* green, float* blue, int width, float* hlmax); void transformRect (PreviewProps pp, int tran, int &sx1, int &sy1, int &width, int &height, int &fw); void transformPosition (int x, int y, int tran, int& tx, int& ty); @@ -186,7 +186,7 @@ public: void convertColorSpace(Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb); static bool findInputProfile(Glib::ustring inProfile, cmsHPROFILE embedded, std::string camName, DCPProfile **dcpProf, cmsHPROFILE& in); - static void colorSpaceConversion (Imagefloat* im, ColorManagementParams cmp, const ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], std::string camName) + static void colorSpaceConversion (Imagefloat* im, ColorManagementParams cmp, const ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], const std::string &camName) { colorSpaceConversion_ (im, cmp, wb, pre_mul, embedded, camprofile, cam, camName); } From 95027d2884d3613a023ce92f9a54addbb3934b5e Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 3 Oct 2016 17:56:31 +0200 Subject: [PATCH 06/13] Cppcheck: Fix most issues in rtengine/ipwavelet.cc --- rtengine/ipwavelet.cc | 137 ++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 92 deletions(-) diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index fd682d1d5..048f1b5d6 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -102,7 +102,6 @@ struct cont_params { int backm; float eddet; float eddetthr; - bool lips; float eddetthrHi; bool link; bool lip3; @@ -217,19 +216,12 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int cp.tmstrength = params->wavelet.tmrs; //cp.tonemap = params->wavelet.tmr; - cp.contena = true; cp.contena = params->wavelet.expcontrast; - cp.chromena = true; cp.chromena = params->wavelet.expchroma; - cp.edgeena = true; cp.edgeena = params->wavelet.expedge; - cp.resena = true; cp.resena = params->wavelet.expresid; - cp.finena = true; cp.finena = params->wavelet.expfinal; - cp.toningena = true; cp.toningena = params->wavelet.exptoning; - cp.noiseena = true; cp.noiseena = params->wavelet.expnoise; if(params->wavelet.Backmethod == "black") { @@ -490,7 +482,6 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int cp.lev3s = static_cast(params->wavelet.level3noise.value[0]); cp.lev3n = static_cast(params->wavelet.level3noise.value[1]); - cp.detectedge = false; cp.detectedge = params->wavelet.medianlev; //printf("low=%f mean=%f sd=%f max=%f\n",cp.edg_low,cp.edg_mean,cp.edg_sd,cp.edg_max); int minwin = min(imwidth, imheight); @@ -603,6 +594,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int //printf("levwav = %d\n",levwav); +#ifdef _OPENMP int numthreads = 1; int maxnumberofthreadsforwavelet = 0; @@ -640,7 +632,6 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int //printf("maxthre=%d\n",maxnumberofthreadsforwavelet); -#ifdef _OPENMP // Calculate number of tiles. If less than omp_get_max_threads(), then limit num_threads to number of tiles if( options.rgbDenoiseThreadLimit > 0) { @@ -674,10 +665,6 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int printf("Ip Wavelet uses %d main thread(s) and up to %d nested thread(s) for each main thread\n", numthreads, wavNestedLevels); } - -#endif - -#ifdef _OPENMP #pragma omp parallel num_threads(numthreads) #endif { @@ -880,7 +867,6 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int if(!Ldecomp->memoryAllocationFailed) { float madL[8][3]; - bool memoryAllocationFailed = false; #ifdef _RT_NESTED_OPENMP #pragma omp parallel for schedule(dynamic) collapse(2) num_threads(wavNestedLevels) if(wavNestedLevels>1) #endif @@ -922,18 +908,16 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int vari[1] = 8.f * SQR((cp.lev1n / 125.0) * (1.0 + cp.lev1n / 25.0)); vari[2] = 8.f * SQR((cp.lev2n / 125.0) * (1.0 + cp.lev2n / 25.0)); vari[3] = 8.f * SQR((cp.lev3n / 125.0) * (1.0 + cp.lev3n / 25.0)); - int edge = 1; if((cp.lev0n > 0.1f || cp.lev1n > 0.1f || cp.lev2n > 0.1f || cp.lev3n > 0.1f) && cp.noiseena) { + int edge = 1; vari[0] = max(0.0001f, vari[0]); vari[1] = max(0.0001f, vari[1]); vari[2] = max(0.0001f, vari[2]); vari[3] = max(0.0001f, vari[3]); float* noisevarlum = NULL; // we need a dummy to pass it to WaveletDenoiseAllL - if(!WaveletDenoiseAllL(*Ldecomp, noisevarlum, madL, vari, edge)) { // - memoryAllocationFailed = true; - } + WaveletDenoiseAllL(*Ldecomp, noisevarlum, madL, vari, edge); } ind = 1; @@ -987,7 +971,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int // printf("Levwava before: %d\n",levwava); if(cp.chrores == 0.f && params->wavelet.CLmethod == "all" && !cp.cbena) { // no processing of residual ab => we probably can reduce the number of levels - while(levwava > 0 && !cp.diag && (((cp.CHmet == 2 && (cp.chro == 0.f || cp.mul[levwava - 1] == 0.f )) || (cp.CHmet != 2 && (levwava == 10 || (!cp.curv || (cp.curv && cp.mulC[levwava - 1] == 0.f)))))) && (!cp.opaRG || levwava == 10 || (cp.opaRG && cp.mulopaRG[levwava - 1] == 0.f)) && ((levwava == 10 || (cp.CHSLmet == 1 && cp.mulC[levwava - 1] == 0.f)))) { + while(levwava > 0 && !cp.diag && (((cp.CHmet == 2 && (cp.chro == 0.f || cp.mul[levwava - 1] == 0.f )) || (cp.CHmet != 2 && (levwava == 10 || (!cp.curv || cp.mulC[levwava - 1] == 0.f))))) && (!cp.opaRG || levwava == 10 || (cp.opaRG && cp.mulopaRG[levwava - 1] == 0.f)) && ((levwava == 10 || (cp.CHSLmet == 1 && cp.mulC[levwava - 1] == 0.f)))) { levwava--; } } @@ -1008,7 +992,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int //printf("Levwavb before: %d\n",levwavb); if(cp.chrores == 0.f && params->wavelet.CLmethod == "all" && !cp.cbena) { // no processing of residual ab => we probably can reduce the number of levels - while(levwavb > 0 && !cp.diag && (((cp.CHmet == 2 && (cp.chro == 0.f || cp.mul[levwavb - 1] == 0.f )) || (cp.CHmet != 2 && (levwavb == 10 || (!cp.curv || (cp.curv && cp.mulC[levwavb - 1] == 0.f)))))) && (!cp.opaBY || levwavb == 10 || (cp.opaBY && cp.mulopaBY[levwavb - 1] == 0.f)) && ((levwavb == 10 || (cp.CHSLmet == 1 && cp.mulC[levwavb - 1] == 0.f)))) { + while(levwavb > 0 && !cp.diag && (((cp.CHmet == 2 && (cp.chro == 0.f || cp.mul[levwavb - 1] == 0.f )) || (cp.CHmet != 2 && (levwavb == 10 || (!cp.curv || cp.mulC[levwavb - 1] == 0.f))))) && (!cp.opaBY || levwavb == 10 || (cp.opaBY && cp.mulopaBY[levwavb - 1] == 0.f)) && ((levwavb == 10 || (cp.CHSLmet == 1 && cp.mulC[levwavb - 1] == 0.f)))) { levwavb--; } } @@ -1029,7 +1013,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int // printf("Levwavab before: %d\n",levwavab); if(cp.chrores == 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.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)))) { + 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--; } } @@ -1405,14 +1389,11 @@ void ImProcFunctions::Evaluate2(wavelet_decomposition &WaveletCoeffs_L, void ImProcFunctions::Eval2 (float ** WavCoeffs_L, int level, const struct cont_params& cp, int W_L, int H_L, int skip_L, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float *madL) { - const float eps = 0.01f; - float ava[4], avb[4], avLP[4], avLN[4]; - float maxL[4], minL[4], maxa[4], maxb[4]; + float avLP[4], avLN[4]; + float maxL[4], minL[4]; float sigP[4], sigN[4]; - float AvL, AvN, SL, SN, maxLP, maxLN, MADL; - float madLlev[10]; - float thr = params->wavelet.thres; + float AvL, AvN, SL, SN, maxLP, maxLN; for (int dir = 1; dir < 4; dir++) { Aver(WavCoeffs_L[dir], W_L * H_L, avLP[dir], avLN[dir], maxL[dir], minL[dir]); @@ -1425,7 +1406,6 @@ void ImProcFunctions::Eval2 (float ** WavCoeffs_L, int level, const struct cont SN = 0.f; maxLP = 0.f; maxLN = 0.f; - MADL = 0.f; for (int dir = 1; dir < 4; dir++) { AvL += avLP[dir]; @@ -1434,7 +1414,6 @@ void ImProcFunctions::Eval2 (float ** WavCoeffs_L, int level, const struct cont SN += sigN[dir]; maxLP += maxL[dir]; maxLN += minL[dir]; - MADL += madL[dir]; } AvL /= 3; @@ -1443,13 +1422,6 @@ void ImProcFunctions::Eval2 (float ** WavCoeffs_L, int level, const struct cont SN /= 3; maxLP /= 3; maxLN /= 3; - MADL /= 3; - - if(level < 4) { - MADL = sqrt(MADL); - } else { - MADL = 0.f; - } mean[level] = AvL; meanN[level] = AvN; @@ -1800,25 +1772,22 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * float maxkoeLi[12]; float *koeLibuffer = NULL; - bool lipschitz = true; - if(lipschitz == true) { - 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; - } + 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; + } + #ifdef _RT_NESTED_OPENMP #pragma omp parallel num_threads(wavNestedLevels) if(wavNestedLevels>1) #endif @@ -1922,7 +1891,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * // float eddlow=5.f + cp.edgampl/2.f;//settings->ed_low;//5 to 40 - if(cp.detectedge && lipschitz == true) { //enabled Lipschitz control...more memory..more time... + if(cp.detectedge) { //enabled Lipschitz control...more memory..more time... float *tmCBuffer = new float[H_L * W_L]; float *tmC[H_L]; @@ -2065,7 +2034,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs(lvl); - ContAllL (koeLi, maxkoeLi, lipschitz, maxlvl, labco, varhue, varchrom, WavCoeffs_L, WavCoeffs_L0, lvl, dir, cp, Wlvl_L, Hlvl_L, skip, mean, meanN, sigma, sigmaN, 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, meanN, sigma, sigmaN, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, ChCurve, Chutili); } @@ -2280,9 +2249,6 @@ void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float int Wlvl_ab = WaveletCoeffs_ab.level_W(lvl); int Hlvl_ab = WaveletCoeffs_ab.level_H(lvl); - - int skip_ab = WaveletCoeffs_ab.level_stride(lvl); - //printf("lev=%d skipL=%d skipab=%d\n",lvl, skip_L,skip_ab); float ** WavCoeffs_ab = WaveletCoeffs_ab.level_coeffs(lvl); ContAllAB (labco, maxlvl, varhue, varchrom, WavCoeffs_ab, WavCoeffs_ab0, lvl, dir, waOpacityCurveW, cp, Wlvl_ab, Hlvl_ab, useChannelA); } @@ -2621,7 +2587,6 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit scaleskip[sc] = scales[sc] / skip; } - float atten01234 = 0.80f; float t_r = settings->top_right; float t_l = settings->top_left; float b_r = settings->bot_right; @@ -2718,6 +2683,7 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float value = ((float)cp.val) / 8.f; //strength if (scaleskip[1] < 1.f) { + float atten01234 = 0.80f; value *= (atten01234 * scaleskip[1]); //for zoom < 100% reduce strength...I choose level 1...but!! } @@ -2869,9 +2835,9 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit kinterm = 1.f; float kc = kmul * (wavCLVCcurve[absciss * 500.f] - 0.5f); float kcd = kmuld * (wavCLVCcurve[absciss * 500.f] - 0.5f); - float reduceeffect = 0.6f; if(kc >= 0.f) { + float reduceeffect = 0.6f; kinterm = 1.f + reduceeffect * kmul * (wavCLVCcurve[absciss * 500.f] - 0.5f); //about 1 to 3 general and big amplification for max (under 0) } else { kinterm = 1.f - (SQR(kcd)) / 10.f; @@ -3064,10 +3030,10 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit mea[8] = mean[level] + 2.5f * sigma[level]; //99% bool useChromAndHue = (skinprot != 0.f || cp.HSmet); - float modchro, kLlev; + float modchro; for (int i = 0; i < W_L * H_L; i++) { - kLlev = 1.f; + float kLlev = 1.f; if(cpMul < 0.f) { beta = 1.f; // disabled for negatives values "less contrast" @@ -3217,15 +3183,13 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit it = itmoins; } else if(level == med) { it = 7; - } else if(level > med) { + } else /*if(level > med)*/ { it = itplus; } for(int j = 0; j < it; j++) { //float bal = cp.balan;//-100 +100 float kba = 1.f; - float k1; - float k2; // if(dir <3) kba= 1.f + bal/600.f; // if(dir==3) kba = 1.f - bal/300.f; @@ -3233,8 +3197,8 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit int ii = i / W_L; int jj = i - ii * W_L; float LL100 = labco->L[ii * 2][jj * 2] / 327.68f; - k1 = 0.3f * (waOpacityCurveW[6.f * LL100] - 0.5f); //k1 between 0 and 0.5 0.5==> 1/6=0.16 - k2 = k1 * 2.f; + float k1 = 0.3f * (waOpacityCurveW[6.f * LL100] - 0.5f); //k1 between 0 and 0.5 0.5==> 1/6=0.16 + float k2 = k1 * 2.f; if(dir < 3) { kba = 1.f + k1; @@ -3260,23 +3224,21 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit it = itmoins; } else if(level == med) { it = 7; - } else if(level > med) { + } else /*if(level > med)*/ { it = itplus; } for(int j = 0; j < it; j++) { float bal = cp.balan;//-100 +100 float kba = 1.f; - float k1; - float k2; // if(dir <3) kba= 1.f + bal/600.f; // if(dir==3) kba = 1.f - bal/300.f; for (int i = 0; i < W_L * H_L; i++) { int ii = i / W_L; int jj = i - ii * W_L; - k1 = 600.f; - k2 = 300.f; + float k1 = 600.f; + float k2 = 300.f; float LL100 = labco->L[ii * 2][jj * 2] / 327.68f; float aa = 4970.f; float bb = -397000.f; @@ -3362,7 +3324,6 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, // if( (cp.curv || cp.CHSLmet==1) && cp.CHmet!=2 && level < 9 && cpMulC != 0.f) { // cpMulC == 0.f means all will be multiplied by 1.f, so we can skip if( cp.CHmet != 2 && level < 9 && cpMulC != 0.f && cp.chromena) { // cpMulC == 0.f means all will be multiplied by 1.f, so we can skip - float modchro, modhue, kClev; const float skinprot = params->wavelet.skinprotect; const float skinprotneg = -skinprot; const float factorHard = (1.f - skinprotneg / 100.f); @@ -3372,15 +3333,13 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, int ii = i / W_ab; int jj = i - ii * W_ab; //WL and W_ab are identical - float LL = labco->L[ii * 2][jj * 2]; - float LL100 = LL / 327.68f; float scale = 1.f; - modchro = varchrom[ii * 2][jj * 2]; + float modchro = varchrom[ii * 2][jj * 2]; if(useSkinControl) { // hue chroma skin with initial lab datas - modhue = varhue[ii][jj]; - scale = 1.f; + float LL100 = labco->L[ii * 2][jj * 2] / 327.68f; + float modhue = varhue[ii][jj]; if(skinprot > 0.f) { Color::SkinSatCbdl2 (LL100, modhue, modchro, skinprot, scale, true, cp.b_l, cp.t_l, cp.t_r, cp.b_r, 1); //1 for curve @@ -3396,7 +3355,7 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, beta = 0.02f; } - kClev = beta; + float kClev = beta; if(cp.CHmet == 1) { if(level < cp.chrom) { @@ -3478,15 +3437,13 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, it = itmoins; } else if(level == med) { it = 7; - } else if(level > med) { + } else /*if(level > med)*/ { it = itplus; } for(int j = 0; j < it; j++) { //float bal = cp.balan;//-100 +100 float kba = 1.f; - float k1; - float k2; // if(dir <3) kba= 1.f + bal/600.f; // if(dir==3) kba = 1.f - bal/300.f; @@ -3494,8 +3451,8 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, int ii = i / W_ab; int jj = i - ii * W_ab; float LL100 = labco->L[ii * 2][jj * 2] / 327.68f; - k1 = 0.3f * (waOpacityCurveW[6.f * LL100] - 0.5f); //k1 between 0 and 0.5 0.5==> 1/6=0.16 - k2 = k1 * 2.f; + float k1 = 0.3f * (waOpacityCurveW[6.f * LL100] - 0.5f); //k1 between 0 and 0.5 0.5==> 1/6=0.16 + float k2 = k1 * 2.f; if(dir < 3) { kba = 1.f + k1; @@ -3521,23 +3478,21 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, it = itmoins; } else if(level == med) { it = 7; - } else if(level > med) { + } else /*if(level > med)*/ { it = itplus; } for(int j = 0; j < it; j++) { float bal = cp.balan;//-100 +100 float kba = 1.f; - float k1; - float k2; // if(dir <3) kba= 1.f + bal/600.f; // if(dir==3) kba = 1.f - bal/300.f; for (int i = 0; i < W_ab * H_ab; i++) { int ii = i / W_ab; int jj = i - ii * W_ab; - k1 = 600.f; - k2 = 300.f; + float k1 = 600.f; + float k2 = 300.f; float LL100 = labco->L[ii * 2][jj * 2] / 327.68f; float aa = 4970.f; float bb = -397000.f; @@ -3606,10 +3561,8 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, if(choiceClevel < 3) { // not all levels visible, paint residual if(level == 0) { if(cp.backm != 2) { // nothing to change when residual is used as background - float backGroundChroma = (cp.backm == 1) ? 0.f : 0.f; //we can change first to colorized... - for (int i = 0; i < W_ab * H_ab; i++) { - WavCoeffs_ab0[i] = backGroundChroma; + WavCoeffs_ab0[i] = 0.f; } } } From 260cd290fb1aa67c73a8d925b3ee8c19832ac936 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 3 Oct 2016 21:01:26 +0200 Subject: [PATCH 07/13] Cppcheck: Fix most issues in rtexif/* --- rtexif/canonattribs.cc | 5 +++-- rtexif/nikonattribs.cc | 22 +++++++++++----------- rtexif/pentaxattribs.cc | 2 +- rtexif/rtexif.cc | 14 ++++---------- rtexif/rtexif.h | 3 ++- rtexif/sonyminoltaattribs.cc | 16 ++++++++-------- 6 files changed, 29 insertions(+), 33 deletions(-) diff --git a/rtexif/canonattribs.cc b/rtexif/canonattribs.cc index bd14c6514..41ab468cb 100644 --- a/rtexif/canonattribs.cc +++ b/rtexif/canonattribs.cc @@ -101,7 +101,7 @@ public: } char buffer[32]; - sprintf (buffer, "%.1fs %s", sec / 10., sec & 0x4000 ? ",Custom" : ""); + sprintf (buffer, "%.1fs %s", sec / 10., (sec & 0x4000) ? ",Custom" : ""); return buffer; } }; @@ -965,7 +965,7 @@ public: std::ostringstream candidates; for (r = choices.lower_bound(lensID); r != choices.upper_bound(lensID); r++) { - double a1, a2, f1, f2, lensAperture, dif; + double a1, a2, f1, f2, dif; if( !extractLensInfo( r->second , f1, f2, a1, a2) ) { continue; @@ -988,6 +988,7 @@ public: } if( maxApertureAtFocal > 0.1) { + double lensAperture; if( maxApertureAtFocal < a1 - 0.15 || maxApertureAtFocal > a2 + 0.15) { continue; } diff --git a/rtexif/nikonattribs.cc b/rtexif/nikonattribs.cc index 38f4ce1f0..a827eb1fe 100644 --- a/rtexif/nikonattribs.cc +++ b/rtexif/nikonattribs.cc @@ -147,10 +147,10 @@ public: { int a = t->toInt(); std::ostringstream str; - str << "MF = " << (a & 1 ? "Yes" : "No") << std::endl; - str << "D = " << (a & 2 ? "Yes" : "No") << std::endl; - str << "G = " << (a & 4 ? "Yes" : "No") << std::endl; - str << "VR = " << (a & 8 ? "Yes" : "No"); + str << "MF = " << ((a & 1) ? "Yes" : "No") << std::endl; + str << "D = " << ((a & 2) ? "Yes" : "No") << std::endl; + str << "G = " << ((a & 4) ? "Yes" : "No") << std::endl; + str << "VR = " << ((a & 8) ? "Yes" : "No"); return str.str(); } }; @@ -196,13 +196,13 @@ public: { int a = t->toInt(); std::ostringstream str; - str << "Continuous = " << (a & 1 ? "Yes" : "No") << std::endl; - str << "Delay = " << (a & 2 ? "Yes" : "No") << std::endl; - str << "PC Control = " << (a & 4 ? "Yes" : "No") << std::endl; - str << "White-Balance Bracketing = " << (a & 8 ? "Yes" : "No") << std::endl; - str << "Exposure Bracketing = " << (a & 16 ? "Yes" : "No") << std::endl; - str << "Auto ISO = " << (a & 32 ? "Yes" : "No") << std::endl; - str << "IR Control = " << (a & 64 ? "Yes" : "No"); + str << "Continuous = " << ((a & 1) ? "Yes" : "No") << std::endl; + str << "Delay = " << ((a & 2) ? "Yes" : "No") << std::endl; + str << "PC Control = " << ((a & 4) ? "Yes" : "No") << std::endl; + str << "White-Balance Bracketing = " << ((a & 8) ? "Yes" : "No") << std::endl; + str << "Exposure Bracketing = " << ((a & 16) ? "Yes" : "No") << std::endl; + str << "Auto ISO = " << ((a & 32) ? "Yes" : "No") << std::endl; + str << "IR Control = " << ((a & 64) ? "Yes" : "No"); return str.str(); } }; diff --git a/rtexif/pentaxattribs.cc b/rtexif/pentaxattribs.cc index f88e650ec..4d3cef90d 100644 --- a/rtexif/pentaxattribs.cc +++ b/rtexif/pentaxattribs.cc @@ -1911,12 +1911,12 @@ public: PAAFPointSelectedInterpreter() {} virtual std::string toString (Tag* t) { - const char *ps[] = {"Upper-left", "Top", "Upper-right", "Left", "Mid-left", "Center", "Mid-right", "Right", "Lower-left", "Bottom", "Lower-right"}; int c = t->toInt(0, SHORT); if( !c ) { return "Auto"; } else { + const char *ps[] = {"Upper-left", "Top", "Upper-right", "Left", "Mid-left", "Center", "Mid-right", "Right", "Lower-left", "Bottom", "Lower-right"}; for( int iBit = 0; iBit < 11; iBit++) if( c & (1 << iBit) ) { return ps[iBit]; diff --git a/rtexif/rtexif.cc b/rtexif/rtexif.cc index 91f52ce55..a13e9cae8 100644 --- a/rtexif/rtexif.cc +++ b/rtexif/rtexif.cc @@ -207,13 +207,11 @@ void TagDirectory::printAll (unsigned int level) const for (size_t i = 0; i < tags.size(); i++) { std::string name = tags[i]->nameToString (); - if (tags[i]->isDirectory()) + if (tags[i]->isDirectory()) { for (int j = 0; tags[i]->getDirectory(j); j++) { printf ("%s+-- DIRECTORY %s[%d]:\n", prefixStr, name.c_str(), j); tags[i]->getDirectory(j)->printAll (level + 1); } - else { - std::string value = tags[i]->valueToString (); } } } @@ -696,7 +694,7 @@ void TagDirectory::applyChange (std::string name, std::string value) } TagDirectoryTable::TagDirectoryTable () - : zeroOffset(0), valuesSize(0) + : values(nullptr), zeroOffset(0), valuesSize(0), defaultType(INVALID) { } @@ -1269,9 +1267,8 @@ Tag::~Tag () } // if there are directories behind the tag, delete them - int i = 0; - if (directory) { + int i = 0; while (directory[i]) { delete directory[i++]; } @@ -1600,11 +1597,10 @@ std::string Tag::nameToString (int i) std::string Tag::valueToString () { - char buffer[1024]; - if (attrib && attrib->interpreter) { return attrib->interpreter->toString (this); } else { + char buffer[1024]; toString (buffer); return buffer; } @@ -2831,7 +2827,6 @@ int ExifManager::createJPEGMarker (const TagDirectory* root, const rtengine::pro sset2 (42, buffer + offs, order); offs += 2; sset4 (8, buffer + offs, order); - offs += 4; TagDirectory* cl; @@ -2964,7 +2959,6 @@ int ExifManager::createTIFFHeader (const TagDirectory* root, const rtengine::pro sset2 (42, buffer + offs, order); offs += 2; sset4 (8, buffer + offs, order); - offs += 4; int endOffs = cl->write (8, buffer); diff --git a/rtexif/rtexif.h b/rtexif/rtexif.h index fcccd1161..ea57ada73 100644 --- a/rtexif/rtexif.h +++ b/rtexif/rtexif.h @@ -535,7 +535,7 @@ protected: double deltaMin = 1000.; for ( r = choices.lower_bound( lensID ); r != choices.upper_bound(lensID); ++r ) { - double lensAperture, dif; + double dif; if( !extractLensInfo( r->second , f1, f2, a1, a2) ) { continue; @@ -550,6 +550,7 @@ protected: } if( maxApertureAtFocal > 0.1) { + double lensAperture; if( maxApertureAtFocal < a1 - 0.15 || maxApertureAtFocal > a2 + 0.15) { continue; } diff --git a/rtexif/sonyminoltaattribs.cc b/rtexif/sonyminoltaattribs.cc index 7f4e1bb53..80db5018f 100644 --- a/rtexif/sonyminoltaattribs.cc +++ b/rtexif/sonyminoltaattribs.cc @@ -1966,7 +1966,7 @@ public: { // Get the value; Depending on the camera model, this parameter can be a BYTE or a SHORT TagType astype = t->getType(); - int a; + int a = 0; if (astype == BYTE) { a = t->getValue()[ofs]; @@ -1975,7 +1975,7 @@ public: } // Decode the value - if(a > 0.) { + if(a > 0) { return pow(2., 6. - (double(a) / 8.)); } else { return 0.; @@ -1984,7 +1984,7 @@ public: virtual int toInt (Tag* t, int ofs, TagType astype) { // Get the value; Depending on the camera model, this parameter can be a BYTE or a SHORT - int a; + int a = 0; if (astype == INVALID || astype == AUTO) { astype = t->getType(); @@ -2026,7 +2026,7 @@ public: { // Get the value; Depending on the camera model, this parameter can be a BYTE or a SHORT TagType astype = t->getType(); - int a; + int a = 0; if (astype == BYTE) { a = t->getValue()[ofs]; @@ -2035,7 +2035,7 @@ public: } // Decode the value - if(a > 0.) { + if(a > 0) { return pow(2., (double(a) / 8. - 1.) / 2.); } else { return 0.; @@ -2044,7 +2044,7 @@ public: virtual int toInt (Tag* t, int ofs, TagType astype) { // Get the value; Depending on the camera model, this parameter can be a BYTE or a SHORT - int a; + int a = 0; if (astype == INVALID || astype == AUTO) { astype = t->getType(); @@ -2085,7 +2085,7 @@ public: virtual int toInt (Tag* t, int ofs, TagType astype) { // Get the value; Depending on the camera model, this parameter can be a BYTE or a SHORT - int a; + int a = 0; if (astype == INVALID || astype == AUTO) { astype = t->getType(); @@ -2235,7 +2235,7 @@ public: } virtual int toInt (Tag* t, int ofs, TagType astype) { - int a; + int a = 0; if (astype == INVALID || astype == AUTO) { astype = t->getType(); From 01048ee513534082d71e219a92813250874130c8 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 3 Oct 2016 21:17:27 +0200 Subject: [PATCH 08/13] Cppcheck: Fixed all issues in rtengine/ alignedbuffer.h, colortemp.cc, dcrop.cc, simpleprocess.cc --- rtengine/alignedbuffer.h | 10 +++++- rtengine/colortemp.cc | 70 +++++++++++++++++---------------------- rtengine/dcrop.cc | 2 +- rtengine/simpleprocess.cc | 39 ++++++++++------------ 4 files changed, 58 insertions(+), 63 deletions(-) diff --git a/rtengine/alignedbuffer.h b/rtengine/alignedbuffer.h index fbbf83523..652bfe8cf 100644 --- a/rtengine/alignedbuffer.h +++ b/rtengine/alignedbuffer.h @@ -93,7 +93,15 @@ public: // we're freeing the memory and allocate it again if the new size is bigger. if (allocatedSize < oldAllocatedSize) { - real = realloc(real, allocatedSize + alignment); + void *temp = realloc(real, allocatedSize + alignment); + if (temp) { // realloc succeeded + real = temp; + } else { // realloc failed => free old buffer and allocate new one + if (real) { + free (real); + } + real = malloc(allocatedSize + alignment); + } } else { if (real) { free (real); diff --git a/rtengine/colortemp.cc b/rtengine/colortemp.cc index 2612d3148..b013d672d 100644 --- a/rtengine/colortemp.cc +++ b/rtengine/colortemp.cc @@ -1100,7 +1100,7 @@ void ColorTemp::temp2mulxyz (double tem, double gree, const std::string &method, x_D = -4.6070e9 / (tem * tem * tem) + 2.9678e6 / (tem * tem) + 0.09911e3 / tem + 0.244063; } else if (tem <= 25000) { x_D = -2.0064e9 / (tem * tem * tem) + 1.9018e6 / (tem * tem) + 0.24748e3 / tem + 0.237040; - } else if (tem > 25000) { + } else /*if (tem > 25000)*/ { x_D = -2.0064e9 / (tem * tem * tem) + 1.9018e6 / (tem * tem) + 0.24748e3 / tem + 0.237040 - ((tem - 25000) / 25000) * 0.025; //Jacques empirical adjustemnt for very high temp (underwater !) } @@ -1135,12 +1135,10 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, //printf("temp=%d green=%.3f equal=%.3f\n", (int)temp, (float) green, (float) equal); //variables for CRI and display Lab, and palette - bool CRI_type = false; double xD, yD, x_D, y_D, interm; double m1, m2; - double xp, yp; - double x, y, z, xx, yy, zz; + double x, y, z; double Xchk[50], Ychk[50], Zchk[50]; //50 : I think it's a good limit for number of color : for CRI and Palette double Xcam02[50], Ycam02[50], Zcam02[50]; double Xcam02pal[50], Ycam02pal[50], Zcam02pal[50]; @@ -1148,16 +1146,12 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double XchkLamp[50], YchkLamp[50], ZchkLamp[50]; double Xcam02Lamp[50], Ycam02Lamp[50], Zcam02Lamp[50]; double Xpal[50], Ypal[50], Zpal[50]; - double tempw; const double epsilon = 0.008856; //Lab const double whiteD50[3] = {0.9646019585, 1.0, 0.8244507152}; //calculate with this tool : spect 5nm double CAM02BB00, CAM02BB01, CAM02BB02, CAM02BB10, CAM02BB11, CAM02BB12, CAM02BB20, CAM02BB21, CAM02BB22; //for CIECAT02 double xr[50], yr[50], zr[50]; double fx[50], fy[50], fz[50]; - double Llamp[50], alamp[50], blamp[50]; - double Lbb[50], abb[50], bbb[50]; - double Lpal[50], apal[50], bpal[50]; int palet = -1; bool palette = false; @@ -1263,7 +1257,7 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, x_D = -4.6070e9 / (temp * temp * temp) + 2.9678e6 / (temp * temp) + 0.09911e3 / temp + 0.244063; } else if (temp <= 25000) { x_D = -2.0064e9 / (temp * temp * temp) + 1.9018e6 / (temp * temp) + 0.24748e3 / temp + 0.237040; - } else if (temp > 25000) { // above 25000 it's unknown..then I have modified to adjust for underwater + } else /*if (temp > 25000)*/ { // above 25000 it's unknown..then I have modified to adjust for underwater x_D = -2.0064e9 / (temp * temp * temp) + 1.9018e6 / (temp * temp) + 0.24748e3 / temp + 0.237040 - ((temp - 25000) / 25000) * 0.025; //Jacques empirical adjustemnt for very high temp (underwater !) } @@ -1291,8 +1285,6 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double Xwb = xD / yD; double Ywb = 1.0; double Zwb = (1.0 - xD - yD) / yD; - double correl_temp; - if (settings->verbose) { // double u=4*xD/(-2*xD+12*yD+3); @@ -1335,11 +1327,6 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, { double x_x, y_y, z_z; // illuminants - const double* spect_illummax[] = { - Daylight5300_spect, Cloudy6200_spect, Shade7600_spect, A2856_spect, FluoF1_spect, FluoF2_spect, FluoF3_spect, FluoF4_spect, FluoF5_spect, FluoF6_spect, FluoF7_spect, - FluoF8_spect, FluoF9_spect, FluoF10_spect, FluoF11_spect, FluoF12_spect, HMI_spect, GTI_spect, JudgeIII_spect, Solux3500_spect, Solux4100_spect, Solux4700_spect, NG_Solux4700_spect, NG_CRSSP12WWMR16_spect, NG_CRSSP12WWMR16_spect, - Flash5500_spect, Flash6000_spect, Flash6500_spect - }; // color const double* spec_colorpalet[] = { ColabSkin98_m2_10_spect, ColabSkin95_0_4_spect, ColabSkin91_4_14_spect, ColabSkin90_m1_20_spect, @@ -1359,13 +1346,18 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, int N_col = sizeof(spec_colorpalet) / sizeof(spec_colorpalet[0]); //number of color if(palet < 28) { + const double* spect_illummax[] = { + Daylight5300_spect, Cloudy6200_spect, Shade7600_spect, A2856_spect, FluoF1_spect, FluoF2_spect, FluoF3_spect, FluoF4_spect, FluoF5_spect, FluoF6_spect, FluoF7_spect, + FluoF8_spect, FluoF9_spect, FluoF10_spect, FluoF11_spect, FluoF12_spect, HMI_spect, GTI_spect, JudgeIII_spect, Solux3500_spect, Solux4100_spect, Solux4700_spect, NG_Solux4700_spect, NG_CRSSP12WWMR16_spect, NG_CRSSP12WWMR16_spect, + Flash5500_spect, Flash6000_spect, Flash6500_spect + }; for(int i = 0; i < N_col; i++) { spectrum_to_color_xyz_preset(spec_colorpalet[i], spect_illummax[palet], x_x, y_y, z_z); Xpal[i] = x_x; Ypal[i] = y_y; Zpal[i] = z_z; } - } else if(palet >= 28) { + } else /*if(palet >= 28)*/ { if(temp < INITIALBLACKBODY) { for(int i = 0; i < N_col; i++) { spectrum_to_color_xyz_blackbody(spec_colorpalet[i], temp, x_x, y_y, z_z); @@ -1387,8 +1379,8 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, } } - xp = xD; - yp = yD; + double xp = xD; + double yp = yD; double Xwbpal = xp / yp; //white balance double Ywbpal = 1.0; double Zwbpal = (1.0 - xp - yp) / yp; @@ -1433,6 +1425,8 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, //Lab values in function of color and illuminant //these values can be compared to preview values when using white-balance (skin / sky / BW) + double Lpal[50], apal[50], bpal[50]; + for(int i = 0; i < N_col; i++) { Lpal[i] = 116.0 * fy[i] - 16.0; apal[i] = 500.0 * (fx[i] - fy[i]); @@ -1464,12 +1458,6 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, int numero_color = settings->CRI_color - 1; //spectral data illuminant (actually 21): only those necessary (lamp, fluorescent, LED) others CRI=100 (not Flash...) - const double* spect_illum[] = { - Daylight5300_spect, Cloudy6200_spect, Shade7600_spect, A2856_spect, FluoF1_spect, FluoF2_spect, FluoF3_spect, - FluoF4_spect, FluoF5_spect, FluoF6_spect, FluoF7_spect, FluoF8_spect, FluoF9_spect, FluoF10_spect, FluoF11_spect, - FluoF12_spect, HMI_spect, GTI_spect, JudgeIII_spect, Solux3500_spect, Solux4100_spect, Solux4700_spect, - NG_Solux4700_spect, NG_CRSSP12WWMR16_spect, NG_CRSSP12WWMR16_spect - }; const double* spec_color[] = { ColorchechredC3_spect, ColorchechOraA2_spect, ColorchechYelD3_spect, ColorchechGreE2_spect, ColorchechGreB3_spect, ColorchechCyaF3_spect, ColorchechPurD2_spect, ColorchechMagE3_spect, ColorchechSkiA138_13_14_spect, ColorchechGraC4_67_spect, @@ -1480,6 +1468,9 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, int N_c = sizeof(spec_color) / sizeof(spec_color[0]); //number of color + bool CRI_type = false; + double tempw; + if (method == "Fluo F1") { CRI_type = true; tempw = 6430; @@ -1569,25 +1560,26 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, } if (CRI_type) { + const double* spect_illum[] = { + Daylight5300_spect, Cloudy6200_spect, Shade7600_spect, A2856_spect, FluoF1_spect, FluoF2_spect, FluoF3_spect, + FluoF4_spect, FluoF5_spect, FluoF6_spect, FluoF7_spect, FluoF8_spect, FluoF9_spect, FluoF10_spect, FluoF11_spect, + FluoF12_spect, HMI_spect, GTI_spect, JudgeIII_spect, Solux3500_spect, Solux4100_spect, Solux4700_spect, + NG_Solux4700_spect, NG_CRSSP12WWMR16_spect, NG_CRSSP12WWMR16_spect + }; + float DeltaE[50], DeltaEs[8]; float quadCRI = 0.0f, quadCRIs = 0.0f; float CRI_RT = 0.0, CRI[50]; float CRI_RTs = 0.0, CRIs[8]; for(int i = 0; i < N_c; i++) { - spectrum_to_color_xyz_preset(spec_color[i], spect_illum[illum + 3], xx, yy, zz); - XchkLamp[i] = xx; - YchkLamp[i] = yy; - ZchkLamp[i] = zz; + spectrum_to_color_xyz_preset(spec_color[i], spect_illum[illum + 3], XchkLamp[i], YchkLamp[i], ZchkLamp[i]); } //calculate XYZ for each color : for Blackbody and Daylight at tempw if(tempw <= INITIALBLACKBODY) { for(int i = 0; i < N_c; i++) { - spectrum_to_color_xyz_blackbody(spec_color[i], tempw, xx, yy, zz); - Xchk[i] = xx; - Ychk[i] = yy; - Zchk[i] = zz; + spectrum_to_color_xyz_blackbody(spec_color[i], tempw, Xchk[i], Ychk[i], Zchk[i]); } spectrum_to_xyz_blackbody(tempw, x, y, z);//for white point @@ -1608,18 +1600,15 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, m22 = (0.03 - 31.4424 * x_DD + 30.0717 * y_DD) / interm2; for(int i = 0; i < N_c; i++) { - spectrum_to_color_xyz_daylight(spec_color[i], m11, m22, xx, yy, zz); - Xchk[i] = xx; - Ychk[i] = yy; - Zchk[i] = zz; + spectrum_to_color_xyz_daylight(spec_color[i], m11, m22, Xchk[i], Ychk[i], Zchk[i]); } spectrum_to_xyz_daylight(m11, m22, x, y, z); } - XYZtoCorColorTemp(Xwb, Ywb, Zwb, correl_temp); - if (settings->verbose) { + double correl_temp; + XYZtoCorColorTemp(Xwb, Ywb, Zwb, correl_temp); printf("Correlated temperature (lamp)=%i\n", (int) correl_temp); //use only for lamp...otherwise It give an information!! } @@ -1680,6 +1669,7 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, } } + double Llamp[50], alamp[50], blamp[50]; for(int i = 0; i < N_c; i++) { Llamp[i] = 116.0 * fy[i] - 16.0; alamp[i] = 500.0 * (fx[i] - fy[i]); @@ -1712,6 +1702,8 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, } } + double Lbb[50], abb[50], bbb[50]; + for(int i = 0; i < N_c; i++) { Lbb[i] = 116.*fy[i] - 16.; abb[i] = 500.*(fx[i] - fy[i]); diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index b2c2f03f1..ac8b6fc0e 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -33,7 +33,7 @@ extern const Settings* settings; Crop::Crop (ImProcCoordinator* parent, EditDataProvider *editDataProvider, bool isDetailWindow) : PipetteBuffer(editDataProvider), origCrop(NULL), laboCrop(NULL), labnCrop(NULL), cropImg(NULL), cbuf_real(NULL), cshmap(NULL), transCrop(NULL), cieCrop(NULL), cbuffer(NULL), - updating(false), newUpdatePending(false), skip(10), + updating(false), newUpdatePending(false), skip(10), padding(0), cropx(0), cropy(0), cropw(-1), croph(-1), trafx(0), trafy(0), trafw(-1), trafh(-1), rqcropx(0), rqcropy(0), rqcropw(-1), rqcroph(-1), diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index e12121d07..c16960041 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -996,13 +996,12 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p } } - int kall = 2; bool wavcontlutili = false; CurveFactory::curveWavContL(wavcontlutili, params.wavelet.wavclCurve, wavclCurve,/* hist16C, dummy,*/ 1); - if((params.wavelet.enabled)) { - ipf.ip_wavelet(labView, labView, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, wavcontlutili, 1); + if(params.wavelet.enabled) { + ipf.ip_wavelet(labView, labView, 2, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, wavcontlutili, 1); } wavCLVCurve.Reset(); @@ -1053,25 +1052,19 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p float CAMMean = NAN; if (params.sharpening.enabled) { - float d; - double dd; - - int sk = 1; - if(settings->ciecamfloat) { - ipf.ciecam_02float (cieView, float(adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, sk, 1); + float d; + ipf.ciecam_02float (cieView, float(adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, 1, 1); } else { + double dd; ipf.ciecam_02 (cieView, adap, begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, 1, 1); } } else { - float d; - - double dd; - int sk = 1; - if(settings->ciecamfloat) { - ipf.ciecam_02float (cieView, float(adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, sk, 1); + float d; + ipf.ciecam_02float (cieView, float(adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, 1, 1); } else { + double dd; ipf.ciecam_02 (cieView, adap, begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, 1, 1); } } @@ -1160,10 +1153,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p bool useLCMS = false; if(params.icm.gamma != "default" || params.icm.freegamma) { // if select gamma output between BT709, sRGB, linear, low, high, 2.2 , 1.8 - cmsMLU *DescriptionMLU, *CopyrightMLU, *DmndMLU, *DmddMLU;// for modification TAG - cmsToneCurve* GammaTRC[3] = { NULL, NULL, NULL }; - cmsFloat64Number Parameters[7]; double ga0, ga1, ga2, ga3, ga4, ga5, ga6; // if(params.blackwhite.enabled) params.toneCurve.hrenabled=false; readyImg = ipf.lab2rgb16b (labView, cx, cy, cw, ch, params.icm.output, params.icm.outputIntent, params.icm.working, params.icm.gamma, params.icm.freegamma, params.icm.gampos, params.icm.slpos, ga0, ga1, ga2, ga3, ga4, ga5, ga6, params.blackwhite.enabled ); @@ -1266,6 +1256,10 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p printf("\"%s\" ICC output profile not found!\n", outProfile.c_str()); } } else { + cmsToneCurve* GammaTRC[3] = { NULL, NULL, NULL }; + + cmsFloat64Number Parameters[7]; + Parameters[0] = ga0; Parameters[1] = ga1; Parameters[2] = ga2; @@ -1275,6 +1269,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p Parameters[6] = ga6; // 7 parameters for smoother curves //change desc Tag , to "free gamma", or "BT709", etc. + cmsMLU *DescriptionMLU, *CopyrightMLU, *DmndMLU, *DmddMLU;// for modification TAG + cmsContext ContextID = cmsGetProfileContextID(jprof);//modification TAG DescriptionMLU = cmsMLUalloc(ContextID, 1); CopyrightMLU = cmsMLUalloc(ContextID, 1);//for ICC @@ -1344,13 +1340,12 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p // else if (params.icm.gamma== "sRGB_g2.4_s12.92") cmsSaveProfileToFile(jprof, "RT_Medium_gsRGB.icc"); // else if (params.icm.gamma== "linear_g1.0") cmsSaveProfileToFile(jprof, "RT_Large_g10.icc"); - + if (GammaTRC[0]) { + cmsFreeToneCurve(GammaTRC[0]); + } } } - if (GammaTRC[0]) { - cmsFreeToneCurve(GammaTRC[0]); - } } else { // if Default gamma mode: we use the profile selected in the "Output profile" combobox; // gamma come from the selected profile, otherwise it comes from "Free gamma" tool From 566d4c982224194b16e158235744c866106f22f5 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Tue, 4 Oct 2016 23:28:19 +0200 Subject: [PATCH 09/13] Cppcheck: Fixed most issued in rtgui/* --- rtgui/adjuster.cc | 3 +- rtgui/batchqueuepanel.cc | 4 - rtgui/browserfilter.cc | 3 +- rtgui/cacheimagedata.cc | 4 +- rtgui/clipboard.cc | 2 +- rtgui/coordinateadjuster.cc | 3 +- rtgui/crophandler.cc | 1 + rtgui/curveeditorgroup.cc | 5 +- rtgui/diagonalcurveeditorsubgroup.cc | 4 - rtgui/editorpanel.cc | 2 +- rtgui/extprog.cc | 5 +- rtgui/extprog.h | 3 +- rtgui/filebrowser.cc | 25 ++- rtgui/filecatalog.cc | 11 +- rtgui/histogrampanel.cc | 3 +- rtgui/lwbutton.cc | 2 +- rtgui/lwbuttonset.cc | 2 +- rtgui/mydiagonalcurve.cc | 5 +- rtgui/myflatcurve.cc | 5 +- rtgui/options.cc | 2 +- rtgui/preferences.cc | 5 +- rtgui/previewloader.cc | 5 +- rtgui/previewwindow.cc | 4 +- rtgui/profilestore.cc | 4 +- rtgui/progressconnector.h | 2 +- rtgui/renamedlg.cc | 294 +++++++++++++-------------- rtgui/renamedlg.h | 78 +++---- rtgui/retinex.cc | 2 +- rtgui/shcselector.cc | 2 +- rtgui/thumbbrowserbase.cc | 6 +- rtgui/thumbbrowserentrybase.cc | 3 +- rtgui/thumbnail.cc | 4 +- rtgui/thumbnail.h | 2 +- rtgui/whitebalance.cc | 3 +- 34 files changed, 247 insertions(+), 261 deletions(-) diff --git a/rtgui/adjuster.cc b/rtgui/adjuster.cc index f0e53fbbf..b481f4ebe 100644 --- a/rtgui/adjuster.cc +++ b/rtgui/adjuster.cc @@ -35,7 +35,6 @@ static double one2one(double val) Adjuster::Adjuster (Glib::ustring vlabel, double vmin, double vmax, double vstep, double vdefault, Gtk::Image *imgIcon1, Gtk::Image *imgIcon2, double2double_fun slider2value_, double2double_fun value2slider_) { - Gtk::HBox *hbox2 = NULL; label = NULL; adjusterListener = NULL; afterReset = false; @@ -107,6 +106,8 @@ Adjuster::Adjuster (Glib::ustring vlabel, double vmin, double vmax, double vstep if (!imgIcon1 || !imgIcon2) { pack_start (*slider, true, true); } else { + Gtk::HBox *hbox2 = NULL; + // A second HBox is necessary hbox2 = Gtk::manage (new Gtk::HBox()); diff --git a/rtgui/batchqueuepanel.cc b/rtgui/batchqueuepanel.cc index 2c7f81729..e1def62ec 100644 --- a/rtgui/batchqueuepanel.cc +++ b/rtgui/batchqueuepanel.cc @@ -24,10 +24,6 @@ #include "soundman.h" #include "rtimage.h" -struct BQProcessLoaded { - BatchQueue* bq; -}; - int processLoadedBatchQueueUIThread (void* data) { diff --git a/rtgui/browserfilter.cc b/rtgui/browserfilter.cc index 6fa663aa3..3d43400ba 100644 --- a/rtgui/browserfilter.cc +++ b/rtgui/browserfilter.cc @@ -21,7 +21,8 @@ BrowserFilter::BrowserFilter () : exifFilterEnabled (false), showTrash (true), showNotTrash (true), - showOriginal (false) + showOriginal (false), + multiselect (false) { for (int i = 0; i < 6; i++) { showRanked[i] = true; diff --git a/rtgui/cacheimagedata.cc b/rtgui/cacheimagedata.cc index 75a6ab75a..220dcb2e8 100644 --- a/rtgui/cacheimagedata.cc +++ b/rtgui/cacheimagedata.cc @@ -24,7 +24,9 @@ CacheImageData::CacheImageData () : md5(""), supported(false), format(FT_Invalid), rankOld(-1), inTrashOld(false), recentlySaved(false), - timeValid(false), exifValid(false), redAWBMul(-1.0), greenAWBMul(-1.0), blueAWBMul(-1.0), thumbImgType(0) + timeValid(false), year(0), month(0), day(0), hour(0), min(0), sec(0), exifValid(false), + fnumber(0.0), shutter(0.0), focalLen(0.0), focalLen35mm(0.0), focusDist(0.f), iso(0), + redAWBMul(-1.0), greenAWBMul(-1.0), blueAWBMul(-1.0), rotate(0), thumbImgType(0) { } diff --git a/rtgui/clipboard.cc b/rtgui/clipboard.cc index ad3ea6386..e7a5b7b2c 100644 --- a/rtgui/clipboard.cc +++ b/rtgui/clipboard.cc @@ -20,7 +20,7 @@ Clipboard clipboard; -Clipboard::Clipboard () : partProfile (false) {} +Clipboard::Clipboard () : partProfile (false), _hasIPTC(false), hasDiagonalCurveDataType(DCT_Empty), hasFlatCurveDataType(FCT_Empty) {} Clipboard::~Clipboard () { diff --git a/rtgui/coordinateadjuster.cc b/rtgui/coordinateadjuster.cc index 61b5ae8b8..469013800 100644 --- a/rtgui/coordinateadjuster.cc +++ b/rtgui/coordinateadjuster.cc @@ -124,9 +124,8 @@ void CoordinateAdjuster::createWidgets(const std::vector &axis) set_spacing(3); - AxisAdjuster *currAdjuster = NULL; - for (unsigned int i = 0; i < count; ++i) { + AxisAdjuster *currAdjuster = NULL; const Axis *currAxis = &(axis.at(i)); axisAdjusters.at(i) = new AxisAdjuster(this, currAxis, i); currAdjuster = axisAdjusters.at(i); diff --git a/rtgui/crophandler.cc b/rtgui/crophandler.cc index a76f23717..c6cb49650 100644 --- a/rtgui/crophandler.cc +++ b/rtgui/crophandler.cc @@ -32,6 +32,7 @@ CropHandler::CropHandler () : zoom(10), ww(0), wh(0), imx(-1), imy(-1), imw(0), imh(0), cax(-1), cay(-1), cx(0), cy(0), cw(0), ch(0), cropX(0), cropY(0), cropW(0), cropH(0), enabled(false), cropimg(NULL), cropimgtrue(NULL), cropimg_width(0), cropimg_height(0), + cix(0), ciy(0), ciw(0), cih(0), cis(1), initial(false), isLowUpdatePriority(false), ipc(NULL), crop(NULL), displayHandler(NULL) { diff --git a/rtgui/curveeditorgroup.cc b/rtgui/curveeditorgroup.cc index f703169ed..2638ac29e 100644 --- a/rtgui/curveeditorgroup.cc +++ b/rtgui/curveeditorgroup.cc @@ -113,10 +113,9 @@ CurveEditor* CurveEditorGroup::addCurve(CurveType cType, Glib::ustring curveLabe */ void CurveEditorGroup::newLine() { - Gtk::HBox* headerBox; if (curveEditors.size() > numberOfPackedCurve) { - headerBox = Gtk::manage (new Gtk::HBox ()); + Gtk::HBox* headerBox = Gtk::manage (new Gtk::HBox ()); if (!numberOfPackedCurve) { headerBox->pack_start(*curveGroupLabel, Gtk::PACK_SHRINK, 2); @@ -381,7 +380,7 @@ void CurveEditorGroup::setUnChanged (bool uc, CurveEditor* ce) } } -CurveEditorSubGroup::CurveEditorSubGroup(Glib::ustring& curveDir) : curveDir(curveDir), lastFilename("") +CurveEditorSubGroup::CurveEditorSubGroup(Glib::ustring& curveDir) : curveDir(curveDir), lastFilename(""), valLinear(0), valUnchanged(0), parent(nullptr), curveBBoxPos(0) { leftBar = NULL; bottomBar = NULL; diff --git a/rtgui/diagonalcurveeditorsubgroup.cc b/rtgui/diagonalcurveeditorsubgroup.cc index 657186a12..a806a710d 100644 --- a/rtgui/diagonalcurveeditorsubgroup.cc +++ b/rtgui/diagonalcurveeditorsubgroup.cc @@ -1117,12 +1117,10 @@ bool DiagonalCurveEditorSubGroup::curveReset(CurveEditor *ce) case (DCT_NURBS) : // = Control cage NURBSCurve->reset (dce->NURBSResetCurve, dce->getIdentityValue()); return true; - break; case (DCT_Spline) : // = Custom customCurve->reset (dce->customResetCurve, dce->getIdentityValue()); return true; - break; case (DCT_Parametric) : { DiagonalCurveEditor* dCurve = static_cast(parent->displayedCurve); @@ -1137,12 +1135,10 @@ bool DiagonalCurveEditorSubGroup::curveReset(CurveEditor *ce) shcSelector->reset(); paramCurve->reset (dce->paramResetCurve, dce->getIdentityValue()); return true; - break; } default: return false; - break; } return true; diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 93a20c294..ca3055045 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -156,7 +156,7 @@ private: } public: - MonitorProfileSelector (rtengine::StagedImageProcessor* const& ipc) : + explicit MonitorProfileSelector (rtengine::StagedImageProcessor* const& ipc) : intentBox (Glib::ustring (), true), processor (ipc) { diff --git a/rtgui/extprog.cc b/rtgui/extprog.cc index 06f99826d..cf2b6ba9c 100644 --- a/rtgui/extprog.cc +++ b/rtgui/extprog.cc @@ -102,7 +102,7 @@ void ExtProgStore::init () #endif } - +#ifdef WIN32 bool ExtProgStore::searchProgram (const Glib::ustring& name, const Glib::ustring& exePath, const Glib::ustring& exePath86, @@ -111,7 +111,6 @@ bool ExtProgStore::searchProgram (const Glib::ustring& name, bool allowQueueProcess) { -#ifdef WIN32 // get_user_special_dir crashes on some Windows configurations. static Glib::ustring progFilesDir, progFilesDirx86; @@ -196,10 +195,10 @@ bool ExtProgStore::searchProgram (const Glib::ustring& name, return true; } -#endif return false; } +#endif bool ExtProgStore::spawnCommandAsync (const Glib::ustring& cmd) { diff --git a/rtgui/extprog.h b/rtgui/extprog.h index fe7375ce7..154a825e1 100644 --- a/rtgui/extprog.h +++ b/rtgui/extprog.h @@ -44,13 +44,14 @@ class ExtProgStore MyMutex mtx; // covers actions std::vector actions; +#ifdef WIN32 bool searchProgram (const Glib::ustring& name, const Glib::ustring& exePath, const Glib::ustring& exePath86, int maxVer, bool allowRaw, bool allowQueueProcess); - +#endif public: static ExtProgStore* getInstance(); diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index 68825c696..e3066e4dc 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -487,13 +487,13 @@ void FileBrowser::rightClicked (ThumbBrowserEntryBase* entry) untrash->set_sensitive (false); for (size_t i = 0; i < selected.size(); i++) - if ((static_cast(selected[i]))->thumbnail->getStage() == 1) { + if ((static_cast(selected[i]))->thumbnail->getStage()) { untrash->set_sensitive (true); break; } for (size_t i = 0; i < selected.size(); i++) - if ((static_cast(selected[i]))->thumbnail->getStage() == 0) { + if (!(static_cast(selected[i]))->thumbnail->getStage()) { trash->set_sensitive (true); break; } @@ -512,7 +512,6 @@ void FileBrowser::rightClicked (ThumbBrowserEntryBase* entry) submenuDF->attach (*Gtk::manage(autoDF = new Gtk::MenuItem (M("FILEBROWSER_AUTODARKFRAME"))), 0, 1, p, p + 1); p++; submenuDF->attach (*Gtk::manage(thisIsDF = new Gtk::MenuItem (M("FILEBROWSER_MOVETODARKFDIR"))), 0, 1, p, p + 1); - p++; selectDF->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &FileBrowser::menuItemActivated), selectDF)); autoDF->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &FileBrowser::menuItemActivated), autoDF)); thisIsDF->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &FileBrowser::menuItemActivated), thisIsDF )); @@ -527,7 +526,6 @@ void FileBrowser::rightClicked (ThumbBrowserEntryBase* entry) submenuFF->attach (*Gtk::manage(autoFF = new Gtk::MenuItem (M("FILEBROWSER_AUTOFLATFIELD"))), 0, 1, p, p + 1); p++; submenuFF->attach (*Gtk::manage(thisIsFF = new Gtk::MenuItem (M("FILEBROWSER_MOVETOFLATFIELDDIR"))), 0, 1, p, p + 1); - p++; selectFF->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &FileBrowser::menuItemActivated), selectFF)); autoFF->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &FileBrowser::menuItemActivated), autoFF)); thisIsFF->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &FileBrowser::menuItemActivated), thisIsFF )); @@ -612,7 +610,7 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) entry->addButtonSet (new FileThumbnailButtonSet (entry)); entry->getThumbButtonSet()->setRank (entry->thumbnail->getRank()); entry->getThumbButtonSet()->setColorLabel (entry->thumbnail->getColorLabel()); - entry->getThumbButtonSet()->setInTrash (entry->thumbnail->getStage() == 1); + entry->getThumbButtonSet()->setInTrash (entry->thumbnail->getStage()); entry->getThumbButtonSet()->setButtonListener (this); entry->resize (getThumbnailHeight()); @@ -1134,8 +1132,9 @@ bool FileBrowser::keyPressed (GdkEventKey* event) bool ctrl = event->state & GDK_CONTROL_MASK; bool shift = event->state & GDK_SHIFT_MASK; bool alt = event->state & GDK_MOD1_MASK; +#ifdef __WIN32__ bool altgr = event->state & GDK_MOD2_MASK; - +#endif if ((event->keyval == GDK_C || event->keyval == GDK_c || event->keyval == GDK_Insert) && ctrl) { copyProfile (); return true; @@ -1474,8 +1473,8 @@ bool FileBrowser::checkFilter (ThumbBrowserEntryBase* entryb) // true -> entry ((entry->thumbnail->isRecentlySaved() && filter.showRecentlySaved[0]) && !filter.showRecentlySaved[1]) || ((!entry->thumbnail->isRecentlySaved() && filter.showRecentlySaved[1]) && !filter.showRecentlySaved[0]) || - (entry->thumbnail->getStage() == 1 && !filter.showTrash) || - (entry->thumbnail->getStage() == 0 && !filter.showNotTrash)) { + (entry->thumbnail->getStage() && !filter.showTrash) || + (!entry->thumbnail->getStage() && !filter.showNotTrash)) { return false; } @@ -1568,11 +1567,11 @@ void FileBrowser::toTrashRequested (std::vector tbe) // no need to notify listeners as item goes to trash, likely to be deleted - if (tbe[i]->thumbnail->getStage() == 1) { + if (tbe[i]->thumbnail->getStage()) { continue; } - tbe[i]->thumbnail->setStage (1); + tbe[i]->thumbnail->setStage (true); if (tbe[i]->getThumbButtonSet()) { tbe[i]->getThumbButtonSet()->setRank (tbe[i]->thumbnail->getRank()); @@ -1592,11 +1591,11 @@ void FileBrowser::fromTrashRequested (std::vector tbe) for (size_t i = 0; i < tbe.size(); i++) { // if thumbnail was marked inTrash=true then param file must be there, no need to run customprofilebuilder - if (tbe[i]->thumbnail->getStage() == 0) { + if (!tbe[i]->thumbnail->getStage()) { continue; } - tbe[i]->thumbnail->setStage (0); + tbe[i]->thumbnail->setStage (false); if (tbe[i]->getThumbButtonSet()) { tbe[i]->getThumbButtonSet()->setRank (tbe[i]->thumbnail->getRank()); @@ -1715,7 +1714,7 @@ void FileBrowser::buttonPressed (LWButton* button, int actionCode, void* actionD FileBrowserEntry* entry = static_cast(actionData); tbe.push_back (entry); - if (entry->thumbnail->getStage() == 0) { + if (!entry->thumbnail->getStage()) { toTrashRequested (tbe); } else { fromTrashRequested (tbe); diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index 3ed7608f1..440ca9039 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -989,9 +989,6 @@ void FileCatalog::copyMoveRequested (std::vector tbe, bool m fc.set_filename(tbe[0]->filename); //!!! TODO prevent dialog closing on "enter" key press - bool filecopymovecomplete; - int i_copyindex; - if( fc.run() == Gtk::RESPONSE_OK ) { Glib::ustring dest_Dir = fc.get_current_folder(); @@ -1020,8 +1017,8 @@ void FileCatalog::copyMoveRequested (std::vector tbe, bool m /* comparison of src_Dir and dest_Dir is done per image for compatibility with possible future use of Collections as source where each file's source path may be different.*/ - filecopymovecomplete = false; - i_copyindex = 1; + bool filecopymovecomplete = false; + int i_copyindex = 1; while(!filecopymovecomplete) { // check for filename conflicts at destination - prevent overwriting (actually RT will crash on overwriting attempt) @@ -1224,8 +1221,6 @@ void FileCatalog::setExportPanel (ExportPanel* expanel) void FileCatalog::renameRequested (std::vector tbe) { - bool success; - RenameDialog* renameDlg = new RenameDialog ((Gtk::Window*)get_toplevel()); for (size_t i = 0; i < tbe.size(); i++) { @@ -1235,7 +1230,7 @@ void FileCatalog::renameRequested (std::vector tbe) Glib::ustring dirName = Glib::path_get_dirname (tbe[i]->filename); Glib::ustring baseName = Glib::path_get_basename (tbe[i]->filename); - success = false; + bool success = false; do { if (renameDlg->run () == Gtk::RESPONSE_OK) { diff --git a/rtgui/histogrampanel.cc b/rtgui/histogrampanel.cc index 9c8163c8e..65bbadf52 100644 --- a/rtgui/histogrampanel.cc +++ b/rtgui/histogrampanel.cc @@ -353,7 +353,8 @@ void HistogramPanel::toggle_button_full () // // HistogramRGBArea HistogramRGBArea::HistogramRGBArea () ://needChroma unactive by default - frozen(false), valid(false), needRed(true), needGreen(true), needBlue(true), needLuma(true), rawMode(false), showMode(options.histogramBar), barDisplayed(options.histogramBar), needChroma(false) + val(0), r(0), g(0), b(0), frozen(false), valid(false), needRed(true), needGreen(true), needBlue(true), needLuma(true), rawMode(false), + showMode(options.histogramBar), barDisplayed(options.histogramBar), needChroma(false), parent(nullptr) { harih = new HistogramRGBAreaIdleHelper; diff --git a/rtgui/lwbutton.cc b/rtgui/lwbutton.cc index 52b7fd7e8..f7914eedb 100644 --- a/rtgui/lwbutton.cc +++ b/rtgui/lwbutton.cc @@ -20,7 +20,7 @@ #include "guiutils.h" LWButton::LWButton (Cairo::RefPtr i, int aCode, void* aData, Alignment ha, Alignment va, Glib::ustring tooltip) - : halign(ha), valign(va), icon(i), state(Normal), listener(NULL), actionCode(aCode), actionData(aData), toolTip(tooltip) + : xpos(0), ypos(0), halign(ha), valign(va), icon(i), bgr(0.0), bgg(0.0), bgb(0.0), fgr(0.0), fgg(0.0), fgb(0.0), state(Normal), listener(NULL), actionCode(aCode), actionData(aData), toolTip(tooltip) { if (i) { diff --git a/rtgui/lwbuttonset.cc b/rtgui/lwbuttonset.cc index bfa4684af..c801cc33b 100644 --- a/rtgui/lwbuttonset.cc +++ b/rtgui/lwbuttonset.cc @@ -18,7 +18,7 @@ */ #include "lwbuttonset.h" -LWButtonSet::LWButtonSet () : aw(0), ah(0) +LWButtonSet::LWButtonSet () : aw(0), ah(0), ax(0), ay(0) { } diff --git a/rtgui/mydiagonalcurve.cc b/rtgui/mydiagonalcurve.cc index fd57633fb..969b197a2 100644 --- a/rtgui/mydiagonalcurve.cc +++ b/rtgui/mydiagonalcurve.cc @@ -165,11 +165,11 @@ void MyDiagonalCurve::get_LUT (LUTf &lut) // calculate remaining points std::vector curveDescr = getPoints (); rtengine::DiagonalCurve rtcurve(curveDescr, lut.getUpperBound() * 1.2); - double t; + double maxVal = double(lut.getUpperBound()); for (int i = 0; i < size; i++) { - t = double(i) / maxVal; + double t = double(i) / maxVal; lut[i] = rtcurve.getVal (t); } @@ -1167,7 +1167,6 @@ void MyDiagonalCurve::pipetteButton1Released(EditDataProvider *provider) snapToElmt = -100; if (curve.type != DCT_Parametric) { - std::vector::iterator itx, ity; buttonPressed = false; /* get the pointer position */ getCursorPosition(Gdk::EventType(Gdk::BUTTON_RELEASE), false, graphY, 0, Gdk::ModifierType(0)); diff --git a/rtgui/myflatcurve.cc b/rtgui/myflatcurve.cc index 4127d1ae8..4ccc8b5bb 100644 --- a/rtgui/myflatcurve.cc +++ b/rtgui/myflatcurve.cc @@ -86,11 +86,10 @@ void MyFlatCurve::get_LUT (LUTf &lut) std::vector curveDescr = getPoints (); rtengine::FlatCurve rtcurve(curveDescr, periodic, lut.getUpperBound() * 1.2 > 5000 ? 5000 : lut.getUpperBound() * 1.2); - double t; double maxVal = double(lut.getUpperBound()); for (int i = 0; i < size; i++) { - t = double(i) / maxVal; + double t = double(i) / maxVal; lut[i] = rtcurve.getVal (t); } @@ -815,13 +814,13 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) case Gdk::BUTTON_RELEASE: if (edited_point == -1) { //curve.type!=FCT_Parametric) { if (buttonPressed && event->button.button == 1) { - int src, dst; buttonPressed = false; remove_modal_grab (); // Removing any deleted point if we were previously modifying the point position if (editedHandle & (FCT_EditedHandle_CPoint | FCT_EditedHandle_CPointX | FCT_EditedHandle_CPointY)) { /* delete inactive points: */ + int src, dst; itx = curve.x.begin(); ity = curve.y.begin(); itlt = curve.leftTangent.begin(); diff --git a/rtgui/options.cc b/rtgui/options.cc index d6a327dc8..d1b6bda3d 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -2168,9 +2168,9 @@ bool Options::load () } else { #ifdef WIN32 WCHAR pathW[MAX_PATH] = {0}; - char pathA[MAX_PATH]; if (SHGetSpecialFolderPathW(NULL, pathW, CSIDL_LOCAL_APPDATA, false)) { + char pathA[MAX_PATH]; WideCharToMultiByte(CP_UTF8, 0, pathW, -1, pathA, MAX_PATH, 0, 0); rtdir = Glib::build_filename(Glib::ustring(pathA), Glib::ustring(CACHEFOLDERNAME)); } diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index 14c9cb0eb..4ffb28856 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -609,9 +609,10 @@ Gtk::Widget* Preferences::getPerformancePanel () rgbDenoiseTreadLimitSB->set_digits (0); rgbDenoiseTreadLimitSB->set_increments (1, 5); rgbDenoiseTreadLimitSB->set_max_length(2); // Will this be sufficient? :) - int maxThreadNumber = 10; #ifdef _OPENMP - maxThreadNumber = omp_get_max_threads(); + int maxThreadNumber = omp_get_max_threads(); +#else + int maxThreadNumber = 10; #endif rgbDenoiseTreadLimitSB->set_range (0, maxThreadNumber); threadLimitHB->pack_start (*RGBDTLl, Gtk::PACK_SHRINK, 2); diff --git a/rtgui/previewloader.cc b/rtgui/previewloader.cc index e7c3d4fac..e7b37cac6 100644 --- a/rtgui/previewloader.cc +++ b/rtgui/previewloader.cc @@ -72,9 +72,10 @@ public: Impl(): nConcurrentThreads(0) { - int threadCount = 2; #ifdef _OPENMP - threadCount = omp_get_num_procs(); + int threadCount = omp_get_num_procs(); +#else + int threadCount = 2; #endif threadPool_ = new Glib::ThreadPool(threadCount, 0); diff --git a/rtgui/previewwindow.cc b/rtgui/previewwindow.cc index ea419427b..18c470e55 100644 --- a/rtgui/previewwindow.cc +++ b/rtgui/previewwindow.cc @@ -223,10 +223,10 @@ bool PreviewWindow::on_button_press_event (GdkEventButton* event) int x, y, w, h; getObservedFrameArea (x, y, w, h); if (x>imgX || y>imgY || w < imgW || h < imgH) { - bool inside = event->x > x - 6 && event->x < x + w - 1 + 6 && event->y > y - 6 && event->y < y + h - 1 + 6; - bool moreInside = event->x > x + 6 && event->x < x + w - 1 - 6 && event->y > y + 6 && event->y < y + h - 1 - 6; if (!isMoving) { + bool inside = event->x > x - 6 && event->x < x + w - 1 + 6 && event->y > y - 6 && event->y < y + h - 1 + 6; + bool moreInside = event->x > x + 6 && event->x < x + w - 1 - 6 && event->y > y + 6 && event->y < y + h - 1 - 6; isMoving = true; if (!inside || moreInside) { diff --git a/rtgui/profilestore.cc b/rtgui/profilestore.cc index acbbfba63..4f4f2c187 100644 --- a/rtgui/profilestore.cc +++ b/rtgui/profilestore.cc @@ -164,10 +164,10 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath { bool fileFound = false; - unsigned int folder = 0; // folder's own Id // reload the available profiles from the profile dir if (!realPath.empty() && Glib::file_test(realPath, Glib::FILE_TEST_EXISTS) && Glib::file_test (realPath, Glib::FILE_TEST_IS_DIR)) { + unsigned int folder = 0; // folder's own Id // add this entry to the folder list folders.push_back(virtualPath); @@ -488,7 +488,7 @@ void ProfileStore::dumpFolderList() printf("Folder list:\n------------\n"); for (unsigned int i = 0; i < folders.size(); i++) { - printf(" #%3d - %s\n", i, folders.at(i).c_str()); + printf(" #%3ud - %s\n", i, folders.at(i).c_str()); } printf("\n"); diff --git a/rtgui/progressconnector.h b/rtgui/progressconnector.h index 2e235fa82..fe824a6a1 100644 --- a/rtgui/progressconnector.h +++ b/rtgui/progressconnector.h @@ -90,7 +90,7 @@ class ProgressConnector public: - ProgressConnector (): workThread( 0 ) { } + ProgressConnector (): retval( 0 ), workThread( 0 ) { } void startFunc (const sigc::slot0& startHandler, const sigc::slot0& endHandler ) { diff --git a/rtgui/renamedlg.cc b/rtgui/renamedlg.cc index a33011f09..16bfaff00 100644 --- a/rtgui/renamedlg.cc +++ b/rtgui/renamedlg.cc @@ -88,159 +88,159 @@ Glib::ustring RenameDialog::getNewName () return newName->get_text (); } -void RenameDialog::fillTemplateList () -{ +//void RenameDialog::fillTemplateList () +//{ +// +// templateModel->clear (); +// +// for (size_t i = 0; i < options.renameTemplates.size(); i++) { +// Gtk::TreeModel::iterator iter = templateModel->append (); +// iter->set_value (templateColumns.tmplName, options.renameTemplates[i]); +// iter->set_value (templateColumns.rowSeparator, false); +// } +// +// // append separator and the manage... item +// Gtk::TreeModel::iterator iter = templateModel->append (); +// iter->set_value (templateColumns.tmplName, Glib::ustring("")); +// iter->set_value (templateColumns.rowSeparator, true); +// iter = templateModel->append (); +// iter->set_value (templateColumns.tmplName, Glib::ustring(M("FILEBROWSER_ADDDELTEMPLATE"))); +// iter->set_value (templateColumns.rowSeparator, false); +//} - templateModel->clear (); +//bool RenameDialog::rowSeparatorFunc (const Glib::RefPtr& model, const Gtk::TreeModel::iterator& iter) +//{ +// +// return iter->get_value (templateColumns.rowSeparator); +//} - for (size_t i = 0; i < options.renameTemplates.size(); i++) { - Gtk::TreeModel::iterator iter = templateModel->append (); - iter->set_value (templateColumns.tmplName, options.renameTemplates[i]); - iter->set_value (templateColumns.rowSeparator, false); - } +//void RenameDialog::useTemplToggled () +//{ +// +// templates->set_sensitive (useTmpl->get_active ()); +// +// if (useTmpl->get_active () && isTemplSelected ()) { +// all->set_sensitive (true); +// newName->set_text (applyTemplate (oldName->get_text(), imageData, getActiveTemplate())); +// } else { +// all->set_sensitive (false); +// } +// +// newName->select_region (0, newName->get_text().size()); +//} - // append separator and the manage... item - Gtk::TreeModel::iterator iter = templateModel->append (); - iter->set_value (templateColumns.tmplName, Glib::ustring("")); - iter->set_value (templateColumns.rowSeparator, true); - iter = templateModel->append (); - iter->set_value (templateColumns.tmplName, Glib::ustring(M("FILEBROWSER_ADDDELTEMPLATE"))); - iter->set_value (templateColumns.rowSeparator, false); -} +//bool RenameDialog::isTemplSelected () +//{ +// +// Gtk::TreeModel::iterator iter = templates->get_active(); +// return iter && iter->get_value (templateColumns.tmplName) != M("FILEBROWSER_ADDDELTEMPLATE"); +//} -bool RenameDialog::rowSeparatorFunc (const Glib::RefPtr& model, const Gtk::TreeModel::iterator& iter) -{ +//Glib::ustring RenameDialog::getActiveTemplate () +//{ +// +// Gtk::TreeModel::iterator iter = templates->get_active(); +// +// if (iter && iter->get_value (templateColumns.tmplName) != M("FILEBROWSER_ADDDELTEMPLATE")) { +// return iter->get_value (templateColumns.tmplName); +// } else { +// return ""; +// } +//} - return iter->get_value (templateColumns.rowSeparator); -} +//void RenameDialog::tmplSelectionChanged () +//{ +// +// Gtk::TreeModel::iterator iter = templates->get_active(); +// +// if (iter && iter->get_value (templateColumns.tmplName) == M("FILEBROWSER_ADDDELTEMPLATE")) { +// RenameTemplateEditor* rte = new RenameTemplateEditor (p); +// +// if (rte->run() == Gtk::RESPONSE_OK) { +// fillTemplateList (); +// } +// +// delete rte; +// // show add/del template dialog +// } else { +// useTemplToggled (); +// } +//} -void RenameDialog::useTemplToggled () -{ +//RenameTemplateEditor::RenameTemplateEditor (Gtk::Window* parent) +// : Gtk::Dialog ("Edit rename templates", *parent, true, true) +//{ +// +// list = Gtk::manage (new Gtk::ListViewText (1, false, Gtk::SELECTION_MULTIPLE)); +// list->set_headers_visible (false); +// get_vbox ()->pack_start (*list); +// +// Gtk::HBox* hb = Gtk::manage (new Gtk::HBox ()); +// templ = Gtk::manage (new Gtk::Entry ()); +// Gtk::Button* add = Gtk::manage (new Gtk::Button ()); +// Gtk::Button* del = Gtk::manage (new Gtk::Button ()); +// add->add (*Gtk::manage (new RTImage ("list-add-small.png"))); +// del->add (*Gtk::manage (new RTImage ("list-remove-red-small.png"))); +// hb->pack_start (*templ); +// hb->pack_start (*add, Gtk::PACK_SHRINK, 2); +// hb->pack_start (*del, Gtk::PACK_SHRINK, 2); +// +// get_vbox ()->pack_start (*hb, Gtk::PACK_SHRINK, 4); +// +// add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK); +// +// refreshTemplateList (); +// +// add->signal_pressed().connect( sigc::mem_fun(*this, &RenameTemplateEditor::addPressed) ); +// del->signal_pressed().connect( sigc::mem_fun(*this, &RenameTemplateEditor::delPressed) ); +// +// show_all_children (); +// +// set_size_request (-1, 250); +//} +// +//void RenameTemplateEditor::refreshTemplateList () +//{ +// +// list->clear_items (); +// +// for (size_t i = 0; i < options.renameTemplates.size(); i++) { +// list->append_text (options.renameTemplates[i]); +// } +//} +// +//void RenameTemplateEditor::addPressed () +//{ +// +// if (templ->get_text() != "") { +// options.renameTemplates.push_back (templ->get_text ()); +// refreshTemplateList (); +// templ->set_text(""); +// } +//} +// +//void RenameTemplateEditor::delPressed () +//{ +// +// std::vector sel = list->get_selected (); +// +// for (size_t i = 0; i < sel.size(); i++) { +// Glib::ustring toDel = list->get_text (sel[i]); +// std::vector::iterator f = std::find (options.renameTemplates.begin(), options.renameTemplates.end(), toDel); +// +// if (f != options.renameTemplates.end()) { +// options.renameTemplates.erase (f); +// } +// } +// +// refreshTemplateList (); +//} - templates->set_sensitive (useTmpl->get_active ()); - - if (useTmpl->get_active () && isTemplSelected ()) { - all->set_sensitive (true); - newName->set_text (applyTemplate (oldName->get_text(), imageData, getActiveTemplate())); - } else { - all->set_sensitive (false); - } - - newName->select_region (0, newName->get_text().size()); -} - -bool RenameDialog::isTemplSelected () -{ - - Gtk::TreeModel::iterator iter = templates->get_active(); - return iter && iter->get_value (templateColumns.tmplName) != M("FILEBROWSER_ADDDELTEMPLATE"); -} - -Glib::ustring RenameDialog::getActiveTemplate () -{ - - Gtk::TreeModel::iterator iter = templates->get_active(); - - if (iter && iter->get_value (templateColumns.tmplName) != M("FILEBROWSER_ADDDELTEMPLATE")) { - return iter->get_value (templateColumns.tmplName); - } else { - return ""; - } -} - -void RenameDialog::tmplSelectionChanged () -{ - - Gtk::TreeModel::iterator iter = templates->get_active(); - - if (iter && iter->get_value (templateColumns.tmplName) == M("FILEBROWSER_ADDDELTEMPLATE")) { - RenameTemplateEditor* rte = new RenameTemplateEditor (p); - - if (rte->run() == Gtk::RESPONSE_OK) { - fillTemplateList (); - } - - delete rte; - // show add/del template dialog - } else { - useTemplToggled (); - } -} - -RenameTemplateEditor::RenameTemplateEditor (Gtk::Window* parent) - : Gtk::Dialog ("Edit rename templates", *parent, true, true) -{ - - list = Gtk::manage (new Gtk::ListViewText (1, false, Gtk::SELECTION_MULTIPLE)); - list->set_headers_visible (false); - get_vbox ()->pack_start (*list); - - Gtk::HBox* hb = Gtk::manage (new Gtk::HBox ()); - templ = Gtk::manage (new Gtk::Entry ()); - Gtk::Button* add = Gtk::manage (new Gtk::Button ()); - Gtk::Button* del = Gtk::manage (new Gtk::Button ()); - add->add (*Gtk::manage (new RTImage ("list-add-small.png"))); - del->add (*Gtk::manage (new RTImage ("list-remove-red-small.png"))); - hb->pack_start (*templ); - hb->pack_start (*add, Gtk::PACK_SHRINK, 2); - hb->pack_start (*del, Gtk::PACK_SHRINK, 2); - - get_vbox ()->pack_start (*hb, Gtk::PACK_SHRINK, 4); - - add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK); - - refreshTemplateList (); - - add->signal_pressed().connect( sigc::mem_fun(*this, &RenameTemplateEditor::addPressed) ); - del->signal_pressed().connect( sigc::mem_fun(*this, &RenameTemplateEditor::delPressed) ); - - show_all_children (); - - set_size_request (-1, 250); -} - -void RenameTemplateEditor::refreshTemplateList () -{ - - list->clear_items (); - - for (size_t i = 0; i < options.renameTemplates.size(); i++) { - list->append_text (options.renameTemplates[i]); - } -} - -void RenameTemplateEditor::addPressed () -{ - - if (templ->get_text() != "") { - options.renameTemplates.push_back (templ->get_text ()); - refreshTemplateList (); - templ->set_text(""); - } -} - -void RenameTemplateEditor::delPressed () -{ - - std::vector sel = list->get_selected (); - - for (size_t i = 0; i < sel.size(); i++) { - Glib::ustring toDel = list->get_text (sel[i]); - std::vector::iterator f = std::find (options.renameTemplates.begin(), options.renameTemplates.end(), toDel); - - if (f != options.renameTemplates.end()) { - options.renameTemplates.erase (f); - } - } - - refreshTemplateList (); -} - -Glib::ustring RenameDialog::applyTemplate (const Glib::ustring& oName, const CacheImageData* cid, const Glib::ustring& templ) -{ - - return Glib::ustring ("szeva"); - -} +//Glib::ustring RenameDialog::applyTemplate (const Glib::ustring& oName, const CacheImageData* cid, const Glib::ustring& templ) +//{ +// +// return Glib::ustring ("szeva"); +// +//} diff --git a/rtgui/renamedlg.h b/rtgui/renamedlg.h index 8de7fe013..94972d575 100644 --- a/rtgui/renamedlg.h +++ b/rtgui/renamedlg.h @@ -30,29 +30,29 @@ class RenameDialog : public Gtk::Dialog protected: - class TemplateColumns : public Gtk::TreeModel::ColumnRecord - { - public: - Gtk::TreeModelColumn tmplName; - Gtk::TreeModelColumn rowSeparator; - TemplateColumns() - { - add(tmplName); - add(rowSeparator); - } - }; - TemplateColumns templateColumns; - Glib::RefPtr templateModel; +// class TemplateColumns : public Gtk::TreeModel::ColumnRecord +// { +// public: +// Gtk::TreeModelColumn tmplName; +// Gtk::TreeModelColumn rowSeparator; +// TemplateColumns() +// { +// add(tmplName); +// add(rowSeparator); +// } +// }; +// TemplateColumns templateColumns; +// Glib::RefPtr templateModel; Gtk::Window* p; Gtk::Label* oldName; Gtk::Entry* newName; - Gtk::CheckButton* useTmpl; - MyComboBox* templates; - Gtk::Button* all; +// Gtk::CheckButton* useTmpl; +// MyComboBox* templates; +// Gtk::Button* all; const CacheImageData* imageData; - void fillTemplateList (); +// void fillTemplateList (); public: explicit RenameDialog (Gtk::Window* parent); @@ -60,32 +60,32 @@ public: void initName (const Glib::ustring& iname, const CacheImageData* cid); Glib::ustring getNewName (); - bool rowSeparatorFunc (const Glib::RefPtr& model, const Gtk::TreeModel::iterator& iter); - void tmplSelectionChanged (); - void useTemplToggled (); +// bool rowSeparatorFunc (const Glib::RefPtr& model, const Gtk::TreeModel::iterator& iter); +// void tmplSelectionChanged (); +// void useTemplToggled (); - bool isTemplSelected (); - Glib::ustring getActiveTemplate (); +// bool isTemplSelected (); +// Glib::ustring getActiveTemplate (); - static Glib::ustring applyTemplate (const Glib::ustring& oName, const CacheImageData* cid, const Glib::ustring& templ); +// static Glib::ustring applyTemplate (const Glib::ustring& oName, const CacheImageData* cid, const Glib::ustring& templ); }; -class RenameTemplateEditor : public Gtk::Dialog -{ - -protected: - Gtk::ListViewText* list; - Gtk::Entry* templ; - - void refreshTemplateList (); -public: - explicit RenameTemplateEditor (Gtk::Window* parent); - - Glib::ustring getSelectedTemplate (); - - void addPressed (); - void delPressed (); -}; +//class RenameTemplateEditor : public Gtk::Dialog +//{ +// +//protected: +// Gtk::ListViewText* list; +// Gtk::Entry* templ; +// +// void refreshTemplateList (); +//public: +// explicit RenameTemplateEditor (Gtk::Window* parent); +// +// Glib::ustring getSelectedTemplate (); +// +// void addPressed (); +// void delPressed (); +//}; #endif diff --git a/rtgui/retinex.cc b/rtgui/retinex.cc index fead40b88..d44cef912 100644 --- a/rtgui/retinex.cc +++ b/rtgui/retinex.cc @@ -1121,7 +1121,7 @@ void Retinex::gammaretinexChanged() if(gammaretinex->get_active_row_number() == 4) { gam->show(); slope->show(); - } else if(gammaretinex->get_active_row_number() != 4) { + } else /*if(gammaretinex->get_active_row_number() != 4)*/ { gam->hide(); slope->hide(); } diff --git a/rtgui/shcselector.cc b/rtgui/shcselector.cc index 461eb118f..9cb41e1a5 100644 --- a/rtgui/shcselector.cc +++ b/rtgui/shcselector.cc @@ -21,7 +21,7 @@ #include "multilangmgr.h" #include "mycurve.h" -SHCSelector::SHCSelector() : ColoredBar(RTO_Left2Right), movingPosition(-1), cl(NULL) +SHCSelector::SHCSelector() : ColoredBar(RTO_Left2Right), movingPosition(-1), tmpX(0.0), tmpPos(0.0), wslider(0.0), cl(NULL) { positions[0] = defaults[0] = 0.25; diff --git a/rtgui/thumbbrowserbase.cc b/rtgui/thumbbrowserbase.cc index ea2bb00dd..2d022f9f7 100644 --- a/rtgui/thumbbrowserbase.cc +++ b/rtgui/thumbbrowserbase.cc @@ -559,7 +559,6 @@ void ThumbBrowserBase::arrangeFiles () int ct = 0; int currx = 0; - int curry = 0; while (ct < N) { // find widest item in the column @@ -571,7 +570,7 @@ void ThumbBrowserBase::arrangeFiles () } // arrange items in the column - curry = 0; + int curry = 0; for (int i = 0; ct < N && i < numOfRows; i++, ct++) { while (ct < N && fd[ct]->filtered) { @@ -641,12 +640,11 @@ void ThumbBrowserBase::arrangeFiles () // arrange files int ct = 0; - int currx = 0; int curry = 0; while (ct < N) { // arrange items in the row - currx = 0; + int currx = 0; for (int i = 0; ct < N && i < numOfCols; i++, ct++) { while (ct < N && fd[ct]->filtered) { diff --git a/rtgui/thumbbrowserentrybase.cc b/rtgui/thumbbrowserentrybase.cc index b924655c5..3783c5164 100644 --- a/rtgui/thumbbrowserentrybase.cc +++ b/rtgui/thumbbrowserentrybase.cc @@ -119,7 +119,6 @@ void ThumbBrowserEntryBase::updateBackBuffer () getTextSizes (infow, infoh); int iofs_x = 4, iofs_y = 4; - int igap = 2; int istartx = prex; int istarty = prey; @@ -141,6 +140,7 @@ void ThumbBrowserEntryBase::updateBackBuffer () istarty += iofs_y; if (!bbIcons.empty()) { + int igap = 2; int iwidth = 0; int iheight = 0; @@ -251,7 +251,6 @@ void ThumbBrowserEntryBase::updateBackBuffer () fn->set_width (textw * Pango::SCALE); fn->set_ellipsize (Pango::ELLIPSIZE_MIDDLE); backBuffer->draw_layout (gc_, textposx_ex, textposy + tpos, fn); - tpos += exlabh; } } } diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index b9d23e46d..62d48b2ec 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -63,8 +63,8 @@ Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageDa Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5) : fname(fname), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL), pparamsValid(false), - needsReProcessing(true), imageLoading(false), lastImg(NULL), - initial_(true) + pparamsSet(false), needsReProcessing(true), imageLoading(false), lastImg(NULL), + lastW(0), lastH(0), lastScale(0.0), initial_(true) { diff --git a/rtgui/thumbnail.h b/rtgui/thumbnail.h index ca2f898ec..97dd20b5a 100644 --- a/rtgui/thumbnail.h +++ b/rtgui/thumbnail.h @@ -187,7 +187,7 @@ public: { return pparams.inTrash; } - void setStage (int stage) + void setStage (bool stage) { if (pparams.inTrash != stage) { pparams.inTrash = stage; diff --git a/rtgui/whitebalance.cc b/rtgui/whitebalance.cc index f77ce74e7..3c4b61fe3 100644 --- a/rtgui/whitebalance.cc +++ b/rtgui/whitebalance.cc @@ -104,14 +104,13 @@ static double wbTemp2Slider(double temp) const double slope = (double)(CENTERTEMP - MINTEMP) / (MAXTEMP - CENTERTEMP); const double y = (temp - CENTERTEMP) / (MAXTEMP - CENTERTEMP); double x = pow(y, 0.25); // rough guess of x, will be a little lower - double y1; double k = 0.1; bool add = true; // the y=f(x) function is a mess to invert, therefore we have this trial-refinement loop instead. // from tests, worst case is about 20 iterations, ie no problem for (;;) { - y1 = x * slope + (1.0 - slope) * pow(x, 4.0); + double y1 = x * slope + (1.0 - slope) * pow(x, 4.0); if (5000 * fabs(y1 - y) < 0.1) { break; From e82b60cd03b2e65a3a1f9b0a755351367ea0e3db Mon Sep 17 00:00:00 2001 From: heckflosse Date: Tue, 4 Oct 2016 23:50:44 +0200 Subject: [PATCH 10/13] =?UTF-8?q?Cppcheck:=20Fixed=20some=20issues=20found?= =?UTF-8?q?=20by=20Fl=C3=B6ssie=20during=20review=20of=20my=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rtengine/FTblockDN.cc | 5 +---- rtengine/lcp.cc | 2 +- rtengine/lcp.h | 2 +- rtgui/ilabel.cc | 2 +- rtgui/ilabel.h | 2 +- rtgui/partialpastedlg.cc | 2 +- rtgui/partialpastedlg.h | 2 +- rtgui/saveasdlg.cc | 2 +- rtgui/saveasdlg.h | 2 +- 9 files changed, 9 insertions(+), 12 deletions(-) diff --git a/rtengine/FTblockDN.cc b/rtengine/FTblockDN.cc index e0d22d639..c74e49218 100644 --- a/rtengine/FTblockDN.cc +++ b/rtengine/FTblockDN.cc @@ -1677,10 +1677,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef } delete labdn; - - if (Lin) { - delete Lin; - } + delete Lin; }//end of tile row }//end of tile loop diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index 1ed601301..0f45e1270 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -276,7 +276,7 @@ float LCPMapper::calcVignetteFac(int x, int y) const + 2.*aVig[0] * aVig[2] - 3.*param0Sqr * aVig[1]) * rsqr * rsqr)); } -LCPProfile::LCPProfile(Glib::ustring fname) +LCPProfile::LCPProfile(const Glib::ustring &fname) { const int BufferSize = 8192; char buf[BufferSize]; diff --git a/rtengine/lcp.h b/rtengine/lcp.h index 15d51d556..908bacf56 100644 --- a/rtengine/lcp.h +++ b/rtengine/lcp.h @@ -89,7 +89,7 @@ public: static const int MaxPersModelCount = 3000; LCPPersModel* aPersModel[MaxPersModelCount]; // Do NOT use std::list or something, it's buggy in GCC! - explicit LCPProfile(Glib::ustring fname); + explicit LCPProfile(const Glib::ustring &fname); void calcParams(int mode, float focalLength, float focusDist, float aperture, LCPModelCommon *pCorr1, LCPModelCommon *pCorr2, LCPModelCommon *pCorr3) const; // Interpolates between the persModels frames diff --git a/rtgui/ilabel.cc b/rtgui/ilabel.cc index 591564305..2c7edfd80 100644 --- a/rtgui/ilabel.cc +++ b/rtgui/ilabel.cc @@ -18,7 +18,7 @@ */ #include "ilabel.h" -ILabel::ILabel (Glib::ustring lab) : label(lab) {} +ILabel::ILabel (const Glib::ustring &lab) : label(lab) {} void ILabel::on_realize() { diff --git a/rtgui/ilabel.h b/rtgui/ilabel.h index ab8f656cc..82064bd23 100644 --- a/rtgui/ilabel.h +++ b/rtgui/ilabel.h @@ -27,7 +27,7 @@ class ILabel : public Gtk::DrawingArea Glib::ustring label; public: - explicit ILabel (Glib::ustring lab); + explicit ILabel (const Glib::ustring &lab); bool on_expose_event(GdkEventExpose* event); void on_realize(); void on_style_changed (const Glib::RefPtr& style); diff --git a/rtgui/partialpastedlg.cc b/rtgui/partialpastedlg.cc index d017b5409..78631b725 100644 --- a/rtgui/partialpastedlg.cc +++ b/rtgui/partialpastedlg.cc @@ -20,7 +20,7 @@ #include "multilangmgr.h" #include "paramsedited.h" -PartialPasteDlg::PartialPasteDlg (Glib::ustring title) +PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title) { set_modal (true); diff --git a/rtgui/partialpastedlg.h b/rtgui/partialpastedlg.h index 57d77f532..a054b042e 100644 --- a/rtgui/partialpastedlg.h +++ b/rtgui/partialpastedlg.h @@ -132,7 +132,7 @@ public: sigc::connection raw_caredConn, raw_cablueConn, raw_ca_autocorrectConn, raw_hotpix_filtConn, raw_deadpix_filtConn, raw_linenoiseConn, raw_greenthreshConn, raw_ccStepsConn, raw_methodConn, raw_dcb_iterationsConn, raw_lmmse_iterationsConn, raw_dcb_enhanceConn, raw_exposConn, raw_preserConn, raw_blackConn; public: - explicit PartialPasteDlg (Glib::ustring title); + explicit PartialPasteDlg (const Glib::ustring &title); void applyPaste (rtengine::procparams::ProcParams* dstPP, ParamsEdited* dstPE, const rtengine::procparams::ProcParams* srcPP, const ParamsEdited* srcPE = NULL); diff --git a/rtgui/saveasdlg.cc b/rtgui/saveasdlg.cc index c9490f585..2afd1eb58 100644 --- a/rtgui/saveasdlg.cc +++ b/rtgui/saveasdlg.cc @@ -22,7 +22,7 @@ #include "rtimage.h" extern Options options; -SaveAsDialog::SaveAsDialog (Glib::ustring initialDir) +SaveAsDialog::SaveAsDialog (const Glib::ustring &initialDir) { set_title(M("GENERAL_SAVE")); diff --git a/rtgui/saveasdlg.h b/rtgui/saveasdlg.h index 188d915fb..4810b46d9 100644 --- a/rtgui/saveasdlg.h +++ b/rtgui/saveasdlg.h @@ -45,7 +45,7 @@ protected: void putToQueueClicked (); public: - explicit SaveAsDialog (Glib::ustring initialDir); + explicit SaveAsDialog (const Glib::ustring &initialDir); Glib::ustring getFileName (); Glib::ustring getDirectory (); From 18ee91b8e4dcd5d1e6c51d79f7147c3285d8d4c4 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 5 Oct 2016 00:04:22 +0200 Subject: [PATCH 11/13] Removed rtgui/createicon.cc --- rtgui/createicon.cc | 223 -------------------------------------------- 1 file changed, 223 deletions(-) delete mode 100644 rtgui/createicon.cc diff --git a/rtgui/createicon.cc b/rtgui/createicon.cc deleted file mode 100644 index 32884c182..000000000 --- a/rtgui/createicon.cc +++ /dev/null @@ -1,223 +0,0 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * RawTherapee is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * RawTherapee is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with RawTherapee. If not, see . - */ -#include - -void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ - check = (png_size_t)fread(data, (png_size_t)1, length, (FILE *)png_ptr->io_ptr); - - if (check != length) { - png_error(png_ptr, "Read Error"); - } -} - -void png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - - check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr)); - - if (check != length) { - png_error(png_ptr, "Write Error"); - } -} - -void png_flush(png_structp png_ptr) -{ - FILE *io_ptr; - io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr)); - - if (io_ptr != NULL) { - fflush(io_ptr); - } -} - - -unsigned char* loadPNG (char* fname, int& w, int& h) -{ - - FILE *file = fopen (fname, "rb"); - - unsigned char header[8]; - fread (header, 1, 8, file); - - png_structp png = png_create_read_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0); - png_infop info = png_create_info_struct (png); - png_infop end_info = png_create_info_struct (png); - - if (setjmp (png_jmpbuf(png))) { - png_destroy_read_struct (&png, &info, &end_info); - fclose (file); - return NULL; - } - - //set up png read - png_set_read_fn (png, file, png_read_data); - png_set_sig_bytes (png, 8); - - png_read_info(png, info); - - unsigned long width, height; - int bit_depth, color_type, interlace_type, compression_type, filter_method; - png_get_IHDR(png, info, &width, &height, &bit_depth, &color_type, &interlace_type, - &compression_type, &filter_method); - - //converting to 32bpp format - if (color_type == PNG_COLOR_TYPE_PALETTE) { - png_set_palette_to_rgb(png); - } - - if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { - png_set_gray_to_rgb(png); - } - - if (png_get_valid(png, info, PNG_INFO_tRNS)) { - png_set_tRNS_to_alpha(png); - } - - if (interlace_type != PNG_INTERLACE_NONE) { - png_destroy_read_struct (&png, &info, &end_info); - fclose (file); - return NULL; - } - - if (color_type & PNG_COLOR_MASK_ALPHA) { - png_set_strip_alpha(png); - } - - //setting gamma - double gamma; - - if (png_get_gAMA(png, info, &gamma)) { - png_set_gamma(png, 2.0, gamma); - } else { - png_set_gamma(png, 2.0, 0.45455); - } - - int bps = 8; - - //updating png info struct - png_read_update_info(png, info); - png_get_IHDR(png, info, &width, &height, &bit_depth, &color_type, &interlace_type, - &compression_type, &filter_method); - - if (color_type & PNG_COLOR_MASK_ALPHA) { - png_set_strip_alpha(png); - } - - png_read_update_info(png, info); - png_get_IHDR(png, info, &width, &height, &bit_depth, &color_type, &interlace_type, - &compression_type, &filter_method); - - - unsigned char* data = new unsigned char[width * height * 3]; - int rowlen = width * 3; - unsigned char *row = new unsigned char [rowlen]; - - for (unsigned int i = 0; i < height; i++) { - - png_read_row (png, (png_byte*)row, NULL); - memcpy (data + 3 * i * width, row, 3 * width); - } - - png_read_end (png, 0); - png_destroy_read_struct (&png, &info, &end_info); - - delete [] row; - fclose(file); - - w = width; - h = height; - return data; -} - -void savePNG (char* fname, unsigned char* data1, unsigned char* data2, int w, int h) -{ - - FILE* file = fopen(fname, "wb"); - - png_structp png = png_create_write_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0); - png_infop info = png_create_info_struct(png); - - if (setjmp(png_jmpbuf(png))) { - png_destroy_write_struct (&png, &info); - fclose(file); - return; - } - - png_set_write_fn (png, file, png_write_data, png_flush); - png_set_compression_level(png, 6); - - int width = w; - int height = h; - int bps = 8; - - png_set_IHDR(png, info, width, height, bps, PNG_COLOR_TYPE_RGB_ALPHA, - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_BASE); - - - int rowlen = width * 4; - unsigned char *row = new unsigned char [rowlen]; - - png_write_info(png, info); - - for (unsigned int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - int ofs = 3 * (width * i + j); - unsigned char alpha = data2[ofs] - data1[ofs]; - - if (i == 8 && j == 8) { - printf ("alpha=%d pix=%d\n", (int)alpha, (int)(data1[ofs + 0] / (1.0 - alpha / 255.0))); - } - - if (alpha < 255) { - row[4 * j + 0] = data1[ofs + 0] / (1.0 - alpha / 255.0); - row[4 * j + 1] = data1[ofs + 1] / (1.0 - alpha / 255.0); - row[4 * j + 2] = data1[ofs + 2] / (1.0 - alpha / 255.0); - } else { - - } - - row[4 * j + 3] = 255 - alpha; - } - - png_write_row (png, (png_byte*)row); - } - - png_write_end(png, info); - png_destroy_write_struct(&png, &info); - - delete [] row; - fclose (file); -} - -int main (int argc, char* argv[]) -{ - - int w, h; - unsigned char* data1 = loadPNG (argv[1], w, h); - unsigned char* data2 = loadPNG (argv[2], w, h); - savePNG (argv[3], data1, data2, w, h); - -} From 8a2b2e6700e214b2cd14d97b32d9b8215a1d0a62 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 5 Oct 2016 01:15:52 +0200 Subject: [PATCH 12/13] Extended StopWatch class to report processing time in microseconds --- rtengine/StopWatch.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/rtengine/StopWatch.h b/rtengine/StopWatch.h index ac4a4d16c..9e4400b94 100644 --- a/rtengine/StopWatch.h +++ b/rtengine/StopWatch.h @@ -26,18 +26,17 @@ #ifdef BENCHMARK #define BENCHFUN StopWatch StopFun(__func__); + #define BENCHFUNMICRO StopWatch StopFun(__func__, true); #else #define BENCHFUN + #define BENCHFUNMICRO #endif class StopWatch { public: - StopWatch( ) - { - stopped = false; - } - explicit StopWatch( const char* msg ) + + explicit StopWatch( const char* msg, bool microseconds = false ) : microseconds(microseconds) { message = msg; start(); @@ -56,8 +55,13 @@ public: void stop() { stopTime.set(); - long elapsedTime = stopTime.etime(startTime) / 1000; - std::cout << message << " took " << elapsedTime << " ms" << std::endl; + if(!microseconds) { + long elapsedTime = stopTime.etime(startTime) / 1000; + std::cout << message << " took " << elapsedTime << " ms" << std::endl; + } else { + long elapsedTime = stopTime.etime(startTime); + std::cout << message << " took " << elapsedTime << " us" << std::endl; + } stopped = true; } void stop(const char *msg) @@ -66,6 +70,7 @@ public: stop(); }; private: + bool microseconds; MyTime startTime; MyTime stopTime; const char *message; From d132149a2661c4036b87fd951349dd79a1cec90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Sat, 8 Oct 2016 15:36:44 +0200 Subject: [PATCH 13/13] Introduce `rtengine/noncopyable.hpp` --- rtengine/EdgePreservingDecomposition.h | 10 +++++--- rtengine/LUT.h | 10 +++++--- rtengine/array2D.h | 7 +++--- rtengine/cieimage.h | 6 ++--- rtengine/clutstore.h | 12 ++++----- rtengine/cplx_wavelet_dec.h | 8 +++--- rtengine/dcp.h | 11 ++++---- rtengine/jaggedarray.h | 14 ++++------- rtengine/noncopyable.h | 34 +++++++++++++++++++++++++ rtengine/procparams.h | 6 +++-- rtengine/rawimage.h | 7 +++--- rtengine/shmap.h | 6 ++--- rtexif/rtexif.h | 6 +++-- rtgui/cachemanager.h | 11 +++----- rtgui/previewloader.cc | 5 ++-- rtgui/previewloader.h | 20 ++++++++++----- rtgui/profilestore.h | 11 +++++--- rtgui/threadutils.h | 35 ++++++++++---------------- rtgui/thumbimageupdater.cc | 6 ++--- rtgui/thumbimageupdater.h | 22 +++++++++------- 20 files changed, 142 insertions(+), 105 deletions(-) create mode 100644 rtengine/noncopyable.h diff --git a/rtengine/EdgePreservingDecomposition.h b/rtengine/EdgePreservingDecomposition.h index a369bdf4d..a9038355e 100644 --- a/rtengine/EdgePreservingDecomposition.h +++ b/rtengine/EdgePreservingDecomposition.h @@ -50,17 +50,19 @@ My email address is my screen name followed by @yahoo.com. I'm also known as ben #include #include #include + #include "opthelper.h" +#include "noncopyable.h" //This is for solving big symmetric positive definite linear problems. float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), float *b, int n, bool OkToModify_b = true, float *x = NULL, float RMSResidual = 0.0f, void *Pass = NULL, int MaximumIterates = 0, void Preconditioner(float *Product, float *x, void *Pass) = NULL); //Storage and use class for symmetric matrices, the nonzero contents of which are confined to diagonals. -class MultiDiagonalSymmetricMatrix +class MultiDiagonalSymmetricMatrix : + public rtengine::NonCopyable { public: MultiDiagonalSymmetricMatrix(int Dimension, int NumberOfDiagonalsInLowerTriangle); - MultiDiagonalSymmetricMatrix(const MultiDiagonalSymmetricMatrix&) = delete; ~MultiDiagonalSymmetricMatrix(); /* Storage of matrix data, and a function to create memory for Diagonals[index]. @@ -115,11 +117,11 @@ public: }; -class EdgePreservingDecomposition +class EdgePreservingDecomposition : + public rtengine::NonCopyable { public: EdgePreservingDecomposition(int width, int height); - EdgePreservingDecomposition(const EdgePreservingDecomposition&) = delete; ~EdgePreservingDecomposition(); //Create an edge preserving blur of Source. Will create and return, or fill into Blur if not NULL. In place not ok. diff --git a/rtengine/LUT.h b/rtengine/LUT.h index c570fe671..2d3d91ed5 100644 --- a/rtengine/LUT.h +++ b/rtengine/LUT.h @@ -61,13 +61,16 @@ #include #include +#include + #ifndef NDEBUG #include #include #endif + #include "opthelper.h" -#include #include "rt_math.h" +#include "noncopyable.h" // Bit representations of flags enum { @@ -85,7 +88,8 @@ using LUTd = LUT; using LUTuc = LUT; template -class LUT +class LUT : + public rtengine::NonCopyable { protected: // list of variables ordered to improve cache speed @@ -167,8 +171,6 @@ public: reset(); } - LUT(const LUT&) = delete; - ~LUT() { if (owner) { diff --git a/rtengine/array2D.h b/rtengine/array2D.h index 75d784cbc..db44fcfc8 100644 --- a/rtengine/array2D.h +++ b/rtengine/array2D.h @@ -66,8 +66,11 @@ #include #include +#include "noncopyable.h" + template -class array2D +class array2D : + public rtengine::NonCopyable { private: @@ -167,8 +170,6 @@ public: } } - array2D(const array2D&) = delete; - // destructor ~array2D() { diff --git a/rtengine/cieimage.h b/rtengine/cieimage.h index d8cf45cf8..23b080ae3 100644 --- a/rtengine/cieimage.h +++ b/rtengine/cieimage.h @@ -20,11 +20,13 @@ #define _CIEIMAGE_H_ #include "image16.h" +#include "noncopyable.h" namespace rtengine { -class CieImage +class CieImage : + public NonCopyable { private: bool fromImage; @@ -41,8 +43,6 @@ public: float** h_p; CieImage (int w, int h); - CieImage (const CieImage&) = delete; - ~CieImage (); //Copies image data in Img into this instance. diff --git a/rtengine/clutstore.h b/rtengine/clutstore.h index 7383b597f..5e4930fa1 100644 --- a/rtengine/clutstore.h +++ b/rtengine/clutstore.h @@ -7,16 +7,16 @@ #include "cache.h" #include "alignedbuffer.h" +#include "noncopyable.h" namespace rtengine { -class HaldCLUT +class HaldCLUT final : + public NonCopyable { public: HaldCLUT(); - HaldCLUT(const HaldCLUT& other) = delete; - HaldCLUT& operator =(const HaldCLUT& other) = delete; ~HaldCLUT(); bool load(const Glib::ustring& filename); @@ -51,14 +51,12 @@ private: Glib::ustring clut_profile; }; -class CLUTStore +class CLUTStore final : + public NonCopyable { public: static CLUTStore& getInstance(); - CLUTStore(const CLUTStore& other) = delete; - CLUTStore& operator =(const CLUTStore& other) = delete; - std::shared_ptr getClut(const Glib::ustring& filename); void clearCache(); diff --git a/rtengine/cplx_wavelet_dec.h b/rtengine/cplx_wavelet_dec.h index c5267897c..bc8b7bdd3 100644 --- a/rtengine/cplx_wavelet_dec.h +++ b/rtengine/cplx_wavelet_dec.h @@ -22,15 +22,17 @@ #define CPLX_WAVELET_DEC_H_INCLUDED #include -#include +#include #include "cplx_wavelet_level.h" #include "cplx_wavelet_filter_coeffs.h" +#include "noncopyable.h" namespace rtengine { -class wavelet_decomposition +class wavelet_decomposition : + public NonCopyable { public: @@ -58,8 +60,6 @@ public: template wavelet_decomposition(E * src, int width, int height, int maxlvl, int subsampling, int skipcrop = 1, int numThreads = 1, int Daub4Len = 6); - wavelet_decomposition(const wavelet_decomposition&) = delete; - ~wavelet_decomposition(); internal_type ** level_coeffs(int level) const diff --git a/rtengine/dcp.h b/rtengine/dcp.h index ffc1e33ce..8b781ce6b 100644 --- a/rtengine/dcp.h +++ b/rtengine/dcp.h @@ -26,11 +26,12 @@ #include +#include "../rtgui/threadutils.h" + #include "imagefloat.h" #include "curves.h" #include "colortemp.h" - -#include "../rtgui/threadutils.h" +#include "noncopyable.h" namespace rtengine { @@ -145,14 +146,12 @@ private: AdobeToneCurve tone_curve; }; -class DCPStore final +class DCPStore final : + public NonCopyable { public: static DCPStore* getInstance(); - DCPStore(const DCPStore& other) = delete; - DCPStore& operator =(const DCPStore& other) = delete; - void init(const Glib::ustring& rt_profile_dir); bool isValidDCPFileName(const Glib::ustring& filename) const; diff --git a/rtengine/jaggedarray.h b/rtengine/jaggedarray.h index 4d01747da..153ed2902 100644 --- a/rtengine/jaggedarray.h +++ b/rtengine/jaggedarray.h @@ -17,8 +17,9 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#ifndef JAGGEDARRAY_H -#define JAGGEDARRAY_H +#pragma once + +#include "noncopyable.h" namespace rtengine { @@ -50,7 +51,8 @@ inline void freeJaggedArray (T** const a) } template -class JaggedArray +class JaggedArray : + public NonCopyable { public: JaggedArray (const int W, const int H, const bool initZero = false) @@ -65,10 +67,6 @@ public: } } - JaggedArray (const JaggedArray&) = delete; - JaggedArray& operator= (const JaggedArray&) = delete; - -public: operator T** const () const { return a; @@ -85,5 +83,3 @@ template void freeJaggedArray (JaggedArray&); } // rtengine - -#endif // JAGGEDARRAY_H diff --git a/rtengine/noncopyable.h b/rtengine/noncopyable.h new file mode 100644 index 000000000..d34c42441 --- /dev/null +++ b/rtengine/noncopyable.h @@ -0,0 +1,34 @@ +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2016 Flössie + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ + +#pragma once + +namespace rtengine +{ + +class NonCopyable +{ +public: + NonCopyable() = default; + + explicit NonCopyable(const NonCopyable&) = delete; + NonCopyable& operator =(const NonCopyable&) = delete; +}; + +} diff --git a/rtengine/procparams.h b/rtengine/procparams.h index cf02b9f10..d51c032c0 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -19,11 +19,13 @@ #ifndef _PROCPARAMS_H_ #define _PROCPARAMS_H_ -#include #include #include #include + +#include #include + #include "LUT.h" #include "coord.h" @@ -1363,7 +1365,7 @@ class PartialProfile public: rtengine::procparams::ProcParams* pparams; ParamsEdited* pedited; - PartialProfile& operator=(PartialProfile& rhs) + PartialProfile& operator =(const PartialProfile& rhs) { pparams = rhs.pparams; pedited = rhs.pedited; diff --git a/rtengine/rawimage.h b/rtengine/rawimage.h index 26ddbfd1b..45e67cbac 100644 --- a/rtengine/rawimage.h +++ b/rtengine/rawimage.h @@ -20,8 +20,10 @@ #define __RAWIMAGE_H #include + #include "dcraw.h" #include "imageio.h" +#include "noncopyable.h" namespace rtengine { @@ -32,7 +34,8 @@ struct badPix { badPix( uint16_t xc, uint16_t yc ): x(xc), y(yc) {} }; -class PixelsMap +class PixelsMap : + public NonCopyable { int w; // line width in base_t units int h; // height @@ -49,8 +52,6 @@ public: memset(pm, 0, h * w * base_t_size ); } - PixelsMap(const PixelsMap&) = delete; - ~PixelsMap() { delete [] pm; diff --git a/rtengine/shmap.h b/rtengine/shmap.h index 990193378..9bb496b54 100644 --- a/rtengine/shmap.h +++ b/rtengine/shmap.h @@ -21,11 +21,13 @@ #include "imagefloat.h" #include "image16.h" +#include "noncopyable.h" namespace rtengine { -class SHMap +class SHMap : + public NonCopyable { public: @@ -33,8 +35,6 @@ public: float max_f, min_f, avg; SHMap (int w, int h, bool multiThread); - SHMap(const SHMap&) = delete; - ~SHMap (); void update (Imagefloat* img, double radius, double lumi[3], bool hq, int skip); diff --git a/rtexif/rtexif.h b/rtexif/rtexif.h index ea57ada73..02d357a5d 100644 --- a/rtexif/rtexif.h +++ b/rtexif/rtexif.h @@ -28,7 +28,9 @@ #include #include #include + #include "../rtengine/procparams.h" +#include "../rtengine/noncopyable.h" class CacheImageData; @@ -178,7 +180,8 @@ public: }; // a class representing a single tag -class Tag +class Tag : + public rtengine::NonCopyable { protected: @@ -202,7 +205,6 @@ public: Tag (TagDirectory* parent, const TagAttrib* attr, unsigned char *data, TagType t); Tag (TagDirectory* parent, const TagAttrib* attr, int data, TagType t); // create a new tag from array (used Tag (TagDirectory* parent, const TagAttrib* attr, const char* data); // create a new tag from array (used - Tag(const Tag&) = delete; ~Tag (); void initType (unsigned char *data, TagType type); diff --git a/rtgui/cachemanager.h b/rtgui/cachemanager.h index 4460204cc..99c732e88 100644 --- a/rtgui/cachemanager.h +++ b/rtgui/cachemanager.h @@ -24,11 +24,14 @@ #include +#include "../rtengine/noncopyable.h" + #include "threadutils.h" class Thumbnail; -class CacheManager +class CacheManager : + public rtengine::NonCopyable { private: using Entries = std::map; @@ -41,12 +44,7 @@ private: void applyCacheSizeLimitation () const; - CacheManager () = default; - CacheManager (const CacheManager&) = delete; - CacheManager& operator= (const CacheManager&) = delete; - public: - static CacheManager* getInstance (); void init (); @@ -69,7 +67,6 @@ public: const Glib::ustring& fname, const Glib::ustring& fext, const Glib::ustring& md5) const; - }; #define cacheMgr CacheManager::getInstance() diff --git a/rtgui/previewloader.cc b/rtgui/previewloader.cc index e7b37cac6..c38fed49d 100644 --- a/rtgui/previewloader.cc +++ b/rtgui/previewloader.cc @@ -29,7 +29,8 @@ #define DEBUG(format,args...) //#define DEBUG(format,args...) printf("PreviewLoader::%s: " format "\n", __FUNCTION__, ## args) -class PreviewLoader::Impl +class PreviewLoader::Impl : + public rtengine::NonCopyable { public: struct Job { @@ -81,8 +82,6 @@ public: threadPool_ = new Glib::ThreadPool(threadCount, 0); } - Impl(const Impl&) = delete; - Glib::ThreadPool* threadPool_; MyMutex mutex_; JobSet jobs_; diff --git a/rtgui/previewloader.h b/rtgui/previewloader.h index 05669d399..d5207cd44 100644 --- a/rtgui/previewloader.h +++ b/rtgui/previewloader.h @@ -21,11 +21,17 @@ #include #include + +#include "../rtengine/noncopyable.h" + #include "filebrowserentry.h" class PreviewLoaderListener { public: + virtual ~PreviewLoaderListener() + { + } /** * @brief a preview is ready @@ -33,20 +39,22 @@ public: * @param dir_id directory ID this is for * @param fd entry */ - virtual void previewReady (int dir_id, FileBrowserEntry* fd) {} + virtual void previewReady(int dir_id, FileBrowserEntry* fd) + { + } /** * @brief all previews have finished loading */ - virtual void previewsFinished (int dir_id_) {} + virtual void previewsFinished(int dir_id_) + { + } }; -class PreviewLoader +class PreviewLoader : + public rtengine::NonCopyable { public: - - PreviewLoader(const PreviewLoader&) = delete; - /** * @brief Singleton entry point. * diff --git a/rtgui/profilestore.h b/rtgui/profilestore.h index 0304db330..05a0a3797 100644 --- a/rtgui/profilestore.h +++ b/rtgui/profilestore.h @@ -21,11 +21,14 @@ #include #include +#include + #include "../rtengine/rtengine.h" +#include "../rtengine/noncopyable.h" + #include "threadutils.h" #include "paramsedited.h" #include "guiutils.h" -#include /** @brief This will implement callback functions for the ProfileStore @@ -118,7 +121,8 @@ public: * This store can be queried by the GUI to display a Tree of the profiles available * in the user's and system's profile directory and subdirectories. */ -class ProfileStore +class ProfileStore : + public rtengine::NonCopyable { typedef enum { @@ -176,9 +180,8 @@ private: public: ProfileStore(); - ProfileStore (const ProfileStore&) = delete; - ~ProfileStore(); + bool init (); void parseProfiles (); int findFolderId(const Glib::ustring &path); diff --git a/rtgui/threadutils.h b/rtgui/threadutils.h index 03203db82..1215d53a1 100644 --- a/rtgui/threadutils.h +++ b/rtgui/threadutils.h @@ -27,6 +27,8 @@ #include +#include "../rtengine/noncopyable.h" + #if STRICT_MUTEX && NDEBUG using MyMutexBase = Glib::Threads::Mutex; #else @@ -41,15 +43,13 @@ using MyMutexBase = Glib::Threads::RecMutex; * It will behave like Glib::Threads::RecMutex (STRICT_MUTEX=0) or Glib::Threads::Mutex (STRICT_MUTEX=1). * Debug builds with strict mutexes, will emit a message and crash immediately upon recursive locking. */ -class MyMutex : private MyMutexBase +class MyMutex : + public rtengine::NonCopyable, + private MyMutexBase { public: class MyLock; - MyMutex () = default; - MyMutex (const MyMutex&) = delete; - MyMutex& operator= (const MyMutex&) = delete; - void lock (); bool trylock (); void unlock (); @@ -62,7 +62,8 @@ private: #endif }; -class MyMutex::MyLock +class MyMutex::MyLock : + public rtengine::NonCopyable { public: explicit MyLock (MyMutex& mutex); @@ -71,9 +72,6 @@ public: ~MyLock (); - MyLock (const MyLock&) = delete; - MyLock& operator= (const MyLock&) = delete; - void acquire (); bool try_acquire (); void release (); @@ -86,13 +84,10 @@ private: /** * @brief Custom implementation to replace Glib::Threads::RWLock */ -class MyRWMutex +class MyRWMutex : + public rtengine::NonCopyable { public: - MyRWMutex () = default; - MyRWMutex (const MyRWMutex&) = delete; - MyRWMutex& operator= (const MyRWMutex&) = delete; - friend class MyReaderLock; friend class MyWriterLock; @@ -113,14 +108,12 @@ private: /** * @brief Custom implementation to replace Glib::Threads::RWLock::ReaderLock */ -class MyReaderLock +class MyReaderLock : + public rtengine::NonCopyable { public: ~MyReaderLock (); - MyReaderLock (const MyReaderLock&) = delete; - MyReaderLock& operator= (const MyReaderLock&) = delete; - #if !TRACE_MYRWMUTEX explicit MyReaderLock (MyRWMutex& mutex); @@ -141,14 +134,12 @@ private: /** * @brief Custom implementation to replace Glib::Threads::RWLock::WriterLock */ -class MyWriterLock +class MyWriterLock : + public rtengine::NonCopyable { public: ~MyWriterLock (); - MyWriterLock (const MyWriterLock&) = delete; - MyWriterLock& operator= (const MyWriterLock&) = delete; - #if !TRACE_MYRWMUTEX explicit MyWriterLock (MyRWMutex& mutex); diff --git a/rtgui/thumbimageupdater.cc b/rtgui/thumbimageupdater.cc index a247af5f8..39711a5ae 100644 --- a/rtgui/thumbimageupdater.cc +++ b/rtgui/thumbimageupdater.cc @@ -30,8 +30,8 @@ #define DEBUG(format,args...) //#define DEBUG(format,args...) printf("ThumbImageUpdate::%s: " format "\n", __FUNCTION__, ## args) -class - ThumbImageUpdater::Impl +class ThumbImageUpdater::Impl : + public rtengine::NonCopyable { public: @@ -78,8 +78,6 @@ public: threadPool_ = new Glib::ThreadPool(threadCount, 0); } - Impl(const Impl&) = delete; - Glib::ThreadPool* threadPool_; // Need to be a Glib::Threads::Mutex because used in a Glib::Threads::Cond object... diff --git a/rtgui/thumbimageupdater.h b/rtgui/thumbimageupdater.h index 8d1fc2cc5..3b34c9456 100644 --- a/rtgui/thumbimageupdater.h +++ b/rtgui/thumbimageupdater.h @@ -20,14 +20,19 @@ #define _THUMBIMAGEUPDATER_ #include -#include "../rtengine/rtengine.h" -#include "thumbbrowserentrybase.h" #include +#include "../rtengine/rtengine.h" +#include "../rtengine/noncopyable.h" + +#include "thumbbrowserentrybase.h" + class ThumbImageUpdateListener { - public: + virtual ~ThumbImageUpdateListener() + { + } /** * @brief Called when thumbnail image is update @@ -38,16 +43,15 @@ public: * * @note no locks are held when called back */ - virtual void updateImage (rtengine::IImage8* img, double scale, rtengine::procparams::CropParams cropParams) {} + virtual void updateImage(rtengine::IImage8* img, double scale, rtengine::procparams::CropParams cropParams) + { + } }; -class ThumbImageUpdater +class ThumbImageUpdater : + public rtengine::NonCopyable { - public: - - ThumbImageUpdater(const ThumbImageUpdater&) = delete; - /** * @brief Singleton entry point. *