diff --git a/rtengine/CA_correct_RT.cc b/rtengine/CA_correct_RT.cc index f4d082199..fa9788af0 100644 --- a/rtengine/CA_correct_RT.cc +++ b/rtengine/CA_correct_RT.cc @@ -790,12 +790,12 @@ float* RawImageSource::CA_correct_RT( for (int m = 0; m < polyord; m++) { double powHblock = powHblockInit; for (int n = 0; n < polyord; n++) { - polymat[c][dir][numpar * (polyord * i + j) + (polyord * m + n)] += powVblock * powHblock * blockwt[vblock * hblsz + hblock]; + polymat[c][dir][numpar * (polyord * i + j) + (polyord * m + n)] += powVblock * powHblock * static_cast(blockwt[vblock * hblsz + hblock]); powHblock *= hblock; } powVblock *= vblock; } - shiftmat[c][dir][(polyord * i + j)] += powVblockInit * powHblockInit * bstemp[dir] * blockwt[vblock * hblsz + hblock]; + shiftmat[c][dir][(polyord * i + j)] += powVblockInit * powHblockInit * static_cast(bstemp[dir]) * static_cast(blockwt[vblock * hblsz + hblock]); powHblockInit *= hblock; } powVblockInit *= vblock; @@ -848,7 +848,7 @@ float* RawImageSource::CA_correct_RT( for (int top = -border; top < height; top += ts - border2) { for (int left = -border; left < width - (W & 1); left += ts - border2) { memset(bufferThr, 0, buffersizePassTwo); - float lblockshifts[2][2]; + double lblockshifts[2][2]; const int vblock = ((top + border) / (ts - border2)) + 1; const int hblock = ((left + border) / (ts - border2)) + 1; const int bottom = min(top + ts, height + border); @@ -1036,8 +1036,8 @@ float* RawImageSource::CA_correct_RT( } if (!autoCA) { - float hfrac = -((float)(hblock - 0.5) / (hblsz - 2) - 0.5); - float vfrac = -((float)(vblock - 0.5) / (vblsz - 2) - 0.5) * height / width; + double hfrac = -((hblock - 0.5) / (hblsz - 2) - 0.5); + double vfrac = -((vblock - 0.5) / (vblsz - 2) - 0.5) * height / width; lblockshifts[0][0] = 2 * vfrac * cared; lblockshifts[0][1] = 2 * hfrac * cared; lblockshifts[1][0] = 2 * vfrac * cablue; @@ -1058,7 +1058,7 @@ float* RawImageSource::CA_correct_RT( } powVblock *= vblock; } - constexpr float bslim = 3.99; //max allowed CA shift + constexpr double bslim = 3.99f; //max allowed CA shift lblockshifts[0][0] = LIM(lblockshifts[0][0], -bslim, bslim); lblockshifts[0][1] = LIM(lblockshifts[0][1], -bslim, bslim); lblockshifts[1][0] = LIM(lblockshifts[1][0], -bslim, bslim); @@ -1070,14 +1070,14 @@ float* RawImageSource::CA_correct_RT( //some parameters for the bilinear interpolation shiftvfloor[c] = floor((float)lblockshifts[c>>1][0]); shiftvceil[c] = ceil((float)lblockshifts[c>>1][0]); - if (lblockshifts[c>>1][0] < 0.f) { + if (lblockshifts[c>>1][0] < 0.0) { std::swap(shiftvfloor[c], shiftvceil[c]); } shiftvfrac[c] = fabs(lblockshifts[c>>1][0] - shiftvfloor[c]); shifthfloor[c] = floor((float)lblockshifts[c>>1][1]); shifthceil[c] = ceil((float)lblockshifts[c>>1][1]); - if (lblockshifts[c>>1][1] < 0.f) { + if (lblockshifts[c>>1][1] < 0.0) { std::swap(shifthfloor[c], shifthceil[c]); } shifthfrac[c] = fabs(lblockshifts[c>>1][1] - shifthfloor[c]); diff --git a/rtengine/EdgePreservingDecomposition.cc b/rtengine/EdgePreservingDecomposition.cc index 700181e1d..04459e88a 100644 --- a/rtengine/EdgePreservingDecomposition.cc +++ b/rtengine/EdgePreservingDecomposition.cc @@ -55,7 +55,7 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl #endif for(int ii = 0; ii < n; ii++) { - rs += r[ii] * s[ii]; + rs += static_cast(r[ii]) * static_cast(s[ii]); } //Search direction d. @@ -84,15 +84,15 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl #endif for(int ii = 0; ii < n; ii++) { - ab += d[ii] * ax[ii]; + ab += static_cast(d[ii]) * static_cast(ax[ii]); } - if(ab == 0.0f) { + if(ab == 0.0) { break; //So unlikely. It means perfectly converged or singular, stop either way. } ab = rs / ab; - + float abf = ab; //Update x and r with this step size. double rms = 0.0; // use double precision for large summations #ifdef _OPENMP @@ -100,15 +100,15 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl #endif for(int ii = 0; ii < n; ii++) { - x[ii] += ab * d[ii]; - r[ii] -= ab * ax[ii]; //"Fast recursive formula", use explicit r = b - Ax occasionally? - rms += r[ii] * r[ii]; + x[ii] += abf * d[ii]; + r[ii] -= abf * ax[ii]; //"Fast recursive formula", use explicit r = b - Ax occasionally? + rms += rtengine::SQR(r[ii]); } rms = sqrtf(rms / n); //Quit? This probably isn't the best stopping condition, but ok. - if(rms < RMSResidual) { + if(rms < static_cast(RMSResidual)) { break; } @@ -129,20 +129,20 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl #endif for(int ii = 0; ii < n; ii++) { - rs += r[ii] * s[ii]; + rs += static_cast(r[ii]) * static_cast(s[ii]); } } ab = rs / ab; - + abf = ab; //Update search direction p. #ifdef _OPENMP #pragma omp parallel for #endif for(int ii = 0; ii < n; ii++) { - d[ii] = s[ii] + ab * d[ii]; + d[ii] = s[ii] + abf * d[ii]; } diff --git a/rtengine/PF_correct_RT.cc b/rtengine/PF_correct_RT.cc index 9a95b8e2f..15b7b21ee 100644 --- a/rtengine/PF_correct_RT.cc +++ b/rtengine/PF_correct_RT.cc @@ -103,7 +103,7 @@ void ImProcFunctions::PF_correct_RT(LabImage * lab, double radius, int thresh) // no precalculated values without SSE => calculate const float HH = xatan2f(lab->b[i][j], lab->a[i][j]); #endif - float chparam = chCurve->getVal((Color::huelab_to_huehsv2(HH))) - 0.5f; // get C=f(H) + float chparam = chCurve->getVal((Color::huelab_to_huehsv2(HH))) - 0.5; // get C=f(H) if (chparam < 0.f) { chparam *= 2.f; // increased action if chparam < 0 @@ -113,25 +113,25 @@ void ImProcFunctions::PF_correct_RT(LabImage * lab, double radius, int thresh) } const float chroma = chromaChfactor * (SQR(lab->a[i][j] - tmpa[i][j]) + SQR(lab->b[i][j] - tmpb[i][j])); // modulate chroma function hue - chromave += chroma; + chromave += static_cast(chroma); fringe[i * width + j] = chroma; } } } chromave /= height * width; - if (chromave > 0.0) { // now as chromave is calculated, we postprocess fringe to reduce the number of divisions in future + const float chromavef = chromave; #ifdef _OPENMP #pragma omp parallel for simd #endif for (int j = 0; j < width * height; j++) { - fringe[j] = 1.f / (fringe[j] + chromave); + fringe[j] = 1.f / (fringe[j] + chromavef); } - const float threshfactor = 1.f / (SQR(thresh / 33.f) * chromave * 5.0f + chromave); + const float threshfactor = 1.f / (SQR(thresh / 33.f) * chromavef * 5.0f + chromavef); const int halfwin = std::ceil(2 * radius) + 1; // Issue 1674: @@ -297,7 +297,7 @@ void ImProcFunctions::PF_correct_RTcam(CieImage * ncie, double radius, int thres // no precalculated values without SSE => calculate const float HH = xatan2f(srbb[i][j], sraa[i][j]); #endif - float chparam = chCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f; //get C=f(H) + float chparam = chCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5; //get C=f(H) if (chparam < 0.f) { chparam *= 2.f; // increase action if chparam < 0 @@ -307,7 +307,7 @@ void ImProcFunctions::PF_correct_RTcam(CieImage * ncie, double radius, int thres } const float chroma = chromaChfactor * (SQR(sraa[i][j] - tmaa[i][j]) + SQR(srbb[i][j] - tmbb[i][j])); //modulate chroma function hue - chromave += chroma; + chromave += static_cast(chroma); fringe[i * width + j] = chroma; } } @@ -317,15 +317,16 @@ void ImProcFunctions::PF_correct_RTcam(CieImage * ncie, double radius, int thres if (chromave > 0.0) { // now as chromave is calculated, we postprocess fringe to reduce the number of divisions in future + const float chromavef = chromave; #ifdef _OPENMP #pragma omp parallel for simd #endif for (int j = 0; j < width * height; j++) { - fringe[j] = 1.f / (fringe[j] + chromave); + fringe[j] = 1.f / (fringe[j] + chromavef); } - const float threshfactor = 1.f / (SQR(thresh / 33.f) * chromave * 5.0f + chromave); + const float threshfactor = 1.f / (SQR(thresh / 33.f) * chromavef * 5.0f + chromavef); const int halfwin = std::ceil(2 * radius) + 1; // Issue 1674: @@ -695,7 +696,7 @@ void ImProcFunctions::Badpixelscam(CieImage * ncie, double radius, int thresh, i for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { const float chroma = SQR(sraa[i][j] - tmaa[i][j]) + SQR(srbb[i][j] - tmbb[i][j]); - chrommed += chroma; + chrommed += static_cast(chroma); badpix[i * width + j] = chroma; } } @@ -703,15 +704,16 @@ void ImProcFunctions::Badpixelscam(CieImage * ncie, double radius, int thresh, i chrommed /= height * width; if (chrommed > 0.0) { + const float chrommedf = chrommed; // now as chrommed is calculated, we postprocess badpix to reduce the number of divisions in future - const float threshfactor = 1.f / ((thresh * chrommed) / 33.f + chrommed); + const float threshfactor = 1.f / ((thresh * chrommedf) / 33.f + chrommedf); const int halfwin = std::ceil(2 * radius) + 1; #ifdef _OPENMP #pragma omp parallel #endif { #ifdef __SSE2__ - const vfloat chrommedv = F2V(chrommed); + const vfloat chrommedv = F2V(chrommedf); const vfloat onev = F2V(1.f); #endif #ifdef _OPENMP @@ -726,7 +728,7 @@ void ImProcFunctions::Badpixelscam(CieImage * ncie, double radius, int thresh, i } #endif for (; j < width; j++) { - badpix[i * width + j] = 1.f / (badpix[i * width + j] + chrommed); + badpix[i * width + j] = 1.f / (badpix[i * width + j] + chrommedf); } } @@ -1040,7 +1042,7 @@ void ImProcFunctions::BadpixelsLab(LabImage * lab, double radius, int thresh, fl for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { const float chroma = SQR(lab->a[i][j] - tmaa[i][j]) + SQR(lab->b[i][j] - tmbb[i][j]); - chrommed += chroma; + chrommed += static_cast(chroma); badpix[i * width + j] = chroma; } } @@ -1049,13 +1051,13 @@ void ImProcFunctions::BadpixelsLab(LabImage * lab, double radius, int thresh, fl if (chrommed > 0.0) { // now as chrommed is calculated, we postprocess badpix to reduce the number of divisions in future - + const float chrommedf = chrommed; #ifdef _OPENMP #pragma omp parallel #endif { #ifdef __SSE2__ - const vfloat chrommedv = F2V(chrommed); + const vfloat chrommedv = F2V(chrommedf); const vfloat onev = F2V(1.f); #endif #ifdef _OPENMP @@ -1070,12 +1072,12 @@ void ImProcFunctions::BadpixelsLab(LabImage * lab, double radius, int thresh, fl } #endif for (; j < width; j++) { - badpix[i * width + j] = 1.f / (badpix[i * width + j] + chrommed); + badpix[i * width + j] = 1.f / (badpix[i * width + j] + chrommedf); } } } - const float threshfactor = 1.f / ((thresh * chrommed) / 33.f + chrommed); + const float threshfactor = 1.f / ((thresh * chrommedf) / 33.f + chrommedf); chrom *= 327.68f; chrom *= chrom; diff --git a/rtengine/ahd_demosaic_RT.cc b/rtengine/ahd_demosaic_RT.cc index 064dfd6e1..536726925 100644 --- a/rtengine/ahd_demosaic_RT.cc +++ b/rtengine/ahd_demosaic_RT.cc @@ -52,13 +52,13 @@ void RawImageSource::ahd_demosaic() int width = W, height = H; - constexpr double xyz_rgb[3][3] = { /* XYZ from RGB */ - { 0.412453, 0.357580, 0.180423 }, - { 0.212671, 0.715160, 0.072169 }, - { 0.019334, 0.119193, 0.950227 } + constexpr float xyz_rgb[3][3] = { /* XYZ from RGB */ + { 0.412453f, 0.357580f, 0.180423f }, + { 0.212671f, 0.715160f, 0.072169f }, + { 0.019334f, 0.119193f, 0.950227f } }; - constexpr float d65_white[3] = { 0.950456, 1, 1.088754 }; + constexpr float d65_white[3] = { 0.950456f, 1.f, 1.088754f }; double progress = 0.0; @@ -76,7 +76,7 @@ void RawImageSource::ahd_demosaic() for (unsigned int j = 0; j < 3; j++) { xyz_cam[i][j] = 0; for (int k = 0; k < 3; k++) { - xyz_cam[i][j] += xyz_rgb[i][k] * imatrices.rgb_cam[k][j] / d65_white[i]; + xyz_cam[i][j] += xyz_rgb[i][k] * static_cast(imatrices.rgb_cam[k][j]) / d65_white[i]; } } } diff --git a/rtengine/badpixels.cc b/rtengine/badpixels.cc index 0ae63a618..97294bdf7 100644 --- a/rtengine/badpixels.cc +++ b/rtengine/badpixels.cc @@ -477,7 +477,7 @@ int RawImageSource::interpolateBadPixelsXtrans(const PixelsMap &bitmapBads) int RawImageSource::findHotDeadPixels(PixelsMap &bpMap, const float thresh, const bool findHotPixels, const bool findDeadPixels) const { BENCHFUN - const float varthresh = (20.0 * (thresh / 100.0) + 1.0) / 24.f; + const float varthresh = (20.f * (thresh / 100.f) + 1.f) / 24.f; // counter for dead or hot pixels int counter = 0; diff --git a/rtengine/camconst.cc b/rtengine/camconst.cc index d136d6a21..b809cc30e 100644 --- a/rtengine/camconst.cc +++ b/rtengine/camconst.cc @@ -553,7 +553,7 @@ CameraConst::get_Levels(struct camera_const_levels & lvl, int bw, int iso, float float av = (avh - 1) + (float)k / 3; float aperture = sqrtf(powf(2, av)); - if (fnumber > aperture * 0.97 && fnumber < aperture / 0.97) { + if (fnumber > aperture * 0.97f && fnumber < aperture / 0.97f) { fnumber = fn_tab[avh][k]; it = mApertureScaling.find(fnumber); avh = 7; @@ -579,7 +579,7 @@ CameraConst::get_Levels(struct camera_const_levels & lvl, int bw, int iso, float scaling = it->second; } - if (scaling > 1.0) { + if (scaling > 1.f) { for (int i = 0; i < 4; i++) { lvl.levels[i] *= scaling; diff --git a/rtengine/capturesharpening.cc b/rtengine/capturesharpening.cc index 072935dc2..c6b9405b5 100644 --- a/rtengine/capturesharpening.cc +++ b/rtengine/capturesharpening.cc @@ -538,8 +538,8 @@ BENCHFUN constexpr int tileSize = 32; const int border = iterations <= 30 ? 5 : 7; const int fullTileSize = tileSize + 2 * border; - const float cornerRadius = std::min(1.15f, sigma + sigmaCornerOffset); - const float cornerDistance = sqrt(rtengine::SQR(W * 0.5f) + rtengine::SQR(H * 0.5f)); + const double cornerRadius = std::min(1.15f, sigma + sigmaCornerOffset); + const double cornerDistance = sqrt(rtengine::SQR(W * 0.5f) + rtengine::SQR(H * 0.5f)); const float distanceFactor = (cornerRadius - sigma) / cornerDistance; double progress = startVal; @@ -642,7 +642,7 @@ BENCHFUN const float distance = sqrt(rtengine::SQR(i + tileSize / 2 - H / 2) + rtengine::SQR(j + tileSize / 2 - W / 2)); const float sigmaTile = static_cast(sigma) + distanceFactor * distance; if (sigmaTile >= 0.4f) { - if (sigmaTile > 0.84) { // have to use 7x7 kernel + if (sigmaTile > 0.84f) { // have to use 7x7 kernel float lkernel7[7][7]; compute7x7kernel(static_cast(sigma) + distanceFactor * distance, lkernel7); for (int k = 0; k < iterations; ++k) { @@ -731,7 +731,7 @@ BENCHFUN { 0.019334, 0.119193, 0.950227 } }; - float contrast = conrastThreshold / 100.f; + float contrast = conrastThreshold / 100.0; const float clipVal = (ri->get_white(1) - ri->get_cblack(1)) * scale_mul[1]; diff --git a/rtengine/ciecam02.cc b/rtengine/ciecam02.cc index c7e49b2ed..208ed4366 100644 --- a/rtengine/ciecam02.cc +++ b/rtengine/ciecam02.cc @@ -28,7 +28,7 @@ #endif #undef CLIPD -#define CLIPD(a) ((a)>0.0?((a)<1.0?(a):1.0):0.0) +#define CLIPD(a) ((a)>0.f?((a)<1.f?(a):1.f):0.f) #define MAXR(a,b) ((a) > (b) ? (a) : (b)) namespace rtengine @@ -408,7 +408,7 @@ void Ciecam02::initcam1float (float yb, float pilotd, float f, float la, float x { n = yb / yw; - if (pilotd == 2.0) { + if (pilotd == 2.f) { d = d_factorfloat ( f, la ); } else { d = pilotd; @@ -434,7 +434,7 @@ void Ciecam02::initcam2float (float yb, float pilotd, float f, float la, float x { n = yb / yw; - if (pilotd == 2.0) { + if (pilotd == 2.f) { d = d_factorfloat ( f, la ); } else { d = pilotd; @@ -492,7 +492,7 @@ void Ciecam02::xyz2jchqms_ciecam02float ( float &J, float &C, float &h, float &Q myh = xatan2f ( cb, ca ); if ( myh < 0.0f ) { - myh += (2.f * rtengine::RT_PI); + myh += (2.f * rtengine::RT_PI_F); } a = ((2.0f * rpa) + gpa + (0.05f * bpa) - 0.305f) * nbb; @@ -620,7 +620,7 @@ void Ciecam02::xyz2jch_ciecam02float ( float &J, float &C, float &h, float aw, f myh = xatan2f ( cb, ca ); if ( myh < 0.0f ) { - myh += (2.f * rtengine::RT_PI); + myh += (2.f * rtengine::RT_PI_F); } a = ((2.0f * rpa) + gpa + (0.05f * bpa) - 0.305f) * nbb; diff --git a/rtengine/color.h b/rtengine/color.h index 211615de1..845770bbe 100644 --- a/rtengine/color.h +++ b/rtengine/color.h @@ -132,7 +132,7 @@ public: constexpr static double sRGBGammaCurve = 2.4; constexpr static double eps = 216.0 / 24389.0; //0.008856 - constexpr static double eps_max = MAXVALF * eps; //580.40756; + constexpr static double eps_max = MAXVALD * eps; //580.40756; constexpr static double kappa = 24389.0 / 27.0; //903.29630; constexpr static double kappaInv = 27.0 / 24389.0; constexpr static double epsilonExpInv3 = 6.0 / 29.0; @@ -144,8 +144,8 @@ public: constexpr static float D50x = 0.9642f; //0.96422; constexpr static float D50z = 0.8249f; //0.82521; - constexpr static double u0 = 4.0 * D50x / (D50x + 15 + 3 * D50z); - constexpr static double v0 = 9.0 / (D50x + 15 + 3 * D50z); + constexpr static double u0 = 4.0 * static_cast(D50x) / (static_cast(D50x) + 15 + 3 * static_cast(D50z)); + constexpr static double v0 = 9.0 / (static_cast(D50x) + 15 + 3 * static_cast(D50z)); constexpr static double epskap = 8.0; constexpr static float c1By116 = 1.0 / 116.0; @@ -206,7 +206,7 @@ public: static float rgbLuminance(float r, float g, float b, const double workingspace[3][3]) { - return r * workingspace[1][0] + g * workingspace[1][1] + b * workingspace[1][2]; + return static_cast(r) * workingspace[1][0] + static_cast(g) * workingspace[1][1] + static_cast(b) * workingspace[1][2]; } #ifdef __SSE2__ @@ -972,10 +972,10 @@ public: template static inline T interpolatePolarHue_PI (T h1, T h2, U balance) { - float d = h2 - h1; - float f; + T d = h2 - h1; + T f; f = T(balance); - double h; + T h; if (h1 > h2) { std::swap(h1, h2); @@ -986,7 +986,7 @@ public: if (d < T(0) || d < T(0.5) || d > T(1.)) { //there was an inversion here !! d > T(rtengine::RT_PI) h1 += T(1.); h = h1 + f * (h2 - h1); - h = std::fmod(h, 1.); + h = std::fmod(h, T(1.)); } else { h = h1 + f * d; } diff --git a/rtengine/colortemp.cc b/rtengine/colortemp.cc index 02d3e0e6d..525ed339e 100644 --- a/rtengine/colortemp.cc +++ b/rtengine/colortemp.cc @@ -1071,10 +1071,10 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double Xwb, Zwb; temp2mulxyz(temp, method, Xwb, Zwb); - float adj = 1.f; + double adj = 1.0; if(equal < 0.9999 || equal > 1.0001 ) { - adj = (100.f + ( 1000.f - (1000.f * (float)equal) ) / 20.f) / 100.f; + adj = (100.0 + ( 1000.0 - (1000.0 * equal) ) / 20.0) / 100.0; } @@ -1389,7 +1389,7 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, } for(int i = 0; i < 8; i++) { - CRIs[i] = 100 - 3.0 * DeltaEs[i]; //3.0 coef to adapt ==> same results than CRI "official" + CRIs[i] = 100 - 3.f * DeltaEs[i]; //3.0 coef to adapt ==> same results than CRI "official" } for(int i = 0; i < 8; i++) { @@ -1409,7 +1409,7 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, } for(int i = 0; i < N_c; i++) { - CRI[i] = 100 - 3.0 * DeltaE[i]; //3.0 coef to adapt ==> same results than CRI "official" + CRI[i] = 100 - 3.f * DeltaE[i]; //3.0 coef to adapt ==> same results than CRI "official" } for(int i = 0; i < N_c; i++) { @@ -1425,8 +1425,8 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, quadCRI /= N_c; if(settings->CRI_color != 0) { - printf("CRI_standard=%i CRI:1->8=%i %i %i %i %i %i %i %i Sigma=%2.1f\n", (int) CRI_RTs, (int) CRIs[0], (int) CRIs[1], (int) CRIs[2], (int) CRIs[3], (int) CRIs[4], (int) CRIs[5], (int) CRIs[6], (int) CRIs[7], sqrt(quadCRIs)); - printf("CRI_RT_exten=%i CRI:9->20=%i %i %i %i %i %i %i %i %i %i %i %i Sigma=%2.1f\n", (int) CRI_RT, (int) CRI[8], (int) CRI[9], (int) CRI[10], (int) CRI[11], (int) CRI[12], (int) CRI[13], (int) CRI[14], (int) CRI[15], (int) CRI[16], (int) CRI[17], (int) CRI[18], (int) CRI[19], sqrt(quadCRI)); + printf("CRI_standard=%i CRI:1->8=%i %i %i %i %i %i %i %i Sigma=%2.1f\n", (int) CRI_RTs, (int) CRIs[0], (int) CRIs[1], (int) CRIs[2], (int) CRIs[3], (int) CRIs[4], (int) CRIs[5], (int) CRIs[6], (int) CRIs[7], sqrt(static_cast(quadCRIs))); + printf("CRI_RT_exten=%i CRI:9->20=%i %i %i %i %i %i %i %i %i %i %i %i Sigma=%2.1f\n", (int) CRI_RT, (int) CRI[8], (int) CRI[9], (int) CRI[10], (int) CRI[11], (int) CRI[12], (int) CRI[13], (int) CRI[14], (int) CRI[15], (int) CRI[16], (int) CRI[17], (int) CRI[18], (int) CRI[19], static_cast(sqrt(quadCRI))); } } } diff --git a/rtengine/curves.h b/rtengine/curves.h index bc8193b76..93c7566d7 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -292,11 +292,11 @@ public: } static inline float gamma2 (float x) { - return x <= 0.00304 ? x * 12.92310 : 1.055 * expf(logf(x) / sRGBGammaCurve) - 0.055; + return x <= 0.00304f ? x * 12.92310f : 1.055f * expf(logf(x) / static_cast(sRGBGammaCurve)) - 0.055f; } static inline float igamma2 (float x) { - return x <= 0.03928 ? x / 12.92310 : expf(logf((x + 0.055) / 1.055) * sRGBGammaCurve); + return x <= 0.03928f ? x / 12.92310f : expf(logf((x + 0.055f) / 1.055f) * static_cast(sRGBGammaCurve)); } // gamma function with adjustable parameters static inline double gamma (double x, double gamma, double start, double slope, double mul, double add) @@ -327,8 +327,8 @@ public: #endif static inline float hlcurve (const float exp_scale, const float comp, const float hlrange, float level) { - if (comp > 0.0) { - float val = level + (hlrange - 65536.0); + if (comp > 0.f) { + float val = level + (hlrange - 65536.f); if(val == 0.0f) { // to avoid division by zero val = 0.000001f; @@ -337,7 +337,7 @@ public: float Y = val * exp_scale / hlrange; Y *= comp; - if(Y <= -1.0) { // to avoid log(<=0) + if(Y <= -1.f) { // to avoid log(<=0) Y = -.999999f; } diff --git a/rtengine/dcp.cc b/rtengine/dcp.cc index 11fe306b8..89256bba4 100644 --- a/rtengine/dcp.cc +++ b/rtengine/dcp.cc @@ -1064,9 +1064,11 @@ void DCPProfile::apply( for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { + double temp = 0.0; for (int k = 0; k < 3; ++k) { - mat[i][j] += work_matrix[i][k] * xyz_cam[k][j]; + temp += work_matrix[i][k] * xyz_cam[k][j]; } + mat[i][j] = temp; } } @@ -1092,9 +1094,11 @@ void DCPProfile::apply( for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { + double temp = 0.0; for (int k = 0; k < 3; ++k) { - pro_photo[i][j] += prophoto_xyz[i][k] * xyz_cam[k][j]; + temp += prophoto_xyz[i][k] * xyz_cam[k][j]; } + pro_photo[i][j] = temp; } } @@ -1102,9 +1106,11 @@ void DCPProfile::apply( for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { + double temp = 0.0; for (int k = 0; k < 3; ++k) { - work[i][j] += work_matrix[i][k] * xyz_prophoto[k][j]; + temp += work_matrix[i][k] * xyz_prophoto[k][j]; } + work[i][j] = temp; } } @@ -1173,27 +1179,35 @@ void DCPProfile::setStep2ApplyState(const Glib::ustring& working_space, bool use mWork = ICCStore::getInstance()->workingSpaceMatrix (working_space); memset(as_out.data->pro_photo, 0, sizeof(as_out.data->pro_photo)); - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + double temp = 0.0; for (int k = 0; k < 3; k++) { - as_out.data->pro_photo[i][j] += prophoto_xyz[i][k] * mWork[k][j]; + temp += prophoto_xyz[i][k] * mWork[k][j]; } + as_out.data->pro_photo[i][j] = temp; + } + } mWork = ICCStore::getInstance()->workingSpaceInverseMatrix (working_space); memset(as_out.data->work, 0, sizeof(as_out.data->work)); - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + double temp = 0.0; for (int k = 0; k < 3; k++) { - as_out.data->work[i][j] += mWork[i][k] * xyz_prophoto[k][j]; + temp += mWork[i][k] * xyz_prophoto[k][j]; } + as_out.data->work[i][j] = temp; + } + } } } void DCPProfile::step2ApplyTile(float* rc, float* gc, float* bc, int width, int height, int tile_width, const DCPProfileApplyState& as_in) const { -#define FCLIP(a) ((a)>0.0?((a)<65535.5?(a):65535.5):0.0) +#define FCLIP(a) ((a)>0.f?((a)<65535.5f?(a):65535.5f):0.f) #define CLIP01(a) ((a)>0?((a)<1?(a):1):0) float exp_scale = as_in.data->bl_scale; diff --git a/rtengine/demosaic_algos.cc b/rtengine/demosaic_algos.cc index 538858a9a..a31415968 100644 --- a/rtengine/demosaic_algos.cc +++ b/rtengine/demosaic_algos.cc @@ -1069,7 +1069,7 @@ void RawImageSource::dcb_hid(float (*image)[3], int x0, int y0) for (int col = colMin + (FC(y0 - TILEBORDER + row, x0 - TILEBORDER + colMin) & 1), indx = row * CACHESIZE + col; col < colMax; col += 2, indx += 2) { assert(indx - u - 1 >= 0 && indx + u + 1 < u * u); - image[indx][1] = 0.25*(image[indx-1][1]+image[indx+1][1]+image[indx-u][1]+image[indx+u][1]); + image[indx][1] = 0.25f * (image[indx-1][1]+image[indx+1][1]+image[indx-u][1]+image[indx+u][1]); } } diff --git a/rtengine/dfmanager.cc b/rtengine/dfmanager.cc index 1fb1d2e1b..6961a4b54 100644 --- a/rtengine/dfmanager.cc +++ b/rtengine/dfmanager.cc @@ -476,7 +476,7 @@ dfInfo* DFManager::find( const std::string &mak, const std::string &mod, int iso } } - return bestD != INFINITY ? &(bestMatch->second) : nullptr ; + return bestD != RT_INFINITY ? &(bestMatch->second) : nullptr ; } } diff --git a/rtengine/diagonalcurves.cc b/rtengine/diagonalcurves.cc index bb20b7cc1..f8b22ed46 100644 --- a/rtengine/diagonalcurves.cc +++ b/rtengine/diagonalcurves.cc @@ -65,23 +65,23 @@ DiagonalCurve::DiagonalCurve (const std::vector& p, int poly_pn) } } - if (x[0] != 0.0f || x[N - 1] != 1.0f) + if (x[0] != 0.0 || x[N - 1] != 1.0) // Special (and very rare) case where all points are on the identity line but // not reaching the limits { identity = false; } - if(x[0] == 0.f && x[1] == 0.f) + if(x[0] == 0.0 && x[1] == 0.0) // Avoid crash when first two points are at x = 0 (git Issue 2888) { - x[1] = 0.01f; + x[1] = 0.01; } - if(x[0] == 1.f && x[1] == 1.f) + if(x[0] == 1.0 && x[1] == 1.0) // Avoid crash when first two points are at x = 1 (100 in gui) (git Issue 2923) { - x[0] = 0.99f; + x[0] = 0.99; } if (!identity) { @@ -97,7 +97,7 @@ DiagonalCurve::DiagonalCurve (const std::vector& p, int poly_pn) } } } else if (kind == DCT_Parametric) { - if ((p.size() == 8 || p.size() == 9) && (p.at(4) != 0.0f || p.at(5) != 0.0f || p.at(6) != 0.0f || p.at(7) != 0.0f)) { + if ((p.size() == 8 || p.size() == 9) && (p.at(4) != 0.0 || p.at(5) != 0.0 || p.at(6) != 0.0 || p.at(7) != 0.0)) { identity = false; x = new double[9]; diff --git a/rtengine/dirpyr_equalizer.cc b/rtengine/dirpyr_equalizer.cc index 1f62badcb..0624f4443 100644 --- a/rtengine/dirpyr_equalizer.cc +++ b/rtengine/dirpyr_equalizer.cc @@ -228,11 +228,11 @@ void fillLut(LUTf &irangefn, int level, double dirpyrThreshold, float mult, floa } const float offs = skinprot == 0.f ? 0.f : -1.f; - constexpr float noise = 2000.f; - const float noisehi = 1.33f * noise * dirpyrThreshold / expf(level * log(3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf(level * log(3.0)); + constexpr double noise = 2000.0; + const float noisehi = 1.33 * noise * dirpyrThreshold / exp(level * log(3.0)), noiselo = 0.66 * noise * dirpyrThreshold / exp(level * log(3.0)); for (int i = 0; i < 0x20000; i++) { - if (abs(i - 0x10000) > noisehi || multbis < 1.0) { + if (abs(i - 0x10000) > noisehi || multbis < 1.f) { irangefn[i] = multbis + offs; } else { if (abs(i - 0x10000) < noiselo) { @@ -262,7 +262,7 @@ void idirpyr_eq_channel(const float * const * data_coarse, const float * const * buffer[i][j] += irangefn[hipass + 0x10000] * hipass; } } - } else if (skinprot > 0.f) { + } else if (skinprot > 0.0) { #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif @@ -314,7 +314,7 @@ void idirpyr_eq_channelcam(const float * const * data_coarse, const float * cons buffer[i][j] += irangefn[hipass + 0x10000] * hipass; } } - } else if (skinprot > 0.f) { + } else if (skinprot > 0.0) { #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif diff --git a/rtengine/dual_demosaic_RT.cc b/rtengine/dual_demosaic_RT.cc index 93508808c..253468a76 100644 --- a/rtengine/dual_demosaic_RT.cc +++ b/rtengine/dual_demosaic_RT.cc @@ -45,7 +45,7 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams { BENCHFUN - if (contrast == 0.f && !autoContrast) { + if (contrast == 0.0 && !autoContrast) { // contrast == 0.0 means only first demosaicer will be used if(isBayer) { if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEVNG4) ) { @@ -103,7 +103,7 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams } // calculate contrast based blend factors to use vng4 in regions with low contrast JaggedArray blend(winw, winh); - float contrastf = contrast / 100.f; + float contrastf = contrast / 100.0; buildBlendMask(L, blend, winw, winh, contrastf, autoContrast); contrast = contrastf * 100.f; diff --git a/rtengine/ffmanager.cc b/rtengine/ffmanager.cc index ce60277e1..c55bc5108 100644 --- a/rtengine/ffmanager.cc +++ b/rtengine/ffmanager.cc @@ -428,7 +428,7 @@ ffInfo* FFManager::find( const std::string &mak, const std::string &mod, const s } } - return bestD != INFINITY ? &(bestMatch->second) : nullptr ; + return bestD != RT_INFINITY ? &(bestMatch->second) : nullptr ; } } diff --git a/rtengine/green_equil_RT.cc b/rtengine/green_equil_RT.cc index fc4f18548..a66bca160 100644 --- a/rtengine/green_equil_RT.cc +++ b/rtengine/green_equil_RT.cc @@ -47,7 +47,7 @@ void RawImageSource::green_equilibrate_global(array2D &rawData) for (int i = border; i < H - border; i++) { double avgg = 0.; for (int j = border + ((FC(i, border) & 1) ^ 1); j < W - border; j += 2) { - avgg += rawData[i][j]; + avgg += static_cast(rawData[i][j]); } int ng = (W - 2 * border + (FC(i, border) & 1)) / 2; @@ -71,15 +71,15 @@ void RawImageSource::green_equilibrate_global(array2D &rawData) avgg2 = 1.0; } - double corrg1 = (avgg1 / ng1 + avgg2 / ng2) / 2.0 / (avgg1 / ng1); - double corrg2 = (avgg1 / ng1 + avgg2 / ng2) / 2.0 / (avgg2 / ng2); + const float corrg1 = (avgg1 / ng1 + avgg2 / ng2) / 2.0 / (avgg1 / ng1); + const float corrg2 = (avgg1 / ng1 + avgg2 / ng2) / 2.0 / (avgg2 / ng2); #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif for (int i = border; i < H - border; i++) { - double corrg = (i & 1) ? corrg2 : corrg1; + const float corrg = (i & 1) ? corrg2 : corrg1; for (int j = border + ((FC(i, border) & 1) ^ 1); j < W - border; j += 2) { rawData[i][j] *= corrg; @@ -220,7 +220,7 @@ void RawImageSource::green_equilibrate(const GreenEqulibrateThreshold &thresh, a float tf = thresh(rr, cc); - if (c1 + c2 < 6 * tf * fabs(d1 - d2)) { + if (c1 + c2 < 6 * tf * std::fabs(d1 - d2)) { //pixel interpolation float gin = cfa[rr][cc >> 1]; diff --git a/rtengine/histmatching.cc b/rtengine/histmatching.cc index f5d16866e..0053cb0d4 100644 --- a/rtengine/histmatching.cc +++ b/rtengine/histmatching.cc @@ -179,7 +179,7 @@ void mappingToCurve(const std::vector &mapping, std::vector &curve) }; idx = -1; for (ssize_t i = curve.size()-1; i > 0; i -= 2) { - if (curve[i] <= 0.f) { + if (curve[i] <= 0.0) { idx = i+1; break; } @@ -328,7 +328,7 @@ void RawImageSource::getAutoMatchedToneCurve(const ColorManagementParams &cp, st int tw = target->getWidth(), th = target->getHeight(); 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)); - if (std::abs(thumb_ratio - target_ratio) > 0.01) { + if (std::abs(thumb_ratio - target_ratio) > 0.01f) { int cx = 0, cy = 0; if (thumb_ratio > target_ratio) { // crop the height @@ -342,7 +342,7 @@ void RawImageSource::getAutoMatchedToneCurve(const ColorManagementParams &cp, st tw -= cw; } if (settings->verbose) { - std::cout << "histogram matching: cropping target to get an aspect ratio of " << round(thumb_ratio * 100)/100.0 << ":1, new size is " << tw << "x" << th << std::endl; + std::cout << "histogram matching: cropping target to get an aspect ratio of " << round(thumb_ratio * 100)/100.f << ":1, new size is " << tw << "x" << th << std::endl; } if (cx || cy) { diff --git a/rtengine/image16.cc b/rtengine/image16.cc index a98d64d51..7013af4b7 100644 --- a/rtengine/image16.cc +++ b/rtengine/image16.cc @@ -147,10 +147,10 @@ void Image16::getStdImage(const ColorTemp &ctemp, int tran, Imagefloat* image, P gm = dgm; bm = dbm; - rm = 1.0 / rm; - gm = 1.0 / gm; - bm = 1.0 / bm; - float mul_lum = 0.299 * rm + 0.587 * gm + 0.114 * bm; + rm = 1.f / rm; + gm = 1.f / gm; + bm = 1.f / bm; + float mul_lum = 0.299f * rm + 0.587f * gm + 0.114f * bm; rm /= mul_lum; gm /= mul_lum; bm /= mul_lum; diff --git a/rtengine/image8.cc b/rtengine/image8.cc index 66ad8b60f..f2098962c 100644 --- a/rtengine/image8.cc +++ b/rtengine/image8.cc @@ -111,10 +111,10 @@ void Image8::getStdImage (const ColorTemp &ctemp, int tran, Imagefloat* image, P gm = dgm; bm = dbm; - rm = 1.0 / rm; - gm = 1.0 / gm; - bm = 1.0 / bm; - float mul_lum = 0.299 * rm + 0.587 * gm + 0.114 * bm; + rm = 1.f / rm; + gm = 1.f / gm; + bm = 1.f / bm; + float mul_lum = 0.299f * rm + 0.587f * gm + 0.114f * bm; rm /= mul_lum; gm /= mul_lum; bm /= mul_lum; diff --git a/rtengine/imagefloat.cc b/rtengine/imagefloat.cc index 1da91a4b4..f905134a0 100644 --- a/rtengine/imagefloat.cc +++ b/rtengine/imagefloat.cc @@ -178,10 +178,10 @@ void Imagefloat::getStdImage (const ColorTemp &ctemp, int tran, Imagefloat* imag gm = dgm; bm = dbm; - rm = 1.0 / rm; - gm = 1.0 / gm; - bm = 1.0 / bm; - float mul_lum = 0.299 * rm + 0.587 * gm + 0.114 * bm; + rm = 1.f / rm; + gm = 1.f / gm; + bm = 1.f / bm; + float mul_lum = 0.299f * rm + 0.587f * gm + 0.114f * bm; rm /= mul_lum; gm /= mul_lum; bm /= mul_lum; @@ -368,7 +368,7 @@ Imagefloat::to16() const void Imagefloat::normalizeFloat(float srcMinVal, float srcMaxVal) { - float scale = MAXVALD / (srcMaxVal - srcMinVal); + float scale = MAXVALF / (srcMaxVal - srcMinVal); int w = width; int h = height; diff --git a/rtengine/ipdehaze.cc b/rtengine/ipdehaze.cc index 28a0f2d57..2dc0287a1 100644 --- a/rtengine/ipdehaze.cc +++ b/rtengine/ipdehaze.cc @@ -240,9 +240,9 @@ float estimate_ambient_light(const array2D &R, const array2D &G, c float g = G[y][x]; float b = B[y][x]; if (r + g + b >= bright_lim) { - rr += r; - gg += g; - bb += b; + rr += static_cast(r); + gg += static_cast(g); + bb += static_cast(b); ++n; } } diff --git a/rtengine/iplabregions.cc b/rtengine/iplabregions.cc index 6526419f5..786d42e56 100644 --- a/rtengine/iplabregions.cc +++ b/rtengine/iplabregions.cc @@ -139,7 +139,7 @@ BENCHFUN auto &hm = hmask[i]; auto &cm = cmask[i]; auto &lm = lmask[i]; - float blend = LIM01((hm ? hm->getVal(h) : 1.f) * (cm ? cm->getVal(c) : 1.f) * (lm ? lm->getVal(l) : 1.f)); + float blend = LIM01((hm ? hm->getVal(h) : 1.0) * (cm ? cm->getVal(c) : 1.0) * (lm ? lm->getVal(l) : 1.0)); Lmask[i][y][x] = abmask[i][y][x] = blend; } } @@ -147,8 +147,8 @@ BENCHFUN } for (int i = begin_idx; i < end_idx; ++i) { - float blur = params->colorToning.labregions[i].maskBlur; - blur = blur < 0.f ? -1.f/blur : 1.f + blur; + double blur = params->colorToning.labregions[i].maskBlur; + blur = blur < 0.0 ? -1.0 / blur : 1.0 + blur; int r1 = max(int(4 / scale * blur + 0.5), 1); int r2 = max(int(25 / scale * blur + 0.5), 1); rtengine::guidedFilter(guide, abmask[i], abmask[i], r1, 0.001, multiThread); @@ -188,7 +188,7 @@ BENCHFUN auto &r = params->colorToning.labregions[i]; abca[i] = abcoord(r.a); abcb[i] = abcoord(r.b); - rs[i] = 1.f + r.saturation / (SGN(r.saturation) > 0 ? 50.f : 100.f); + rs[i] = 1.0 + r.saturation / (SGN(r.saturation) > 0 ? 50.0 : 100.0); slope[i] = r.slope; offset[i] = r.offset; power[i] = r.power; diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index 84f33482f..6768eca93 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -110,8 +110,8 @@ void mean_stddv2( float **dst, float &mean, float &stddv, int W_L, int H_L, floa for (int i = 0; i < H_L; i++ ) for (int j = 0; j < W_L; j++) { - sum += dst[i][j]; - vsquared += (dst[i][j] * dst[i][j]); + sum += static_cast(dst[i][j]); + vsquared += rtengine::SQR(dst[i][j]); lmax = dst[i][j] > lmax ? dst[i][j] : lmax; lmin = dst[i][j] < lmin ? dst[i][j] : lmin; @@ -128,8 +128,8 @@ void mean_stddv2( float **dst, float &mean, float &stddv, int W_L, int H_L, floa } mean = sum / (double) (W_L * H_L); vsquared /= (double) W_L * H_L; - stddv = ( vsquared - (mean * mean) ); - stddv = (float)sqrt(stddv); + stddv = vsquared - rtengine::SQR(mean); + stddv = std::sqrt(stddv); } } @@ -678,9 +678,9 @@ BENCHFUN float valparam; if(useHsl || useHslLin) { - valparam = shcurve->getVal(HH) - 0.5f; + valparam = shcurve->getVal(HH) - 0.5; } else { - valparam = shcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f; + valparam = shcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5; } str *= (1.f + 2.f * valparam); diff --git a/rtengine/ipshadowshighlights.cc b/rtengine/ipshadowshighlights.cc index 5c5b6b324..5d5be57e9 100644 --- a/rtengine/ipshadowshighlights.cc +++ b/rtengine/ipshadowshighlights.cc @@ -46,7 +46,7 @@ void ImProcFunctions::shadowsHighlights(LabImage *lab) array2D mask(width, height); array2D L(width, height); - const float radius = float(params->sh.radius) * 10 / scale; + const float radius = params->sh.radius * 10 / scale; LUTf f(lab_mode ? 32768 : 65536); TMatrix ws = ICCStore::getInstance()->workingSpaceMatrix(params->icm.workingProfile); diff --git a/rtengine/ipvibrance.cc b/rtengine/ipvibrance.cc index 14e5f3c44..8636ecb95 100644 --- a/rtengine/ipvibrance.cc +++ b/rtengine/ipvibrance.cc @@ -48,7 +48,7 @@ void fillCurveArrayVib (DiagonalCurve* diagCurve, LUTf &outCurve) // change to [0,1] range // apply custom/parametric/NURBS curve, if any // and store result in a temporary array - outCurve[i] = 65535.f * diagCurve->getVal ( double (i) / 65535.0 ); + outCurve[i] = 65535.0 * diagCurve->getVal(i / 65535.0); } } else { outCurve.makeIdentity(); @@ -606,7 +606,7 @@ void ImProcFunctions::vibrance (LabImage* lab) bool inGamut; const float fyy = Color::c1By116 * Lprov + Color::c16By116; - const float yy_ = (Lprov > Color::epskap) ? fyy * fyy*fyy : Lprov / Color::kappaf; + const float yy_ = (Lprov > static_cast(Color::epskap)) ? fyy * fyy*fyy : Lprov / Color::kappaf; float ChprovOld = std::numeric_limits::min(); do { inGamut = true; diff --git a/rtengine/lmmse_demosaic.cc b/rtengine/lmmse_demosaic.cc index f4af1b801..5c4ddffed 100644 --- a/rtengine/lmmse_demosaic.cc +++ b/rtengine/lmmse_demosaic.cc @@ -334,7 +334,7 @@ void RawImageSource::lmmse_interpolate_omp(int winw, int winh, const array2DlocalContrast.amount = true; diff --git a/rtengine/tmo_fattal02.cc b/rtengine/tmo_fattal02.cc index feba5c95f..cee57c851 100644 --- a/rtengine/tmo_fattal02.cc +++ b/rtengine/tmo_fattal02.cc @@ -308,7 +308,7 @@ float calculateGradients (Array2Df* H, Array2Df* G, int k, bool multithread) // however, the impact is not visible so we ignore this here (*G) (x, y) = sqrt (gx * gx + gy * gy) / divider; - avgGrad += (*G) (x, y); + avgGrad += static_cast((*G) (x, y)); } } @@ -381,7 +381,7 @@ void calculateFiMatrix (Array2Df* FI, Array2Df* gradients[], #endif for ( int y = 0; y < height; y++ ) { for ( int x = 0; x < width; x++ ) { - float grad = ((*gradients[k]) (x, y) < 1e-4f) ? 1e-4 : (*gradients[k]) (x, y); + float grad = ((*gradients[k]) (x, y) < 1e-4f) ? 1e-4f : (*gradients[k]) (x, y); float a = alfa * avgGrad[k]; float value = pow ((grad + noise) / a, beta - 1.0f); @@ -603,8 +603,8 @@ void tmo_fattal02 (size_t width, // sets index+1 based on the boundary assumption H(N+1)=H(N-1) unsigned int xp1 = (x + 1 >= width ? width - 2 : x + 1); // forward differences in H, so need to use between-points approx of FI - (*Gx) (x, y) = ((*H) (xp1, y) - (*H) (x, y)) * 0.5 * ((*FI) (xp1, y) + (*FI) (x, y)); - (*Gy) (x, y) = ((*H) (x, yp1) - (*H) (x, y)) * 0.5 * ((*FI) (x, yp1) + (*FI) (x, y)); + (*Gx) (x, y) = ((*H) (xp1, y) - (*H) (x, y)) * 0.5f * ((*FI) (xp1, y) + (*FI) (x, y)); + (*Gy) (x, y) = ((*H) (x, yp1) - (*H) (x, y)) * 0.5f * ((*FI) (x, yp1) + (*FI) (x, y)); } } @@ -747,7 +747,7 @@ void transform_ev2normal (Array2Df *A, Array2Df *T, bool multithread) } for (int y = 1 ; y < height - 1 ; y++ ) { - (*A) (0, y) *= 0.5; + (*A) (0, y) *= 0.5f; (*A) (width - 1, y) *= 0.5f; } @@ -912,7 +912,7 @@ void solve_pde_fft (Array2Df *F, Array2Df *U, Array2Df *buf, bool multithread)/* for (int y = 0 ; y < height ; y++ ) { for (int x = 0 ; x < width ; x++ ) { - (*F_tr) (x, y) = (*F_tr) (x, y) / (l1[y] + l2[x]); + (*F_tr) (x, y) = static_cast((*F_tr) (x, y)) / (l1[y] + l2[x]); } } diff --git a/rtengine/xtrans_demosaic.cc b/rtengine/xtrans_demosaic.cc index cb1315ed0..b01b0ac1c 100644 --- a/rtengine/xtrans_demosaic.cc +++ b/rtengine/xtrans_demosaic.cc @@ -31,7 +31,7 @@ namespace rtengine { -const double xyz_rgb[3][3] = { // XYZ from RGB +const float xyz_rgb[3][3] = { // XYZ from RGB { 0.412453, 0.357580, 0.180423 }, { 0.212671, 0.715160, 0.072169 }, { 0.019334, 0.119193, 0.950227 } diff --git a/rtgui/blackwhite.cc b/rtgui/blackwhite.cc index 596d99607..ea493d6e1 100644 --- a/rtgui/blackwhite.cc +++ b/rtgui/blackwhite.cc @@ -70,7 +70,7 @@ BlackWhite::BlackWhite (): FoldableToolPanel(this, "blackwhite", M("TP_BWMIX_LAB // -0.1 rad < Hue < 1.6 rad for (int i = 0; i < 7; i++) { - float x = float(i) * (1.0f / 6.0); + float x = float(i) * (1.0f / 6.f); Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); bottomMilestones.push_back( GradientMilestone(double(x), double(R), double(G), double(B)) ); } @@ -1185,10 +1185,10 @@ void BlackWhite::updateRGBLabel () RGBLabels->set_text( Glib::ustring::compose(M("TP_BWMIX_RGBLABEL"), - Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.), - Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.), - Glib::ustring::format(std::fixed, std::setprecision(1), b * 100.), - Glib::ustring::format(std::fixed, std::setprecision(0), ceil(kcorrec * 100./*(r+g+b)*100.)*/))) + Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.f), + Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.f), + Glib::ustring::format(std::fixed, std::setprecision(1), b * 100.f), + Glib::ustring::format(std::fixed, std::setprecision(0), ceil(kcorrec * 100.f/*(r+g+b)*100.)*/))) ); // We have to update the RGB sliders too if preset values has been chosen diff --git a/rtgui/colorappearance.cc b/rtgui/colorappearance.cc index 62f6eee2c..9468770fc 100644 --- a/rtgui/colorappearance.cc +++ b/rtgui/colorappearance.cc @@ -523,7 +523,7 @@ ColorAppearance::ColorAppearance () : FoldableToolPanel (this, "colorappearance" float R, G, B; for (int i = 0; i < 7; i++) { - float x = float (i) * (1.0f / 6.0); + float x = float (i) * (1.0f / 6.f); Color::hsv2rgb01 (x, 0.5f, 0.5f, R, G, B); shape3Milestones.push_back ( GradientMilestone (double (x), double (R), double (G), double (B)) ); } diff --git a/rtgui/colortoning.cc b/rtgui/colortoning.cc index 59768a6ce..ddf917149 100644 --- a/rtgui/colortoning.cc +++ b/rtgui/colortoning.cc @@ -74,7 +74,7 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR // whole hue range for (int i = 0; i < 7; i++) { float R, G, B; - float x = float(i) * (1.0f / 6.0); + float x = float(i) * (1.0f / 6.f); Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); milestones.push_back( GradientMilestone(double(x), double(R), double(G), double(B)) ); } @@ -1203,11 +1203,11 @@ void ColorToning::colorForValue (double valX, double valY, enum ColorCaller::Ele // the strength applied to the current hue double strength, hue; hlColSat->getValue(strength, hue); - Color::hsv2rgb01(hue / 360.f, 1.f, 1.f, R, G, B); + Color::hsv2rgb01(hue / 360.0, 1.f, 1.f, R, G, B); const double gray = 0.46; - R = (gray * (1.0 - valX)) + R * valX; - G = (gray * (1.0 - valX)) + G * valX; - B = (gray * (1.0 - valX)) + B * valX; + R = (gray * (1.0 - valX)) + static_cast(R) * valX; + G = (gray * (1.0 - valX)) + static_cast(G) * valX; + B = (gray * (1.0 - valX)) + static_cast(B) * valX; } } else if (callerId == 3) { // Slider 2 background if (valY <= 0.5) @@ -1218,17 +1218,17 @@ void ColorToning::colorForValue (double valX, double valY, enum ColorCaller::Ele // the strength applied to the current hue double strength, hue; shadowsColSat->getValue(strength, hue); - Color::hsv2rgb01(hue / 360.f, 1.f, 1.f, R, G, B); + Color::hsv2rgb01(hue / 360.0, 1.f, 1.f, R, G, B); const double gray = 0.46; - R = (gray * (1.0 - valX)) + R * valX; - G = (gray * (1.0 - valX)) + G * valX; - B = (gray * (1.0 - valX)) + B * valX; + R = (gray * (1.0 - valX)) + static_cast(R) * valX; + G = (gray * (1.0 - valX)) + static_cast(G) * valX; + B = (gray * (1.0 - valX)) + static_cast(B) * valX; } } else if (callerId == 4) { // color curve vertical and horizontal crosshair Color::hsv2rgb01(float(valY), 1.0f, 0.5f, R, G, B); } else if (callerId == ID_LABREGION_HUE) { // TODO - float x = valX - 1.f/6.f; + float x = valX - 1.0/6.0; if (x < 0.f) { x += 1.f; } diff --git a/rtgui/coordinateadjuster.cc b/rtgui/coordinateadjuster.cc index ebf36b7e7..57190cf63 100644 --- a/rtgui/coordinateadjuster.cc +++ b/rtgui/coordinateadjuster.cc @@ -69,14 +69,14 @@ void CoordinateAdjuster::AxisAdjuster::setValue(double newValue) { float range = rangeUpperBound - rangeLowerBound; spinButtonConn.block(true); - spinButton->set_value(newValue * range + rangeLowerBound); + spinButton->set_value(static_cast(newValue) * range + rangeLowerBound); spinButtonConn.block(false); } void CoordinateAdjuster::AxisAdjuster::valueChanged() { float range = rangeUpperBound - rangeLowerBound; - parent->updatePos(idx, (spinButton->get_value() - rangeLowerBound) / range); + parent->updatePos(idx, (static_cast(spinButton->get_value()) - rangeLowerBound) / range); } CoordinateAdjuster::CoordinateAdjuster(CoordinateProvider *provider, CurveEditorSubGroup *parent, const std::vector &axis) @@ -171,7 +171,7 @@ void CoordinateAdjuster::startNumericalAdjustment(const std::vector Gtk::SpinButton *currSpinButton = axisAdjusters.at(i)->spinButton; currSpinButton->set_sensitive(true); float range = axisAdjusters.at(i)->rangeUpperBound - axisAdjusters.at(i)->rangeLowerBound; - currSpinButton->set_range(newBoundaries.at(i).minVal * range + axisAdjusters.at(i)->rangeLowerBound, newBoundaries.at(i).maxVal * range + axisAdjusters.at(i)->rangeLowerBound); + currSpinButton->set_range(newBoundaries.at(i).minVal * static_cast(range) + static_cast(axisAdjusters.at(i)->rangeLowerBound), newBoundaries.at(i).maxVal * static_cast(range) + static_cast(axisAdjusters.at(i)->rangeLowerBound)); } axisAdjusters.at(0)->spinButton->grab_focus(); @@ -200,7 +200,7 @@ void CoordinateAdjuster::switchAdjustedPoint(std::vector &pos, const std // ...narrow the range to the new interval float range = axisAdjusters.at(i)->rangeUpperBound - axisAdjusters.at(i)->rangeLowerBound; - currAxis->spinButton->set_range(newBoundaries.at(i).minVal * range + axisAdjusters.at(i)->rangeLowerBound, newBoundaries.at(i).maxVal * range + axisAdjusters.at(i)->rangeLowerBound); + currAxis->spinButton->set_range(newBoundaries.at(i).minVal * static_cast(range) + static_cast(axisAdjusters.at(i)->rangeLowerBound), newBoundaries.at(i).maxVal * static_cast(range) + static_cast(axisAdjusters.at(i)->rangeLowerBound)); // enable events currAxis->spinButtonConn.block(false); diff --git a/rtgui/crop.cc b/rtgui/crop.cc index 3bdcf14cf..d9d496523 100644 --- a/rtgui/crop.cc +++ b/rtgui/crop.cc @@ -1006,7 +1006,7 @@ void Crop::cropWidth1Resized (int &X, int &Y, int &W, int &H, float custom_ratio } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0.f ? custom_ratio : static_cast(getRatio()); H = (int)round(W / r); int Hmax = min(ny + nh, maxh - ny); @@ -1053,7 +1053,7 @@ void Crop::cropWidth2Resized (int &X, int &Y, int &W, int &H, float custom_ratio } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); H = (int)round(W / r); int Hmax = min(ny + nh, maxh - ny); @@ -1101,7 +1101,7 @@ void Crop::cropHeight1Resized (int &X, int &Y, int &W, int &H, float custom_rati } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); W = (int)round(H * r); int Wmax = min(nx + nw, maxw - nx); @@ -1148,7 +1148,7 @@ void Crop::cropHeight2Resized (int &X, int &Y, int &W, int &H, float custom_rati } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); W = (int)round(H * r); int Wmax = min(nx + nw, maxw - nx); @@ -1205,7 +1205,7 @@ void Crop::cropTopLeftResized (int &X, int &Y, int &W, int &H, float custom_rati } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); W = (int)round(H * r); if (W > oldXR) { @@ -1252,7 +1252,7 @@ void Crop::cropTopRightResized (int &X, int &Y, int &W, int &H, float custom_rat } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); W = (int)round(H * r); if (W > maxw - nx) { @@ -1298,7 +1298,7 @@ void Crop::cropBottomLeftResized (int &X, int &Y, int &W, int &H, float custom_r } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); W = (int)round(H * r); if (W > oldXR) { @@ -1342,7 +1342,7 @@ void Crop::cropBottomRightResized (int &X, int &Y, int &W, int &H, float custom_ } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); W = (int)round(H * r); if (W > maxw - nx) { diff --git a/rtgui/editwidgets.cc b/rtgui/editwidgets.cc index f7c748744..e67b664db 100644 --- a/rtgui/editwidgets.cc +++ b/rtgui/editwidgets.cc @@ -126,13 +126,13 @@ void Circle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer if (filled && state != INSENSITIVE) { cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*rtengine::RT_PI); - if (innerLineWidth > 0.) { + if (innerLineWidth > 0.f) { cr->fill_preserve(); cr->stroke(); } else { cr->fill(); } - } else if (innerLineWidth > 0.) { + } else if (innerLineWidth > 0.f) { cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*rtengine::RT_PI); if (state == INSENSITIVE) { @@ -176,7 +176,7 @@ void Circle::drawToMOChannel (Cairo::RefPtr &cr, unsigned short cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0, 2.*rtengine::RT_PI); if (filled) { - if (innerLineWidth > 0.) { + if (innerLineWidth > 0.f) { cr->fill_preserve(); cr->stroke(); } else { @@ -224,7 +224,7 @@ void Line::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuffer * void Line::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { - if ((flags & F_VISIBLE) && innerLineWidth > 0.) { + if ((flags & F_VISIBLE) && innerLineWidth > 0.f) { if (state != INSENSITIVE) { RGBColor color; @@ -383,13 +383,13 @@ void Polyline::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuff } } - if (innerLineWidth > 0.) { + if (innerLineWidth > 0.f) { cr->fill_preserve(); cr->stroke(); } else { cr->fill(); } - } else if (innerLineWidth > 0.) { + } else if (innerLineWidth > 0.f) { rtengine::Coord currPos; for (unsigned int i = 0; i < points.size(); ++i) { @@ -459,7 +459,7 @@ void Polyline::drawToMOChannel (Cairo::RefPtr &cr, unsigned shor } if (filled) { - if (innerLineWidth > 0.) { + if (innerLineWidth > 0.f) { cr->fill_preserve(); cr->stroke(); } else { @@ -576,13 +576,13 @@ void Rectangle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuf if (filled && state != INSENSITIVE) { cr->rectangle(tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); - if (innerLineWidth > 0.) { + if (innerLineWidth > 0.f) { cr->fill_preserve(); cr->stroke(); } else { cr->fill(); } - } else if (innerLineWidth > 0.) { + } else if (innerLineWidth > 0.f) { cr->rectangle(tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); if (state == INSENSITIVE) { @@ -634,7 +634,7 @@ void Rectangle::drawToMOChannel(Cairo::RefPtr &cr, unsigned shor cr->rectangle(tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); if (filled) { - if (innerLineWidth > 0.) { + if (innerLineWidth > 0.f) { cr->fill_preserve(); cr->stroke(); } else {