diff --git a/rtengine/array2D.h b/rtengine/array2D.h index c05c739dc..9645a3a6e 100644 --- a/rtengine/array2D.h +++ b/rtengine/array2D.h @@ -113,7 +113,7 @@ public: // use as empty declaration, resize before use! // very useful as a member object array2D() : - x(0), y(0), owner(0), flags(0), ptr(nullptr), data(nullptr), lock(0) + x(0), y(0), owner(0), flags(0), ptr(nullptr), data(nullptr), lock(false) { //printf("got empty array2D init\n"); } @@ -143,7 +143,7 @@ public: { flags = flgs; //if (lock) { printf("array2D attempt to overwrite data\n");raise(SIGSEGV);} - lock |= flags & ARRAY2D_LOCK_DATA; + lock = flags & ARRAY2D_LOCK_DATA; // when by reference // TODO: improve this code with ar_realloc() owner = (flags & ARRAY2D_BYREFERENCE) ? 0 : 1; diff --git a/rtengine/color.cc b/rtengine/color.cc index f045a84d9..0da74d1c0 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -773,37 +773,38 @@ void Color::hsl2rgb01 (float h, float s, float l, float &r, float &g, float &b) void Color::rgb2hsv(float r, float g, float b, float &h, float &s, float &v) { - double var_R = r / 65535.0; - double var_G = g / 65535.0; - double var_B = b / 65535.0; + const double var_R = r / 65535.0; + const double var_G = g / 65535.0; + const double var_B = b / 65535.0; - double var_Min = min(var_R, var_G, var_B); - double var_Max = max(var_R, var_G, var_B); - double del_Max = var_Max - var_Min; + const double var_Min = min(var_R, var_G, var_B); + const double var_Max = max(var_R, var_G, var_B); + const double del_Max = var_Max - var_Min; + + h = 0.f; v = var_Max; if (del_Max < 0.00001 && del_Max > -0.00001) { // no fabs, slow! - h = 0; - s = 0; + s = 0.f; } else { s = del_Max / var_Max; - if ( var_R == var_Max ) { + if (var_R == var_Max) { h = (var_G - var_B) / del_Max; - } else if ( var_G == var_Max ) { + } else if (var_G == var_Max) { h = 2.0 + (var_B - var_R) / del_Max; - } else if ( var_B == var_Max ) { + } else if (var_B == var_Max) { h = 4.0 + (var_R - var_G) / del_Max; } - h /= 6.0; + h /= 6.f; - if ( h < 0 ) { - h += 1; + if (h < 0.f) { + h += 1.f; } - if ( h > 1 ) { - h -= 1; + if (h > 1.f) { + h -= 1.f; } } } diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 351ce1f08..4b725ea8f 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -397,12 +397,8 @@ void Crop::update (int todo) MyTime t1aue, t2aue; t1aue.set(); - int crW, crH; - - if(settings->leveldnv == 0) { - crW = 100; - crH = 100; - } + int crW = 100; // settings->leveldnv == 0 + int crH = 100; // settings->leveldnv == 0 if(settings->leveldnv == 1) { crW = 250; @@ -1143,7 +1139,7 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte ProcParams& params = parent->params; parent->ipf.transCoord (parent->fw, parent->fh, bx1, by1, bw, bh, orx, ory, orw, orh); - + if (check_need_larger_crop_for_lcp_distortion(parent->fw, parent->fh, orx, ory, orw, orh, parent->params)) { // TODO - this is an estimate of the max distortion relative to the image size. ATM it is hardcoded to be 15%, which seems enough. If not, need to revise int dW = int(double(parent->fw) * 0.15 / (2 * skip)); @@ -1173,7 +1169,7 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte orw = min(x2 - x1, parent->fw - orx); orh = min(y2 - y1, parent->fh - ory); } - + PreviewProps cp (orx, ory, orw, orh, skip); int orW, orH; diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index 321298349..24567205f 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -273,8 +273,9 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } - float varx = 0.f; - float limdx, ilimdx; + float varx = vart; + float limdx = limD; + float ilimdx = ilimD; if(gradvart != 0) { if(gradvart == 1) { @@ -294,10 +295,6 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e limdx = limD * (0.4f * it + 0.6f); ilimdx = 1.f / limdx; } - } else { - varx = vart; - limdx = limD; - ilimdx = ilimD; } scal = round(sc); diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index 5d899617b..d981c803d 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -1253,7 +1253,8 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int delete [] meanN; delete [] sigma; delete [] sigmaN; - + delete [] MaxP; + delete [] MaxN; } #ifdef _RT_NESTED_OPENMP omp_set_nested(oldNested); diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index 821194afe..0e7bcd0ed 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -737,7 +737,7 @@ void XMLCALL LCPProfile::XmlTextHandler(void *pLCPProfile, const XML_Char *s, in if (!pProf->inCamProfiles || pProf->inAlternateLensID || pProf->inAlternateLensNames || *pProf->inInvalidTag) { return; } - + for (int i = 0; i < len; ++i) { pProf->textbuf << s[i]; } @@ -746,8 +746,6 @@ void XMLCALL LCPProfile::XmlTextHandler(void *pLCPProfile, const XML_Char *s, in void LCPProfile::handle_text(std::string text) { - const char *raw = text.c_str(); - // Check if it contains non-whitespaces (there are several calls to this for one tag unfortunately) bool onlyWhiteSpace = true; for (size_t i = 0; i < text.size(); ++i) { @@ -766,6 +764,8 @@ void LCPProfile::handle_text(std::string text) // convert to null terminated char* tag = pProf->lastTag; + const char* raw = text.c_str(); + // Common data section if (!pProf->firstLIDone) { // Generic tags are the same for all diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index efbba78d1..2e1c60ff8 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -43,7 +43,7 @@ void adjust_radius(const T &default_param, double scale_factor, T ¶m) const double delta = (param - default_param) * scale_factor; param = default_param + delta; } - + class ImageProcessor { public: @@ -91,7 +91,7 @@ private: } pl = nullptr; - + if (!stage_init()) { return nullptr; } @@ -267,12 +267,8 @@ private: if(settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PON") { MyTime t1pone, t2pone; t1pone.set(); - int crW, crH; - - if(settings->leveldnv == 0) { - crW = 100; - crH = 100; - } + int crW = 100; // settings->leveldnv == 0 + int crH = 100; // settings->leveldnv == 0 if(settings->leveldnv == 1) { crW = 250; @@ -540,7 +536,7 @@ private: PreviewProps ppP (coordW[wcr] , coordH[hcr], crW, crH, 1); imgsrc->getImage (currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw); //baseImg->getStdImage(currWB, tr, origCropPart, ppP, true, params.toneCurve); - + // we only need image reduced to 1/4 here for(int ii = 0; ii < crH; ii += 2) { @@ -713,7 +709,7 @@ private: hlcompr = params.toneCurve.hlcompr; hlcomprthresh = params.toneCurve.hlcomprthresh; - + if (params.toneCurve.autoexp) { LUTu aehist; int aehistcompr; @@ -737,7 +733,7 @@ private: procparams::ProcParams& params = job->pparams; //ImProcFunctions ipf (¶ms, true); ImProcFunctions &ipf = *(ipf_p.get()); - + // perform luma/chroma denoise // CieImage *cieView; // NoisCurve noiseLCurve; @@ -801,7 +797,7 @@ private: { procparams::ProcParams& params = job->pparams; //ImProcFunctions ipf (¶ms, true); - ImProcFunctions &ipf = *(ipf_p.get()); + ImProcFunctions &ipf = *(ipf_p.get()); imgsrc->convertColorSpace(baseImg, params.icm, currWB); @@ -809,7 +805,7 @@ private: hist16 (65536); ipf.firstAnalysis (baseImg, params, hist16); - + // perform transform (excepted resizing) if (ipf.needsTransform()) { Imagefloat* trImg = new Imagefloat (fw, fh); @@ -824,7 +820,7 @@ private: { procparams::ProcParams& params = job->pparams; //ImProcFunctions ipf (¶ms, true); - ImProcFunctions &ipf = *(ipf_p.get()); + ImProcFunctions &ipf = *(ipf_p.get()); if (params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled) { const int W = baseImg->getWidth(); @@ -1350,8 +1346,8 @@ private: { procparams::ProcParams& params = job->pparams; //ImProcFunctions ipf (¶ms, true); - ImProcFunctions &ipf = *(ipf_p.get()); - + ImProcFunctions &ipf = *(ipf_p.get()); + int imw, imh; double scale_factor = ipf.resizeScale(¶ms, fw, fh, imw, imh); @@ -1387,7 +1383,7 @@ private: } adjust_procparams(scale_factor); - + fw = imw; fh = imh; @@ -1437,7 +1433,7 @@ private: } } } - + params.epd.scale *= scale_factor; //params.epd.edgeStopping *= scale_factor; @@ -1528,7 +1524,7 @@ private: LUTf gCurve; LUTf bCurve; LUTu dummy; - + ToneCurve customToneCurve1, customToneCurve2; ColorGradientCurve ctColorCurve; OpacityCurve ctOpacityCurve; diff --git a/rtgui/main-cli.cc b/rtgui/main-cli.cc index 2a2afca63..f6df47119 100644 --- a/rtgui/main-cli.cc +++ b/rtgui/main-cli.cc @@ -115,12 +115,12 @@ int main(int argc, char **argv) // get the path where the rawtherapee executable is stored #ifdef WIN32 WCHAR exnameU[512] = {0}; - GetModuleFileNameW (NULL, exnameU, 512); - WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 512, 0, 0 ); + GetModuleFileNameW (NULL, exnameU, 511); + WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 ); #else - if (readlink("/proc/self/exe", exname, 512) < 0) { - strncpy(exname, argv[0], 512); + if (readlink("/proc/self/exe", exname, 511) < 0) { + strncpy(exname, argv[0], 511); } #endif diff --git a/rtgui/main.cc b/rtgui/main.cc index 495374f50..0f4a96c8a 100644 --- a/rtgui/main.cc +++ b/rtgui/main.cc @@ -137,12 +137,12 @@ int main(int argc, char **argv) // get the path where the rawtherapee executable is stored #ifdef WIN32 WCHAR exnameU[512] = {0}; - GetModuleFileNameW (NULL, exnameU, 512); - WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 512, 0, 0 ); + GetModuleFileNameW (NULL, exnameU, 511); + WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 ); #else - if (readlink("/proc/self/exe", exname, 512) < 0) { - strncpy(exname, argv[0], 512); + if (readlink("/proc/self/exe", exname, 511) < 0) { + strncpy(exname, argv[0], 511); } #endif