cppcheck: further fixes

This commit is contained in:
Ingo Weyrich 2019-08-06 22:10:38 +02:00
parent 96bf78fe87
commit 4fedfb2b26
10 changed files with 101 additions and 134 deletions

View File

@ -204,10 +204,8 @@ void Crop::update(int todo)
} }
int numtiles_W, numtiles_H, tilewidth, tileheight, tileWskip, tileHskip; int numtiles_W, numtiles_H, tilewidth, tileheight, tileWskip, tileHskip;
int kall = 2;
parent->ipf.Tile_calc(tilesize, overlap, kall, widIm, heiIm, numtiles_W, numtiles_H, tilewidth, tileheight, tileWskip, tileHskip); parent->ipf.Tile_calc(tilesize, overlap, 2, widIm, heiIm, numtiles_W, numtiles_H, tilewidth, tileheight, tileWskip, tileHskip);
kall = 0;
float *min_b = new float [9]; float *min_b = new float [9];
float *min_r = new float [9]; float *min_r = new float [9];
@ -653,10 +651,9 @@ void Crop::update(int todo)
if (todo & M_LINDENOISE) { if (todo & M_LINDENOISE) {
if (skip == 1 && denoiseParams.enabled) { if (skip == 1 && denoiseParams.enabled) {
int kall = 0;
float nresi, highresi; float nresi, highresi;
parent->ipf.RGB_denoise(kall, origCrop, origCrop, calclum, parent->denoiseInfoStore.ch_M, parent->denoiseInfoStore.max_r, parent->denoiseInfoStore.max_b, parent->imgsrc->isRAW(), /*Roffset,*/ denoiseParams, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, nresi, highresi); parent->ipf.RGB_denoise(0, origCrop, origCrop, calclum, parent->denoiseInfoStore.ch_M, parent->denoiseInfoStore.max_r, parent->denoiseInfoStore.max_b, parent->imgsrc->isRAW(), /*Roffset,*/ denoiseParams, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, nresi, highresi);
if (parent->adnListener) { if (parent->adnListener) {
parent->adnListener->noiseChanged(nresi, highresi); parent->adnListener->noiseChanged(nresi, highresi);
@ -885,9 +882,6 @@ void Crop::update(int todo)
if (skip == 1) { if (skip == 1) {
if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) { if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) {
parent->ipf.impulsedenoise(labnCrop); parent->ipf.impulsedenoise(labnCrop);
}
if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) {
parent->ipf.defringe(labnCrop); parent->ipf.defringe(labnCrop);
} }
@ -900,7 +894,6 @@ void Crop::update(int todo)
} }
// if (skip==1) { // if (skip==1) {
WaveletParams WaveParams = params.wavelet;
if (params.dirpyrequalizer.cbdlMethod == "aft") { if (params.dirpyrequalizer.cbdlMethod == "aft") {
if (((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled))) { if (((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled))) {
@ -909,6 +902,8 @@ void Crop::update(int todo)
} }
} }
if ((params.wavelet.enabled)) {
WaveletParams WaveParams = params.wavelet;
int kall = 0; int kall = 0;
int minwin = min(labnCrop->W, labnCrop->H); int minwin = min(labnCrop->W, labnCrop->H);
int maxlevelcrop = 10; int maxlevelcrop = 10;
@ -976,14 +971,12 @@ void Crop::update(int todo)
parent->awavListener->wavChanged(float (maxL)); parent->awavListener->wavChanged(float (maxL));
} }
if ((params.wavelet.enabled)) {
WavCurve wavCLVCurve; WavCurve wavCLVCurve;
WavOpacityCurveRG waOpacityCurveRG; WavOpacityCurveRG waOpacityCurveRG;
WavOpacityCurveBY waOpacityCurveBY; WavOpacityCurveBY waOpacityCurveBY;
WavOpacityCurveW waOpacityCurveW; WavOpacityCurveW waOpacityCurveW;
WavOpacityCurveWL waOpacityCurveWL; WavOpacityCurveWL waOpacityCurveWL;
LUTf wavclCurve; LUTf wavclCurve;
LUTu dummy;
params.wavelet.getCurves(wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL); params.wavelet.getCurves(wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL);

View File

@ -230,7 +230,6 @@ void DiagonalCurve::NURBS_set ()
poly_x.clear(); poly_x.clear();
poly_y.clear(); poly_y.clear();
unsigned int sc_xsize = j - 1; unsigned int sc_xsize = j - 1;
j = 0;
// adding the initial horizontal segment, if any // adding the initial horizontal segment, if any
if (x[0] > 0.) { if (x[0] > 0.) {
@ -314,18 +313,13 @@ inline void catmull_rom_spline(int n_points,
double space = (t2-t1) / n_points; double space = (t2-t1) / n_points;
double t;
int i;
double c, d, A1_x, A1_y, A2_x, A2_y, A3_x, A3_y;
double B1_x, B1_y, B2_x, B2_y, C_x, C_y;
res_x.push_back(p1_x); res_x.push_back(p1_x);
res_y.push_back(p1_y); res_y.push_back(p1_y);
// special case, a segment at 0 or 1 is computed exactly // special case, a segment at 0 or 1 is computed exactly
if (p1_y == p2_y && (p1_y == 0 || p1_y == 1)) { if (p1_y == p2_y && (p1_y == 0 || p1_y == 1)) {
for (i = 1; i < n_points-1; ++i) { for (int i = 1; i < n_points-1; ++i) {
t = p1_x + space * i; double t = p1_x + space * i;
if (t >= p2_x) { if (t >= p2_x) {
break; break;
} }
@ -333,38 +327,38 @@ inline void catmull_rom_spline(int n_points,
res_y.push_back(p1_y); res_y.push_back(p1_y);
} }
} else { } else {
for (i = 1; i < n_points-1; ++i) { for (int i = 1; i < n_points-1; ++i) {
t = t1 + space * i; double t = t1 + space * i;
c = (t1 - t)/(t1 - t0); double c = (t1 - t)/(t1 - t0);
d = (t - t0)/(t1 - t0); double d = (t - t0)/(t1 - t0);
A1_x = c * p0_x + d * p1_x; double A1_x = c * p0_x + d * p1_x;
A1_y = c * p0_y + d * p1_y; double A1_y = c * p0_y + d * p1_y;
c = (t2 - t)/(t2 - t1); c = (t2 - t)/(t2 - t1);
d = (t - t1)/(t2 - t1); d = (t - t1)/(t2 - t1);
A2_x = c * p1_x + d * p2_x; double A2_x = c * p1_x + d * p2_x;
A2_y = c * p1_y + d * p2_y; double A2_y = c * p1_y + d * p2_y;
c = (t3 - t)/(t3 - t2); c = (t3 - t)/(t3 - t2);
d = (t - t2)/(t3 - t2); d = (t - t2)/(t3 - t2);
A3_x = c * p2_x + d * p3_x; double A3_x = c * p2_x + d * p3_x;
A3_y = c * p2_y + d * p3_y; double A3_y = c * p2_y + d * p3_y;
c = (t2 - t)/(t2 - t0); c = (t2 - t)/(t2 - t0);
d = (t - t0)/(t2 - t0); d = (t - t0)/(t2 - t0);
B1_x = c * A1_x + d * A2_x; double B1_x = c * A1_x + d * A2_x;
B1_y = c * A1_y + d * A2_y; double B1_y = c * A1_y + d * A2_y;
c = (t3 - t)/(t3 - t1); c = (t3 - t)/(t3 - t1);
d = (t - t1)/(t3 - t1); d = (t - t1)/(t3 - t1);
B2_x = c * A2_x + d * A3_x; double B2_x = c * A2_x + d * A3_x;
B2_y = c * A2_y + d * A3_y; double B2_y = c * A2_y + d * A3_y;
c = (t2 - t)/(t2 - t1); c = (t2 - t)/(t2 - t1);
d = (t - t1)/(t2 - t1); d = (t - t1)/(t2 - t1);
C_x = c * B1_x + d * B2_x; double C_x = c * B1_x + d * B2_x;
C_y = c * B1_y + d * B2_y; double C_y = c * B1_y + d * B2_y;
res_x.push_back(C_x); res_x.push_back(C_x);
res_y.push_back(C_y); res_y.push_back(C_y);
@ -512,7 +506,6 @@ double DiagonalCurve::getVal (double t) const
++d; ++d;
} }
return LIM01(*(poly_y.begin() + d)); return LIM01(*(poly_y.begin() + d));
break;
} }
case DCT_NURBS : { case DCT_NURBS : {

View File

@ -329,8 +329,8 @@ void RawImageSource::getAutoMatchedToneCurve(const ColorManagementParams &cp, st
int tw = target->getWidth(), th = target->getHeight(); int tw = target->getWidth(), th = target->getHeight();
float thumb_ratio = float(std::max(sw, sh)) / float(std::min(sw, sh)); float thumb_ratio = float(std::max(sw, sh)) / float(std::min(sw, sh));
float target_ratio = float(std::max(tw, th)) / float(std::min(tw, th)); float target_ratio = float(std::max(tw, th)) / float(std::min(tw, th));
int cx = 0, cy = 0;
if (std::abs(thumb_ratio - target_ratio) > 0.01) { if (std::abs(thumb_ratio - target_ratio) > 0.01) {
int cx = 0, cy = 0;
if (thumb_ratio > target_ratio) { if (thumb_ratio > target_ratio) {
// crop the height // crop the height
int ch = th - (tw * float(sh) / float(sw)); int ch = th - (tw * float(sh) / float(sw));

View File

@ -435,12 +435,7 @@ static void calcGradientParams (int oW, int oH, const GradientParams& gradient,
if (gp.transpose) { if (gp.transpose) {
gp.bright_top = !gp.bright_top; gp.bright_top = !gp.bright_top;
} std::swap(w, h);
if (gp.transpose) {
int tmp = w;
w = h;
h = tmp;
} }
gp.scale = 1.0 / pow (2, gradient_stops); gp.scale = 1.0 / pow (2, gradient_stops);

View File

@ -2198,8 +2198,6 @@ void CropWindow::updateHoveredPicker (rtengine::Coord *imgPos)
} }
rtengine::Coord cropPos; rtengine::Coord cropPos;
float r=0.f, g=0.f, b=0.f;
float rpreview=0.f, gpreview=0.f, bpreview=0.f;
if (imgPos) { if (imgPos) {
imageCoordToCropImage(imgPos->x, imgPos->y, cropPos.x, cropPos.y); imageCoordToCropImage(imgPos->x, imgPos->y, cropPos.x, cropPos.y);
hoveredPicker->setPosition (*imgPos); hoveredPicker->setPosition (*imgPos);
@ -2215,6 +2213,8 @@ void CropWindow::updateHoveredPicker (rtengine::Coord *imgPos)
MyMutex::MyLock lock(cropHandler.cimg); MyMutex::MyLock lock(cropHandler.cimg);
if (validity == LockableColorPicker::Validity::INSIDE) { if (validity == LockableColorPicker::Validity::INSIDE) {
float r=0.f, g=0.f, b=0.f;
float rpreview=0.f, gpreview=0.f, bpreview=0.f;
cropHandler.colorPick(cropPos, r, g, b, rpreview, gpreview, bpreview, hoveredPicker->getSize()); cropHandler.colorPick(cropPos, r, g, b, rpreview, gpreview, bpreview, hoveredPicker->getSize());
hoveredPicker->setRGB (r, g, b, rpreview, gpreview, bpreview); hoveredPicker->setRGB (r, g, b, rpreview, gpreview, bpreview);
} }

View File

@ -26,9 +26,8 @@ using namespace rtengine;
using namespace rtengine::procparams; using namespace rtengine::procparams;
MetaDataPanel::MetaDataPanel() MetaDataPanel::MetaDataPanel() : EvMetaDataMode(ProcEventMapper::getInstance()->newEvent(M_VOID, "HISTORY_MSG_METADATA_MODE"))
{ {
EvMetaDataMode = ProcEventMapper::getInstance()->newEvent(M_VOID, "HISTORY_MSG_METADATA_MODE");
Gtk::HBox *box = Gtk::manage(new Gtk::HBox()); Gtk::HBox *box = Gtk::manage(new Gtk::HBox());
box->pack_start(*Gtk::manage(new Gtk::Label(M("TP_METADATA_MODE") + ": ")), Gtk::PACK_SHRINK, 4); box->pack_start(*Gtk::manage(new Gtk::Label(M("TP_METADATA_MODE") + ": ")), Gtk::PACK_SHRINK, 4);

View File

@ -637,13 +637,8 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event)
setDirty(true); setDirty(true);
draw (lit_point); draw (lit_point);
new_type = CSArrow; new_type = CSArrow;
retval = true;
} }
} }
if (buttonPressed) {
retval = true;
}
} else { // if (edited_point > -1) } else { // if (edited_point > -1)
if (event->button.button == 3) { if (event->button.button == 3) {
// do we edit another point? // do we edit another point?
@ -679,7 +674,6 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event)
newBoundaries.at(1).minVal = 0.; newBoundaries.at(1).minVal = 0.;
newBoundaries.at(1).maxVal = 1.; newBoundaries.at(1).maxVal = 1.;
retval = true;
editedPos.at(0) = curve.x.at(edited_point); editedPos.at(0) = curve.x.at(edited_point);
editedPos.at(1) = curve.y.at(edited_point); editedPos.at(1) = curve.y.at(edited_point);
coordinateAdjuster->switchAdjustedPoint(editedPos, newBoundaries); coordinateAdjuster->switchAdjustedPoint(editedPos, newBoundaries);

View File

@ -556,7 +556,7 @@ bool MyFlatCurve::getHandles(int n)
if (!n) { if (!n) {
// first point, the left handle is then computed with the last point's right handle // first point, the left handle is then computed with the last point's right handle
prevX = curve.x.at(N - 1) - 1.0; prevX = curve.x.at(N - 1) - 1.0;
nextX = curve.x.at(n + 1); nextX = curve.x.at(1);
} else if (n == N - 1) { } else if (n == N - 1) {
// last point, the right handle is then computed with the first point's left handle // last point, the right handle is then computed with the first point's left handle
prevX = curve.x.at(n - 1); prevX = curve.x.at(n - 1);
@ -745,7 +745,6 @@ bool MyFlatCurve::handleEvents (GdkEvent* event)
newBoundaries.at(2).maxVal = 1.; newBoundaries.at(2).maxVal = 1.;
newBoundaries.at(3).minVal = 0.; newBoundaries.at(3).minVal = 0.;
newBoundaries.at(3).maxVal = 1.; newBoundaries.at(3).maxVal = 1.;
retval = true;
editedPos.at(0) = curve.x.at(edited_point); editedPos.at(0) = curve.x.at(edited_point);
editedPos.at(1) = curve.y.at(edited_point); editedPos.at(1) = curve.y.at(edited_point);
editedPos.at(2) = curve.leftTangent.at(edited_point); editedPos.at(2) = curve.leftTangent.at(edited_point);

View File

@ -1112,20 +1112,17 @@ void ParamsEdited::initFrom(const std::vector<rtengine::procparams::ProcParams>&
wavelet.exptoning = wavelet.exptoning && p.wavelet.exptoning == other.wavelet.exptoning; wavelet.exptoning = wavelet.exptoning && p.wavelet.exptoning == other.wavelet.exptoning;
wavelet.expnoise = wavelet.expnoise && p.wavelet.expnoise == other.wavelet.expnoise; wavelet.expnoise = wavelet.expnoise && p.wavelet.expnoise == other.wavelet.expnoise;
for (int i = 0; i < 9; i++) { for (int level = 0; level < 9; ++level) {
wavelet.c[i] = wavelet.c[i] && p.wavelet.c[i] == other.wavelet.c[i]; wavelet.c[level] = wavelet.c[level] && p.wavelet.c[level] == other.wavelet.c[level];
} wavelet.ch[level] = wavelet.ch[level] && p.wavelet.ch[level] == other.wavelet.ch[level];
for (int i = 0; i < 9; i++) {
wavelet.ch[i] = wavelet.ch[i] && p.wavelet.ch[i] == other.wavelet.ch[i];
} }
dirpyrequalizer.enabled = dirpyrequalizer.enabled && p.dirpyrequalizer.enabled == other.dirpyrequalizer.enabled; dirpyrequalizer.enabled = dirpyrequalizer.enabled && p.dirpyrequalizer.enabled == other.dirpyrequalizer.enabled;
dirpyrequalizer.gamutlab = dirpyrequalizer.gamutlab && p.dirpyrequalizer.gamutlab == other.dirpyrequalizer.gamutlab; dirpyrequalizer.gamutlab = dirpyrequalizer.gamutlab && p.dirpyrequalizer.gamutlab == other.dirpyrequalizer.gamutlab;
dirpyrequalizer.cbdlMethod = dirpyrequalizer.cbdlMethod && p.dirpyrequalizer.cbdlMethod == other.dirpyrequalizer.cbdlMethod; dirpyrequalizer.cbdlMethod = dirpyrequalizer.cbdlMethod && p.dirpyrequalizer.cbdlMethod == other.dirpyrequalizer.cbdlMethod;
for (int i = 0; i < 6; i++) { for (int level = 0; level < 6; ++level) {
dirpyrequalizer.mult[i] = dirpyrequalizer.mult[i] && p.dirpyrequalizer.mult[i] == other.dirpyrequalizer.mult[i]; dirpyrequalizer.mult[level] = dirpyrequalizer.mult[level] && p.dirpyrequalizer.mult[level] == other.dirpyrequalizer.mult[level];
} }
dirpyrequalizer.threshold = dirpyrequalizer.threshold && p.dirpyrequalizer.threshold == other.dirpyrequalizer.threshold; dirpyrequalizer.threshold = dirpyrequalizer.threshold && p.dirpyrequalizer.threshold == other.dirpyrequalizer.threshold;

View File

@ -232,8 +232,6 @@ const ProcParams& Thumbnail::getProcParamsU ()
rtengine::procparams::ProcParams* Thumbnail::createProcParamsForUpdate(bool returnParams, bool force, bool flaggingMode) rtengine::procparams::ProcParams* Thumbnail::createProcParamsForUpdate(bool returnParams, bool force, bool flaggingMode)
{ {
static int index = 0; // Will act as unique identifier during the session
// try to load the last saved parameters from the cache or from the paramfile file // try to load the last saved parameters from the cache or from the paramfile file
ProcParams* ldprof = nullptr; ProcParams* ldprof = nullptr;
@ -285,6 +283,7 @@ rtengine::procparams::ProcParams* Thumbnail::createProcParamsForUpdate(bool retu
imageMetaData = rtengine::FramesMetaData::fromFile (fname, nullptr, true); imageMetaData = rtengine::FramesMetaData::fromFile (fname, nullptr, true);
} }
static int index = 0; // Will act as unique identifier during the session
Glib::ustring tmpFileName( Glib::build_filename(options.cacheBaseDir, Glib::ustring::compose("CPB_temp_%1.txt", index++)) ); Glib::ustring tmpFileName( Glib::build_filename(options.cacheBaseDir, Glib::ustring::compose("CPB_temp_%1.txt", index++)) );
const rtexif::TagDirectory* exifDir = nullptr; const rtexif::TagDirectory* exifDir = nullptr;
@ -1020,9 +1019,7 @@ int Thumbnail::getRank () const
void Thumbnail::setRank (int rank) void Thumbnail::setRank (int rank)
{ {
if (pparams->rank != rank) {
pparams->rank = rank; pparams->rank = rank;
}
pparamsValid = true; pparamsValid = true;
} }