diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index 76f4e435a..96711c1a0 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -85,7 +85,7 @@ protected: public: ImageSource () : references (1), redAWBMul(-1.), greenAWBMul(-1.), blueAWBMul(-1.), - embProfile(nullptr), idata(nullptr), dirpyrdenoiseExpComp(INFINITY) {} + embProfile(nullptr), idata(nullptr), dirpyrdenoiseExpComp(RT_INFINITY) {} ~ImageSource () override {} virtual int load (const Glib::ustring &fname) = 0; diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index be64be0fc..0e621b254 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -897,10 +897,10 @@ void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const //init for edge and denoise float vari[4]; - vari[0] = 8.f * SQR((cp.lev0n / 125.0) * (1.0 + cp.lev0n / 25.0)); - 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)); + vari[0] = 8.f * SQR((cp.lev0n / 125.f) * (1.f + cp.lev0n / 25.f)); + vari[1] = 8.f * SQR((cp.lev1n / 125.f) * (1.f + cp.lev1n / 25.f)); + vari[2] = 8.f * SQR((cp.lev2n / 125.f) * (1.f + cp.lev2n / 25.f)); + vari[3] = 8.f * SQR((cp.lev3n / 125.f) * (1.f + cp.lev3n / 25.f)); if((cp.lev0n > 0.1f || cp.lev1n > 0.1f || cp.lev2n > 0.1f || cp.lev3n > 0.1f) && cp.noiseena) { int edge = 1; @@ -1116,7 +1116,7 @@ void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const float Chprov1 = sqrtf(SQR(a) + SQR(b)); yBuffer[col] = (Chprov1 == 0.f) ? 1.f : a / Chprov1; xBuffer[col] = (Chprov1 == 0.f) ? 0.f : b / Chprov1; - chprovBuffer[col] = Chprov1 / 327.68; + chprovBuffer[col] = Chprov1 / 327.68f; } } @@ -1280,7 +1280,7 @@ void ImProcFunctions::Aver( float * RESTRICT DataList, int datalen, float &aver for(int i = 0; i < datalen; i++) { if(DataList[i] >= thres) { - averaP += DataList[i]; + averaP += static_cast(DataList[i]); if(DataList[i] > lmax) { lmax = DataList[i]; @@ -1288,7 +1288,7 @@ void ImProcFunctions::Aver( float * RESTRICT DataList, int datalen, float &aver countP++; } else if(DataList[i] < -thres) { - averaN += DataList[i]; + averaN += static_cast(DataList[i]); if(DataList[i] < lmin) { lmin = DataList[i]; @@ -1334,10 +1334,10 @@ void ImProcFunctions::Sigma( float * RESTRICT DataList, int datalen, float aver for(int i = 0; i < datalen; i++) { if(DataList[i] >= thres) { - variP += SQR(DataList[i] - averagePlus); + variP += static_cast(SQR(DataList[i] - averagePlus)); countP++; } else if(DataList[i] <= -thres) { - variN += SQR(DataList[i] - averageNeg); + variN += static_cast(SQR(DataList[i] - averageNeg)); countN++; } } @@ -1613,7 +1613,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * #endif for (int i = 0; i < W_L * H_L; i++) { - avedbl += WavCoeffs_L0[i]; + avedbl += static_cast(WavCoeffs_L0[i]); } #ifdef _OPENMP @@ -1702,7 +1702,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * #pragma omp parallel num_threads(wavNestedLevels) if(wavNestedLevels>1) #endif { - if(contrast != 0.f && cp.resena && max0 > 0.0) { // contrast = 0.f means that all will be multiplied by 1.f, so we can skip this step + if(contrast != 0.f && cp.resena && max0 > 0.f) { // contrast = 0.f means that all will be multiplied by 1.f, so we can skip this step { #ifdef _OPENMP #pragma omp for @@ -2011,7 +2011,7 @@ void ImProcFunctions::WaveletAandBAllAB(wavelet_decomposition &WaveletCoeffs_a, editWhatever->v(i,j) = valpar; } */ - float valparam = float((hhCurve->getVal(Color::huelab_to_huehsv2(hueR)) - 0.5f) * 1.7f) + hueR; //get H=f(H) 1.7 optimisation ! + float valparam = (static_cast(hhCurve->getVal(Color::huelab_to_huehsv2(hueR))) - 0.5f) * 1.7f + hueR; //get H=f(H) 1.7 optimisation ! float2 sincosval = xsincosf(valparam); WavCoeffs_a0[i * W_L + j] = chR * sincosval.y; WavCoeffs_b0[i * W_L + j] = chR * sincosval.x; @@ -3016,9 +3016,8 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit if(Chutili) { int i_i = i / W_L; int j_j = i - i_i * W_L; - double lr; float modhue2 = varhue[i_i][j_j]; - float valparam = float((ChCurve->getVal(lr = Color::huelab_to_huehsv2(modhue2)) - 0.5f)); //get valparam=f(H) + float valparam = static_cast(ChCurve->getVal(Color::huelab_to_huehsv2(modhue2))) - 0.5f; //get valparam=f(H) if(valparam > 0.f) { scale2 = 1.f + 3.f * valparam; //arbitrary value diff --git a/rtengine/rawimage.cc b/rtengine/rawimage.cc index 4421e4af4..34d5d961c 100644 --- a/rtengine/rawimage.cc +++ b/rtengine/rawimage.cc @@ -171,7 +171,7 @@ void RawImage::get_colorsCoeff( float *pre_mul_, float *scale_mul_, float *cblac } for (int c = 0; c < 4; c++) { - dsumthr[c] += sum[c]; + dsumthr[c] += static_cast(sum[c]); } skip_block2: @@ -195,7 +195,7 @@ skip_block2: } for(int c = 0; c < 4; c++) { - dsum[c] -= cblack_[c] * dsum[c + 4]; + dsum[c] -= static_cast(cblack_[c]) * dsum[c + 4]; } } else if(isXtrans()) { @@ -241,7 +241,7 @@ skip_block2: } for (int c = 0; c < 8; c++) { - dsumthr[c] += sum[c]; + dsumthr[c] += static_cast(sum[c]); } skip_block3: @@ -365,18 +365,14 @@ skip_block: } for (dmin = DBL_MAX, dmax = c = 0; c < 4; c++) { - if (dmin > pre_mul_[c]) { - dmin = pre_mul_[c]; - } - - if (dmax < pre_mul_[c]) { - dmax = pre_mul_[c]; - } + dmin = rtengine::min(dmin, pre_mul_[c]); + dmax = rtengine::max(dmax, pre_mul_[c]); } for (c = 0; c < 4; c++) { int sat = this->get_white(c) - cblack_[c]; - scale_mul_[c] = (pre_mul_[c] /= dmax) * 65535.0 / sat; + pre_mul_[c] /= static_cast(dmax); + scale_mul_[c] = pre_mul_[c] * 65535.f / sat; } if (settings->verbose) { @@ -387,25 +383,30 @@ skip_block: asn[c] = 0; } - if (asn[c] > dmax) { + if (asn[c] > static_cast(dmax)) { dmax = asn[c]; } } for (c = 0; c < 4; c++) { - asn[c] /= dmax; + asn[c] /= static_cast(dmax); } printf("cam_mul:[%f %f %f %f], AsShotNeutral:[%f %f %f %f]\n", - cam_mul[0], cam_mul[1], cam_mul[2], cam_mul[3], asn[0], asn[1], asn[2], asn[3]); + static_cast(cam_mul[0]), static_cast(cam_mul[1]), + static_cast(cam_mul[2]), static_cast(cam_mul[3]), + static_cast(asn[0]), static_cast(asn[1]), static_cast(asn[2]), static_cast(asn[3])); printf("pre_mul:[%f %f %f %f], scale_mul:[%f %f %f %f], cblack:[%f %f %f %f]\n", - pre_mul_[0], pre_mul_[1], pre_mul_[2], pre_mul_[3], - scale_mul_[0], scale_mul_[1], scale_mul_[2], scale_mul_[3], - cblack_[0], cblack_[1], cblack_[2], cblack_[3]); + static_cast(pre_mul_[0]), static_cast(pre_mul_[1]), + static_cast(pre_mul_[2]), static_cast(pre_mul_[3]), + static_cast(scale_mul_[0]), static_cast(scale_mul_[1]), + static_cast(scale_mul_[2]), static_cast(scale_mul_[3]), + static_cast(cblack_[0]), static_cast(cblack_[1]), + static_cast(cblack_[2]), static_cast(cblack_[3])); printf("rgb_cam:[ [ %f %f %f], [%f %f %f], [%f %f %f] ]%s\n", - rgb_cam[0][0], rgb_cam[1][0], rgb_cam[2][0], - rgb_cam[0][1], rgb_cam[1][1], rgb_cam[2][1], - rgb_cam[0][2], rgb_cam[1][2], rgb_cam[2][2], + static_cast(rgb_cam[0][0]), static_cast(rgb_cam[1][0]), static_cast(rgb_cam[2][0]), + static_cast(rgb_cam[0][1]), static_cast(rgb_cam[1][1]), static_cast(rgb_cam[2][1]), + static_cast(rgb_cam[0][2]), static_cast(rgb_cam[1][2]), static_cast(rgb_cam[2][2]), (!this->isBayer()) ? " (not bayer)" : ""); } diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 003e018a4..fcc85f2c6 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -17,6 +17,7 @@ * along with RawTherapee. If not, see . */ #include +#include #include #include "camconst.h" @@ -98,7 +99,7 @@ void transLineFuji (const float* const red, const float* const green, const floa { // Fuji SuperCCD rotation + coarse rotation - int start = ABS(fw - i); + int start = std::abs(fw - i); int w = fw * 2 + 1; int h = (imheight - fw) * 2 + 1; int end = min(h + fw - i, w - fw + i); @@ -422,10 +423,6 @@ void transLineD1x (const float* const red, const float* const green, const float namespace rtengine { -#undef ABS - -#define ABS(a) ((a)<0?-(a):(a)) - RawImageSource::RawImageSource () : ImageSource() , W(0), H(0) @@ -615,7 +612,7 @@ float calculate_scale_mul(float scale_mul[4], const float pre_mul_[4], const flo { if (isMono || colors == 1) { for (int c = 0; c < 4; c++) { - scale_mul[c] = 65535.0 / (c_white[c] - c_black[c]); + scale_mul[c] = 65535.f / (c_white[c] - c_black[c]); } } else { float pre_mul[4]; @@ -631,7 +628,7 @@ float calculate_scale_mul(float scale_mul[4], const float pre_mul_[4], const flo float maxpremul = max(pre_mul[0], pre_mul[1], pre_mul[2], pre_mul[3]); for (int c = 0; c < 4; c++) { - scale_mul[c] = (pre_mul[c] / maxpremul) * 65535.0 / (c_white[c] - c_black[c]); + scale_mul[c] = (pre_mul[c] / maxpremul) * 65535.f / (c_white[c] - c_black[c]); } } @@ -670,7 +667,7 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima || (ri->getSensorType() == ST_BAYER && raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::MONO)); for (int i = 0; i < 4; ++i) { - c_white[i] = (ri->get_white(i) - cblacksom[i]) / raw.expos + cblacksom[i]; + c_white[i] = (ri->get_white(i) - cblacksom[i]) / static_cast(raw.expos) + cblacksom[i]; } float gain = calculate_scale_mul(new_scale_mul, new_pre_mul, c_white, cblacksom, isMono, ri->get_colors()); @@ -679,21 +676,21 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima bm = new_scale_mul[2] / scale_mul[2] * gain; //fprintf(stderr, "camera gain: %f, current wb gain: %f, diff in stops %f\n", camInitialGain, gain, log2(camInitialGain) - log2(gain)); } else { - // old scaling: used a fixed reference gain based on camera (as-shot) white balance - - // how much we need to scale each channel to get our new white balance - rm = refwb_red / rm; - gm = refwb_green / gm; - bm = refwb_blue / bm; - // normalize so larger multiplier becomes 1.0 - float minval = min(rm, gm, bm); - rm /= minval; - gm /= minval; - bm /= minval; - // multiply with reference gain, ie as-shot WB - rm *= camInitialGain; - gm *= camInitialGain; - bm *= camInitialGain; +// // old scaling: used a fixed reference gain based on camera (as-shot) white balance +// +// // how much we need to scale each channel to get our new white balance +// rm = refwb_red / rm; +// gm = refwb_green / gm; +// bm = refwb_blue / bm; +// // normalize so larger multiplier becomes 1.0 +// float minval = min(rm, gm, bm); +// rm /= minval; +// gm /= minval; +// bm /= minval; +// // multiply with reference gain, ie as-shot WB +// rm *= camInitialGain; +// gm *= camInitialGain; +// bm *= camInitialGain; } defGain = 0.0; @@ -872,13 +869,13 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima for (int i = 1; i < image->getHeight() - 1; i++) { for (int j = 2 - (a + i + 1) % 2; j < image->getWidth() - 1; j += 2) { // edge-adaptive interpolation - double dh = (ABS(image->r(i, j + 1) - image->r(i, j - 1)) + ABS(image->g(i, j + 1) - image->g(i, j - 1)) + ABS(image->b(i, j + 1) - image->b(i, j - 1))) / 1.0; - double dv = (ABS(image->r(i + 1, j) - image->r(i - 1, j)) + ABS(image->g(i + 1, j) - image->g(i - 1, j)) + ABS(image->b(i + 1, j) - image->b(i - 1, j))) / 1.0; - double eh = 1.0 / (1.0 + dh); - double ev = 1.0 / (1.0 + dv); - image->r(i, j) = (eh * (image->r(i, j + 1) + image->r(i, j - 1)) + ev * (image->r(i + 1, j) + image->r(i - 1, j))) / (2.0 * (eh + ev)); - image->g(i, j) = (eh * (image->g(i, j + 1) + image->g(i, j - 1)) + ev * (image->g(i + 1, j) + image->g(i - 1, j))) / (2.0 * (eh + ev)); - image->b(i, j) = (eh * (image->b(i, j + 1) + image->b(i, j - 1)) + ev * (image->b(i + 1, j) + image->b(i - 1, j))) / (2.0 * (eh + ev)); + float dh = (std::fabs(image->r(i, j + 1) - image->r(i, j - 1)) + std::fabs(image->g(i, j + 1) - image->g(i, j - 1)) + std::fabs(image->b(i, j + 1) - image->b(i, j - 1))); + float dv = (std::fabs(image->r(i + 1, j) - image->r(i - 1, j)) + std::fabs(image->g(i + 1, j) - image->g(i - 1, j)) + std::fabs(image->b(i + 1, j) - image->b(i - 1, j))); + float eh = 1.f / (1.f + dh); + float ev = 1.f / (1.f + dv); + image->r(i, j) = (eh * (image->r(i, j + 1) + image->r(i, j - 1)) + ev * (image->r(i + 1, j) + image->r(i - 1, j))) / (2.f * (eh + ev)); + image->g(i, j) = (eh * (image->g(i, j + 1) + image->g(i, j - 1)) + ev * (image->g(i + 1, j) + image->g(i - 1, j))) / (2.f * (eh + ev)); + image->b(i, j) = (eh * (image->b(i, j + 1) + image->b(i, j - 1)) + ev * (image->b(i + 1, j) + image->b(i - 1, j))) / (2.f * (eh + ev)); } // first pixel @@ -1542,7 +1539,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le } } - if(prepareDenoise && dirpyrdenoiseExpComp == INFINITY) { + if(prepareDenoise && dirpyrdenoiseExpComp == RT_INFINITY) { LUTu aehist; int aehistcompr; double clip = 0; @@ -3873,7 +3870,7 @@ void RawImageSource::getRowStartEnd (int x, int &start, int &end) { if (fuji) { int fw = ri->get_FujiWidth(); - start = ABS(fw - x) + border; + start = std::abs(fw - x) + border; end = min(H + W - fw - x, fw + x) - border; } else { start = border; @@ -3914,7 +3911,7 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm) if (fuji) { for (int i = 32; i < H - 32; i++) { int fw = ri->get_FujiWidth(); - int start = ABS(fw - i) + 32; + int start = std::abs(fw - i) + 32; int end = min(H + W - fw - i, fw + i) - 32; for (int j = start; j < end; j++) { diff --git a/rtengine/shmap.cc b/rtengine/shmap.cc index abdcc42a4..306e30bdd 100644 --- a/rtengine/shmap.cc +++ b/rtengine/shmap.cc @@ -27,6 +27,37 @@ #undef THREAD_PRIORITY_NORMAL #include "opthelper.h" +namespace { + +void fillLuminance(rtengine::Imagefloat* img, float** luminance, const float lumi[3], int W, int H) // fill with luminance +{ + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = 0; i < H; i++) + for (int j = 0; j < W; j++) { + luminance[i][j] = lumi[0] * std::max(img->r(i, j), 0.f) + lumi[1] * std::max(img->g(i, j), 0.f) + lumi[2] * std::max(img->b(i, j), 0.f); + } + +} + +void fillLuminanceL(float** L, float** luminance, int W, int H) // fill with luminance +{ + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = 0; i < H; i++) + for (int j = 0; j < W; j++) { + luminance[i][j] = std::max(L[i][j], 0.f) ;//we can put here some enhancements Gamma, compression data,... + } + +} + +} namespace rtengine { @@ -51,39 +82,13 @@ SHMap::~SHMap () delete [] map; } -void SHMap::fillLuminance( Imagefloat * img, float **luminance, double lumi[3] ) // fill with luminance -{ - -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int i = 0; i < H; i++) - for (int j = 0; j < W; j++) { - luminance[i][j] = lumi[0] * std::max(img->r(i, j), 0.f) + lumi[1] * std::max(img->g(i, j), 0.f) + lumi[2] * std::max(img->b(i, j), 0.f); - } - -} - -void SHMap::fillLuminanceL( float ** L, float **luminance) // fill with luminance -{ - -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int i = 0; i < H; i++) - for (int j = 0; j < W; j++) { - luminance[i][j] = std::max(L[i][j], 0.f) ;//we can put here some enhancements Gamma, compression data,... - } - -} - void SHMap::update (Imagefloat* img, double radius, double lumi[3], bool hq, int skip) { + const float lumif[3] = { static_cast(lumi[0]), static_cast(lumi[1]), static_cast(lumi[2]) }; + if (!hq) { - fillLuminance( img, map, lumi); + fillLuminance(img, map, lumif, W, H); const bool useBoxBlur = radius > 40.0; // boxblur is less prone to artifacts for large radi @@ -91,7 +96,7 @@ void SHMap::update (Imagefloat* img, double radius, double lumi[3], bool hq, int #pragma omp parallel if (!useBoxBlur) #endif { - gaussianBlur (map, map, W, H, radius, useBoxBlur); + gaussianBlur(map, map, W, H, radius, useBoxBlur); } } @@ -99,7 +104,7 @@ void SHMap::update (Imagefloat* img, double radius, double lumi[3], bool hq, int //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //experimental dirpyr shmap - float thresh = (100.f * radius); //1000; + float thresh = 100.0 * radius; //1000; // set up range function // calculate size of Lookup table. That's possible because from a value k for all i>=k rangefn[i] will be exp(-10) @@ -142,7 +147,7 @@ void SHMap::update (Imagefloat* img, double radius, double lumi[3], bool hq, int dirpyrlo[1] = buffer; } - fillLuminance( img, dirpyrlo[0], lumi); + fillLuminance(img, dirpyrlo[0], lumif, W, H); scale = 1; int level = 0; @@ -181,28 +186,18 @@ void SHMap::update (Imagefloat* img, double radius, double lumi[3], bool hq, int for (int j = 0; j < W; j++) { _val = map[i][j]; - if (_val < _min_f) { - _min_f = _val; - } + _min_f = std::min(_min_f, _val); + _max_f = std::max(_max_f, _val); - if (_val > _max_f) { - _max_f = _val; - } - - _avg += _val; + _avg += static_cast(_val); } #ifdef _OPENMP #pragma omp critical #endif { - if(_min_f < min_f ) { - min_f = _min_f; - } - - if(_max_f > max_f ) { - max_f = _max_f; - } + min_f = std::min(min_f, _min_f); + max_f = std::max(max_f, _max_f); } } _avg /= ((H) * (W)); @@ -214,7 +209,7 @@ void SHMap::updateL (float** L, double radius, bool hq, int skip) { if (!hq) { - fillLuminanceL( L, map); + fillLuminanceL(L, map, W, H); #ifdef _OPENMP #pragma omp parallel #endif @@ -228,7 +223,7 @@ void SHMap::updateL (float** L, double radius, bool hq, int skip) { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //experimental dirpyr shmap - float thresh = (100.f * radius); //1000; + float thresh = 100.0 * radius; //1000; int levrad; // = 16; levrad = 2; //for retinex - otherwise levrad = 16 // set up range function @@ -274,7 +269,7 @@ void SHMap::updateL (float** L, double radius, bool hq, int skip) dirpyrlo[1] = buffer; } - fillLuminanceL( L, dirpyrlo[0]); + fillLuminanceL(L, dirpyrlo[0], W, H); scale = 1; int level = 0; @@ -313,28 +308,18 @@ void SHMap::updateL (float** L, double radius, bool hq, int skip) for (int j = 0; j < W; j++) { _val = map[i][j]; - if (_val < _min_f) { - _min_f = _val; - } + _min_f = std::min(_min_f, _val); + _max_f = std::max(_max_f, _val); - if (_val > _max_f) { - _max_f = _val; - } - - _avg += _val; + _avg += static_cast(_val); } #ifdef _OPENMP #pragma omp critical #endif { - if(_min_f < min_f ) { - min_f = _min_f; - } - - if(_max_f > max_f ) { - max_f = _max_f; - } + min_f = std::min(min_f, _min_f); + max_f = std::max(max_f, _max_f); } } _avg /= ((H) * (W)); diff --git a/rtengine/shmap.h b/rtengine/shmap.h index 68e352b23..b1b1e5eff 100644 --- a/rtengine/shmap.h +++ b/rtengine/shmap.h @@ -48,8 +48,6 @@ public: private: int W, H; - void fillLuminance( Imagefloat * img, float **luminance, double lumi[3] ); - void fillLuminanceL( float ** L, float **luminance ); void dirpyr_shmap(float ** data_fine, float ** data_coarse, int width, int height, const LUTf& rangefn, int level, int scale); }; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 1c1e46a65..c50e23d4b 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -994,7 +994,7 @@ private: ipf.rgbProc (baseImg, labView, nullptr, curve1, curve2, curve, params.toneCurve.saturation, rCurve, gCurve, bCurve, satLimit, satLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, customToneCurvebw1, customToneCurvebw2, rrm, ggm, bbm, autor, autog, autob, expcomp, hlcompr, hlcomprthresh, dcpProf, as, histToneCurve, options.chunkSizeRGB, options.measure); if (settings->verbose) { - printf ("Output image / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", autor, autog, autob); + printf ("Output image / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", static_cast(autor), static_cast(autog), static_cast(autob)); } // if clut was used and size of clut cache == 1 we free the memory used by the clutstore (default clut cache size = 1 for 32 bit OS) @@ -1162,10 +1162,10 @@ private: adap = 2000.; }//if no exif data or wrong else { - float E_V = fcomp + log2 ((fnum * fnum) / fspeed / (fiso / 100.f)); + double E_V = fcomp + log2 ((fnum * fnum) / fspeed / (fiso / 100.f)); E_V += params.toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV - E_V += log2 (params.raw.expos); // exposure raw white point ; log2 ==> linear to EV - adap = powf (2.f, E_V - 3.f); //cd / m2 + E_V += log2(params.raw.expos); // exposure raw white point ; log2 ==> linear to EV + adap = std::pow(2.0, E_V - 3.0); //cd / m2 } LUTf CAMBrightCurveJ; diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index edc378700..8e1dcfaf5 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -124,7 +124,7 @@ void CropWindow::initZoomSteps() zoomSteps.push_back(ZoomStep(" 8%", 1.0/12.0, 120, true)); char lbl[64]; for (int s = 100; s >= 11; --s) { - float z = 10./float(s); + float z = 10.f / s; sprintf(lbl, "% 2d%%", int(z * 100)); bool is_major = (s == s/10 * 10); zoomSteps.push_back(ZoomStep(lbl, z, s, is_major)); diff --git a/rtgui/defringe.cc b/rtgui/defringe.cc index cdec88edc..7aae8377a 100644 --- a/rtgui/defringe.cc +++ b/rtgui/defringe.cc @@ -37,7 +37,7 @@ Defringe::Defringe () : FoldableToolPanel(this, "defringe", M("TP_DEFRINGE_LABEL float R, G, B; for (int i = 0; i < 7; i++) { - float x = float(i) * (1.0f / 6.0); + float x = i / 6.f; Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); bottomMilestones.push_back( GradientMilestone(double(x), double(R), double(G), double(B)) ); } diff --git a/rtgui/diagonalcurveeditorsubgroup.cc b/rtgui/diagonalcurveeditorsubgroup.cc index eed6c63d3..079a083ea 100644 --- a/rtgui/diagonalcurveeditorsubgroup.cc +++ b/rtgui/diagonalcurveeditorsubgroup.cc @@ -477,13 +477,13 @@ void DiagonalCurveEditorSubGroup::pipetteMouseOver(EditDataProvider *provider, i double pos[3]; shcSelector->getPositions(pos[0], pos[1], pos[2]); - if (pipetteVal >= pos[2]) { + if (static_cast(pipetteVal) >= pos[2]) { editedAdjuster = highlights; paramCurve->setActiveParam(4); - } else if(pipetteVal >= pos[1]) { + } else if(static_cast(pipetteVal) >= pos[1]) { editedAdjuster = lights; paramCurve->setActiveParam(5); - } else if(pipetteVal >= pos[0]) { + } else if(static_cast(pipetteVal) >= pos[0]) { editedAdjuster = darks; paramCurve->setActiveParam(6); } else { diff --git a/rtgui/dirpyrequalizer.cc b/rtgui/dirpyrequalizer.cc index fd0268efa..34aecf095 100644 --- a/rtgui/dirpyrequalizer.cc +++ b/rtgui/dirpyrequalizer.cc @@ -428,7 +428,7 @@ void DirPyrEqualizer::lumacontrastPlusPressed () { for (int i = 0; i < 6; i++) { - float inc = 0.05 * (6 - i); + double inc = 0.05 * (6 - i); multiplier[i]->setValue(multiplier[i]->getValue() + inc); adjusterChanged(multiplier[i], multiplier[i]->getValue()); } @@ -439,7 +439,7 @@ void DirPyrEqualizer::lumacontrastMinusPressed () { for (int i = 0; i < 6; i++) { - float inc = -0.05 * (6 - i); + double inc = -0.05 * (6 - i); multiplier[i]->setValue(multiplier[i]->getValue() + inc); adjusterChanged(multiplier[i], multiplier[i]->getValue()); } diff --git a/rtgui/gradient.cc b/rtgui/gradient.cc index 4f389e112..b46f8e1ca 100644 --- a/rtgui/gradient.cc +++ b/rtgui/gradient.cc @@ -164,7 +164,7 @@ void Gradient::updateGeometry(const int centerX, const int centerY, const double const auto decay = feather * rtengine::norm2 (imW, imH) / 200.0; rtengine::Coord origin (imW / 2 + centerX * imW / 200, imH / 2 + centerY * imH / 200); - const auto updateLine = [&](Geometry* geometry, const float radius, const float begin, const float end) + const auto updateLine = [&](Geometry* geometry, const double radius, const double begin, const double end) { const auto line = static_cast(geometry); line->begin = PolarCoord(radius, -degree + begin); @@ -173,7 +173,7 @@ void Gradient::updateGeometry(const int centerX, const int centerY, const double line->end += origin; }; - const auto updateLineWithDecay = [&](Geometry* geometry, const float radius, const float offSetAngle) + const auto updateLineWithDecay = [&](Geometry* geometry, const double radius, const double offSetAngle) { const auto line = static_cast(geometry); line->begin = PolarCoord (radius, -degree + 180.) + PolarCoord (decay, -degree + offSetAngle); diff --git a/rtgui/histogrampanel.cc b/rtgui/histogrampanel.cc index dd0cbde46..b8338e4e8 100644 --- a/rtgui/histogrampanel.cc +++ b/rtgui/histogrampanel.cc @@ -518,26 +518,26 @@ void HistogramRGBArea::updateBackBuffer (int r, int g, int b, const Glib::ustrin // Luma cc->set_source_rgb(1.0, 1.0, 1.0); if (options.histogramDrawMode < 2) { - cc->move_to(Lab_L * (winw - 3.*s) / 100.0 + 0.5*s, 0); - cc->line_to(Lab_L * (winw - 3.*s) / 100.0 + 0.5*s, winh - 0); + cc->move_to(static_cast(Lab_L) * (winw - 3. * s) / 100.0 + 0.5 * s, 0); + cc->line_to(static_cast(Lab_L) * (winw - 3. * s) / 100.0 + 0.5 * s, winh - 0); } else { - cc->move_to(HistogramScaling::log (100, Lab_L) * (winw - 1.) / 100.0 + 0.5*s, 0); - cc->line_to(HistogramScaling::log (100, Lab_L) * (winw - 1.) / 100.0 + 0.5*s, winh - 0); + cc->move_to(HistogramScaling::log(100, Lab_L) * (winw - 1.) / 100.0 + 0.5 * s, 0); + cc->line_to(HistogramScaling::log(100, Lab_L) * (winw - 1.) / 100.0 + 0.5 * s, winh - 0); } cc->stroke(); } if (needChroma) { // Chroma - float chromaval = sqrt(Lab_a * Lab_a + Lab_b * Lab_b) / 1.8; + double chromaval = sqrt(Lab_a * Lab_a + Lab_b * Lab_b) / 1.8; // float chromaval = sqrt(Lab_a*Lab_a + Lab_b*Lab_b); cc->set_source_rgb(0.9, 0.9, 0.0); if (options.histogramDrawMode < 2) { - cc->move_to(chromaval * (winw - 1.) / 100.0 + 0.5*s, 0); - cc->line_to(chromaval * (winw - 1.) / 100.0 + 0.5*s, winh - 0); + cc->move_to(chromaval * (winw - 1.) / 100.0 + 0.5 * s, 0); + cc->line_to(chromaval * (winw - 1.) / 100.0 + 0.5 * s, winh - 0); } else { - cc->move_to(HistogramScaling::log (100, chromaval) * (winw - 1.) / 100.0 + 0.5*s, 0); - cc->line_to(HistogramScaling::log (100, chromaval) * (winw - 1.) / 100.0 + 0.5*s, winh - 0); + cc->move_to(HistogramScaling::log(100, chromaval) * (winw - 1.) / 100.0 + 0.5 * s, 0); + cc->line_to(HistogramScaling::log(100, chromaval) * (winw - 1.) / 100.0 + 0.5 * s, winh - 0); } cc->stroke(); } @@ -989,7 +989,7 @@ void HistogramArea::drawCurve(Cairo::RefPtr &cr, cr->set_line_width(s); cr->move_to (0, vsize - 1); - scale = scale <= 0.f ? 0.001f : scale; // avoid division by zero and negative values + scale = scale <= 0.0 ? 0.001 : scale; // avoid division by zero and negative values for (int i = 0; i < 256; i++) { double val = data[i] * (double)vsize / scale; diff --git a/rtgui/hsvequalizer.cc b/rtgui/hsvequalizer.cc index ee3eb90a7..817ba1f4d 100644 --- a/rtgui/hsvequalizer.cc +++ b/rtgui/hsvequalizer.cc @@ -38,7 +38,7 @@ HSVEqualizer::HSVEqualizer () : FoldableToolPanel(this, "hsvequalizer", M("TP_HS // -0.1 rad < Hue < 1.6 rad for (int i = 0; i < 7; i++) { - float x = float(i) * (1.0f / 6.0); + float x = i / 6.0; Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); bottomMilestones.push_back( GradientMilestone(double(x), double(R), double(G), double(B)) ); } diff --git a/rtgui/labcurve.cc b/rtgui/labcurve.cc index 491b02c4c..5f4febc0a 100644 --- a/rtgui/labcurve.cc +++ b/rtgui/labcurve.cc @@ -203,7 +203,7 @@ LCurve::LCurve () : FoldableToolPanel(this, "labcurves", M("TP_LABCURVE_LABEL"), for (int i = 0; i < 7; i++) { float R, G, B; - float x = float(i) * (1.0f / 6.0); + float x = i / 6.0; Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); milestones.emplace_back(x, R, G, B); } diff --git a/rtgui/labgrid.cc b/rtgui/labgrid.cc index 516dbb825..d8a22b1d9 100644 --- a/rtgui/labgrid.cc +++ b/rtgui/labgrid.cc @@ -209,8 +209,8 @@ bool LabGridArea::on_draw(const ::Cairo::RefPtr &crf) float x, y, z; int ii = i - cells/2; int jj = j - cells/2; - float a = step * (ii + 0.5); - float b = step * (jj + 0.5); + float a = step * (ii + 0.5f); + float b = step * (jj + 0.5f); Color::Lab2XYZ(25000.f, a, b, x, y, z); Color::xyz2srgb(x, y, z, R, G, B); cr->set_source_rgb(R / 65535.f, G / 65535.f, B / 65535.f); @@ -231,10 +231,10 @@ bool LabGridArea::on_draw(const ::Cairo::RefPtr &crf) // drawing the connection line cr->set_antialias(Cairo::ANTIALIAS_DEFAULT); float loa, hia, lob, hib; - loa = .5f * (width + width * low_a); - hia = .5f * (width + width * high_a); - lob = .5f * (height + height * low_b); - hib = .5f * (height + height * high_b); + loa = .5 * (width + width * low_a); + hia = .5 * (width + width * high_a); + lob = .5 * (height + height * low_b); + hib = .5 * (height + height * high_b); cr->set_line_width(2. * double(s)); cr->set_source_rgb(0.6, 0.6, 0.6); cr->move_to(loa, lob); @@ -319,8 +319,8 @@ bool LabGridArea::on_motion_notify_event(GdkEventMotion *event) int height = get_allocated_height() - 2 * inset * s - padding.get_top() - padding.get_bottom(); const float mouse_x = std::min(double(std::max(event->x - inset * s - padding.get_right(), 0.)), double(width)); const float mouse_y = std::min(double(std::max(get_allocated_height() - 1 - event->y - inset * s - padding.get_bottom(), 0.)), double(height)); - const float ma = (2.0 * mouse_x - width) / (float)width; - const float mb = (2.0 * mouse_y - height) / (float)height; + const float ma = (2.f * mouse_x - width) / width; + const float mb = (2.f * mouse_y - height) / height; if (isDragged) { if (litPoint == LOW) { low_a = ma; diff --git a/rtgui/lockablecolorpicker.cc b/rtgui/lockablecolorpicker.cc index 071847424..0a08bb945 100644 --- a/rtgui/lockablecolorpicker.cc +++ b/rtgui/lockablecolorpicker.cc @@ -37,7 +37,7 @@ void LockableColorPicker::updateBackBuffer () int newW, newH; // -------------------- setting some key constants --------------------- - constexpr float circlePadding = 3.f; // keep this value odd + constexpr double circlePadding = 3.0; // keep this value odd constexpr double opacity = 0.62; // --------------------------------------------------------------------- @@ -121,18 +121,18 @@ void LockableColorPicker::updateBackBuffer () bbcr->set_antialias (Cairo::ANTIALIAS_SUBPIXEL); bbcr->set_line_width (0.); - float center = (float)size / 2.f + circlePadding; + double center = static_cast(size) / 2.0 + circlePadding; // black background of the whole color picker bbcr->set_line_width (0.); bbcr->set_source_rgba (0., 0., 0., opacity); - bbcr->arc_negative (center, center, center, 0., (double)rtengine::RT_PI); + bbcr->arc_negative (center, center, center, 0., rtengine::RT_PI); bbcr->line_to (0, 2. * center + textHeight); - bbcr->arc_negative (2. * textPadding, 2. * center + textHeight, 2. * textPadding, (double)rtengine::RT_PI, (double)rtengine::RT_PI / 2.); + bbcr->arc_negative (2. * textPadding, 2. * center + textHeight, 2. * textPadding, rtengine::RT_PI, rtengine::RT_PI / 2.); bbcr->line_to (textWidth, 2. * center + textHeight + 2. * textPadding); - bbcr->arc_negative (textWidth, 2. * center + textHeight, 2. * textPadding, (double)rtengine::RT_PI / 2., 0.); + bbcr->arc_negative (textWidth, 2. * center + textHeight, 2. * textPadding, rtengine::RT_PI / 2., 0.); bbcr->line_to (textWidth + 2. * textPadding, 2. * center + 2. * textPadding); - bbcr->arc_negative (textWidth, 2. * center + 2. * textPadding, 2. * textPadding, 0., (double)rtengine::RT_PI * 1.5); + bbcr->arc_negative (textWidth, 2. * center + 2. * textPadding, 2. * textPadding, 0., rtengine::RT_PI * 1.5); bbcr->line_to (2. * center, 2. * center); bbcr->close_path(); bbcr->set_line_join (Cairo::LINE_JOIN_BEVEL); @@ -222,7 +222,7 @@ void LockableColorPicker::updateBackBuffer () bbcr->set_antialias(Cairo::ANTIALIAS_SUBPIXEL); - float center = (float)size / 2.f + circlePadding; + double center = static_cast(size) / 2. + circlePadding; // light grey circle around the color mark bbcr->arc (center, center, center - circlePadding / 2., 0., 2. * (double)rtengine::RT_PI);