diff --git a/rtengine/capturesharpening.cc b/rtengine/capturesharpening.cc index b5b74e140..4dcdd0734 100644 --- a/rtengine/capturesharpening.cc +++ b/rtengine/capturesharpening.cc @@ -761,13 +761,13 @@ bool checkForStop(float** tmpIThr, float** iterCheck, int fullTileSize, int bord return false; } -void CaptureDeconvSharpening (float** luminance, const float* const * oldLuminance, const float * const * blend, int W, int H, double sigma, double sigmaCornerOffset, int iterations, bool checkIterStop, rtengine::ProgressListener* plistener, double startVal, double endVal) +void CaptureDeconvSharpening (float** luminance, const float* const * oldLuminance, const float * const * blend, int W, int H, float sigma, float sigmaCornerOffset, int iterations, bool checkIterStop, rtengine::ProgressListener* plistener, double startVal, double endVal) { BENCHFUN - const bool is9x9 = (sigma <= 1.50 && sigmaCornerOffset == 0.0); - const bool is7x7 = (sigma <= 1.15 && sigmaCornerOffset == 0.0); - const bool is5x5 = (sigma <= 0.84 && sigmaCornerOffset == 0.0); - const bool is3x3 = (sigma < 0.6 && sigmaCornerOffset == 0.0); + const bool is9x9 = (sigma <= 1.5f && sigmaCornerOffset == 0.f); + const bool is7x7 = (sigma <= 1.15f && sigmaCornerOffset == 0.f); + const bool is5x5 = (sigma <= 0.84f && sigmaCornerOffset == 0.f); + const bool is3x3 = (sigma < 0.6f && sigmaCornerOffset == 0.f); float kernel13[13][13]; float kernel9[9][9]; float kernel7[7][7]; @@ -906,11 +906,11 @@ BENCHFUN } } } else { - if (sigmaCornerOffset != 0.0) { + if (sigmaCornerOffset != 0.f) { 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 > 1.50) { // have to use 13x13 kernel + if (sigmaTile > 1.5f) { // have to use 13x13 kernel float lkernel13[13][13]; compute13x13kernel(static_cast(sigma) + distanceFactor * distance, lkernel13); for (int k = 0; k < iterations; ++k) { @@ -921,7 +921,7 @@ BENCHFUN break; } } - } else if (sigmaTile > 1.15) { // have to use 9x9 kernel + } else if (sigmaTile > 1.15f) { // have to use 9x9 kernel float lkernel9[9][9]; compute9x9kernel(static_cast(sigma) + distanceFactor * distance, lkernel9); for (int k = 0; k < iterations; ++k) { @@ -932,7 +932,7 @@ BENCHFUN break; } } - } else if (sigmaTile > 0.84) { // have to use 7x7 kernel + } else 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) { diff --git a/rtengine/filmnegativeproc.cc b/rtengine/filmnegativeproc.cc index 1f27983ed..c7de3c483 100644 --- a/rtengine/filmnegativeproc.cc +++ b/rtengine/filmnegativeproc.cc @@ -122,8 +122,8 @@ bool rtengine::RawImageSource::getFilmNegativeExponents(Coord2D spotA, Coord2D s } if (settings->verbose) { - printf("Clear film values: R=%g G=%g B=%g\n", clearVals[0], clearVals[1], clearVals[2]); - printf("Dense film values: R=%g G=%g B=%g\n", denseVals[0], denseVals[1], denseVals[2]); + printf("Clear film values: R=%g G=%g B=%g\n", static_cast(clearVals[0]), static_cast(clearVals[1]), static_cast(clearVals[2])); + printf("Dense film values: R=%g G=%g B=%g\n", static_cast(denseVals[0]), static_cast(denseVals[1]), static_cast(denseVals[2])); } const float denseGreenRatio = clearVals[1] / denseVals[1]; @@ -141,12 +141,12 @@ bool rtengine::RawImageSource::getFilmNegativeExponents(Coord2D spotA, Coord2D s if (ch == 1) { newExps[ch] = 1.f; // Green is the reference channel } else { - newExps[ch] = CLAMP(logBase(clearVals[ch] / denseVals[ch], denseGreenRatio), 0.3f, 4.f); + newExps[ch] = rtengine::LIM(logBase(clearVals[ch] / denseVals[ch], denseGreenRatio), 0.3f, 4.f); } } if (settings->verbose) { - printf("New exponents: R=%g G=%g B=%g\n", newExps[0], newExps[1], newExps[2]); + printf("New exponents: R=%g G=%g B=%g\n", static_cast(newExps[0]), static_cast(newExps[1]), static_cast(newExps[2])); } return true; @@ -246,8 +246,8 @@ void rtengine::RawImageSource::filmNegativeProcess(const procparams::FilmNegativ if (settings->verbose) { printf("Sample count: %zu, %zu, %zu\n", cvs[0].size(), cvs[1].size(), cvs[2].size()); - printf("Medians: %g %g %g\n", medians[0], medians[1], medians[2] ); - printf("Computed multipliers: %g %g %g\n", mults[0], mults[1], mults[2] ); + printf("Medians: %g %g %g\n", static_cast(medians[0]), static_cast(medians[1]), static_cast(medians[2])); + printf("Computed multipliers: %g %g %g\n", static_cast(mults[0]), static_cast(mults[1]), static_cast(mults[2])); printf("Median calc time us: %d\n", t3.etime(t2)); } diff --git a/rtengine/filmnegativethumb.cc b/rtengine/filmnegativethumb.cc index b31432a55..003fab8e0 100644 --- a/rtengine/filmnegativethumb.cc +++ b/rtengine/filmnegativethumb.cc @@ -89,8 +89,8 @@ void rtengine::Thumbnail::processFilmNegative( const float bmult = (MAX_OUT_VALUE / (bmed * 24)) ; if (settings->verbose) { - printf("Thumbnail channel medians: %g %g %g\n", rmed, gmed, bmed); - printf("Thumbnail computed multipliers: %g %g %g\n", rmult, gmult, bmult); + printf("Thumbnail channel medians: %g %g %g\n", static_cast(rmed), static_cast(gmed), static_cast(bmed)); + printf("Thumbnail computed multipliers: %g %g %g\n", static_cast(rmult), static_cast(gmult), static_cast(bmult)); } #ifdef __SSE2__ diff --git a/rtengine/hilite_recon.cc b/rtengine/hilite_recon.cc index a56ff1918..1ba42a68b 100644 --- a/rtengine/hilite_recon.cc +++ b/rtengine/hilite_recon.cc @@ -323,7 +323,7 @@ void RawImageSource::HLRecovery_inpaint(float** red, float** green, float** blue if (settings->verbose) { for (int c = 0; c < 3; ++c) { - printf("chmax[%d] : %f\tclmax[%d] : %f\tratio[%d] : %f\n", c, chmax[c], c, clmax[c], c, chmax[c] / clmax[c]); + printf("chmax[%d] : %f\tclmax[%d] : %f\tratio[%d] : %f\n", c, static_cast(chmax[c]), c, static_cast(clmax[c]), c, static_cast(chmax[c] / clmax[c])); } } @@ -366,7 +366,7 @@ void RawImageSource::HLRecovery_inpaint(float** red, float** green, float** blue if (settings->verbose) { for (int c = 0; c < 3; ++c) { - printf("correction factor[%d] : %f\n", c, factor[c]); + printf("correction factor[%d] : %f\n", c, static_cast(factor[c])); } } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index e915a11b0..c14e889ad 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -734,7 +734,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) if (params->blackwhite.enabled && params->blackwhite.autoc && abwListener) { if (settings->verbose) { - printf("ImProcCoordinator / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", bwAutoR, bwAutoG, bwAutoB); + printf("ImProcCoordinator / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", static_cast(bwAutoR), static_cast(bwAutoG), static_cast(bwAutoB)); } abwListener->BWChanged((float) rrm, (float) ggm, (float) bbm); @@ -871,7 +871,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) double E_V = fcomp + log2(double ((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 + adap = pow(2.0, E_V - 3.0); // cd / m2 // end calculation adaptation scene luminosity } diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 236f3c672..7ade3e92c 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -5142,7 +5142,7 @@ void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, int Wi float *Qpr = ncie->Q_p[0]; if (settings->verbose) { - printf ("minQ=%f maxQ=%f Qpro=%f\n", minQ, maxQ, Qpro); + printf ("minQ=%f maxQ=%f Qpro=%f\n", static_cast(minQ), static_cast(maxQ), static_cast(Qpro)); } if (maxQ > Qpro) { @@ -5563,7 +5563,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double contr = (int) 50.0f * (1.1f - ospread); contr = max (0, min (100, contr)); //take gamma into account - double whiteclipg = (int) (CurveFactory::gamma2 (whiteclip * corr / 65536.0) * 65536.0); + double whiteclipg = (int) (CurveFactory::gamma2(whiteclip * static_cast(corr) / 65536.0) * 65536.0); float gavg = 0.; @@ -5585,7 +5585,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double } } - whiteclipg = CurveFactory::igamma2 ((float) (whiteclipg / 65535.0)) * 65535.0; //need to inverse gamma transform to get correct exposure compensation parameter + whiteclipg = CurveFactory::igamma2(whiteclipg / 65535.0) * 65535.0; //need to inverse gamma transform to get correct exposure compensation parameter //correction with gamma black = (int) ((65535 * black) / whiteclipg); @@ -5820,8 +5820,8 @@ void ImProcFunctions::lab2rgb (const LabImage &src, Imagefloat &dst, const Glib: */ void ImProcFunctions::colorToningLabGrid(LabImage *lab, int xstart, int xend, int ystart, int yend, bool MultiThread) { - const float factor = ColorToningParams::LABGRID_CORR_MAX * 3.f; - const float scaling = ColorToningParams::LABGRID_CORR_SCALE; + const double factor = ColorToningParams::LABGRID_CORR_MAX * 3.0; + const double scaling = ColorToningParams::LABGRID_CORR_SCALE; float a_scale = (params->colorToning.labgridAHigh - params->colorToning.labgridALow) / factor / scaling; float a_base = params->colorToning.labgridALow / scaling; float b_scale = (params->colorToning.labgridBHigh - params->colorToning.labgridBLow) / factor / scaling; diff --git a/rtengine/ipsharpen.cc b/rtengine/ipsharpen.cc index 959030dc6..0e46cd596 100644 --- a/rtengine/ipsharpen.cc +++ b/rtengine/ipsharpen.cc @@ -103,7 +103,7 @@ void sharpenHaloCtrl (float** luminance, float** blurmap, float** base, float** void dcdamping (float** aI, float** aO, float damping, int W, int H) { - const float dampingFac = -2.0 / (damping * damping); + const float dampingFac = -2.f / (damping * damping); #ifdef __SSE2__ vfloat Iv, Ov, Uv, zerov, onev, fourv, fivev, dampingFacv, Tv, Wv, Lv; @@ -163,7 +163,7 @@ namespace rtengine void ImProcFunctions::deconvsharpening (float** luminance, float** tmp, const float * const * blend, int W, int H, const procparams::SharpeningParams &sharpenParam, double Scale) { - if (sharpenParam.deconvamount == 0 && sharpenParam.blurradius < 0.25f) { + if (sharpenParam.deconvamount == 0 && sharpenParam.blurradius < 0.25) { return; } BENCHFUN @@ -180,7 +180,7 @@ BENCHFUN JaggedArray* blurbuffer = nullptr; - if (sharpenParam.blurradius >= 0.25f) { + if (sharpenParam.blurradius >= 0.25) { blurbuffer = new JaggedArray(W, H); JaggedArray &blur = *blurbuffer; #ifdef _OPENMP @@ -229,7 +229,7 @@ BENCHFUN } } - if (sharpenParam.blurradius >= 0.25f) { + if (sharpenParam.blurradius >= 0.25) { JaggedArray &blur = *blurbuffer; #ifdef _OPENMP #pragma omp for @@ -255,7 +255,7 @@ void ImProcFunctions::sharpening (LabImage* lab, const procparams::SharpeningPar // calculate contrast based blend factors to reduce sharpening in regions with low contrast JaggedArray blend(W, H); - float contrast = sharpenParam.contrast / 100.f; + float contrast = sharpenParam.contrast / 100.0; buildBlendMask(lab->L, blend, W, H, contrast); if(showMask) { @@ -292,7 +292,7 @@ BENCHFUN JaggedArray blur(W, H); - if (sharpenParam.blurradius >= 0.25f) { + if (sharpenParam.blurradius >= 0.25) { #ifdef _OPENMP #pragma omp parallel #endif @@ -372,7 +372,7 @@ BENCHFUN delete [] b3; } - if (sharpenParam.blurradius >= 0.25f) { + if (sharpenParam.blurradius >= 0.25) { #ifdef _OPENMP #pragma omp parallel for #endif @@ -405,10 +405,10 @@ BENCHFUN // k=2 matrix 5x5 k=1 matrix 3x3 const int width = W, height = H; const int unif = params->sharpenMicro.uniformity; - const float amount = (k == 1 ? 2.7f : 1.f) * params->sharpenMicro.amount / 1500.0f; //amount 2000.0 quasi no artifacts ==> 1500 = maximum, after artifacts, 25/9 if 3x3 + const float amount = (k == 1 ? 2.7 : 1.) * params->sharpenMicro.amount / 1500.0; //amount 2000.0 quasi no artifacts ==> 1500 = maximum, after artifacts, 25/9 if 3x3 if (settings->verbose) { - printf ("Micro-contrast amount %f\n", amount); + printf ("Micro-contrast amount %f\n", static_cast(amount)); printf ("Micro-contrast uniformity %i\n", unif); } @@ -439,7 +439,7 @@ BENCHFUN // calculate contrast based blend factors to reduce sharpening in regions with low contrast JaggedArray blend(W, H); - float contrast = params->sharpenMicro.contrast / 100.f; + float contrast = params->sharpenMicro.contrast / 100.0; buildBlendMask(luminance, blend, W, H, contrast); #ifdef _OPENMP @@ -648,7 +648,7 @@ void ImProcFunctions::sharpeningcam (CieImage* ncie, float** b2, bool showMask) // calculate contrast based blend factors to reduce sharpening in regions with low contrast JaggedArray blend(W, H); - float contrast = params->sharpening.contrast / 100.f; + float contrast = params->sharpening.contrast / 100.0; buildBlendMask(ncie->sh_p, blend, W, H, contrast); if(showMask) { #ifdef _OPENMP diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 9e7c61dcf..b0dc55b2f 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -689,11 +689,11 @@ static void calcGradientParams (int oW, int oH, const GradientParams& gradient, gp.ta = tan (gradient_angle); gp.xc = w * gradient_center_x; gp.yc = h * gradient_center_y; - gp.ys = sqrt ((float)h * h + (float)w * w) * (gradient_span / cos (gradient_angle)); - gp.ys_inv = 1.0 / gp.ys; - gp.top_edge_0 = gp.yc - gp.ys / 2.0; + gp.ys = rtengine::norm2(static_cast(h), static_cast(w)) * (gradient_span / cos(gradient_angle)); + gp.ys_inv = 1.f / gp.ys; + gp.top_edge_0 = gp.yc - gp.ys / 2.f; - if (gp.ys < 1.0 / h) { + if (h * gp.ys < 1.f) { gp.ys_inv = 0; gp.ys = 0; } @@ -723,7 +723,7 @@ static float calcGradientFactor (const struct grad_params& gp, int x, int y) val = 1.f - pow3 (xcosf (val)); } - return gp.scale + val * (1.0 - gp.scale); + return gp.scale + val * (1.f - gp.scale); } } else { int gy = gp.transpose ? x : y; @@ -747,7 +747,7 @@ static float calcGradientFactor (const struct grad_params& gp, int x, int y) val = 1.f - pow3 (xcosf (val)); } - return gp.scale + val * (1.0 - gp.scale); + return gp.scale + val * (1.f - gp.scale); } } } @@ -766,7 +766,7 @@ static void calcPCVignetteParams (int fW, int fH, int oW, int oH, const PCVignet { // ellipse formula: (x/a)^2 + (y/b)^2 = 1 - double roundness = pcvignette.roundness / 100.0; + float roundness = pcvignette.roundness / 100.f; pcv.feather = pcvignette.feather / 100.0; if (crop.enabled) { @@ -783,42 +783,40 @@ static void calcPCVignetteParams (int fW, int fH, int oW, int oH, const PCVignet pcv.h = oH; } - pcv.fadeout_mul = 1.0 / (0.05 * sqrtf (oW * oW + oH * oH)); + pcv.fadeout_mul = 20.0 / rtengine::norm2(static_cast(oW), static_cast(oW)); float short_side = (pcv.w < pcv.h) ? pcv.w : pcv.h; float long_side = (pcv.w > pcv.h) ? pcv.w : pcv.h; pcv.sep = 2; pcv.sepmix = 0; - pcv.oe_a = sqrt (2.0) * long_side * 0.5; + pcv.oe_a = std::sqrt(2.f) * long_side * 0.5f; pcv.oe_b = pcv.oe_a * short_side / long_side; - pcv.ie_mul = (1.0 / sqrt (2.0)) * (1.0 - pcv.feather); + pcv.ie_mul = (1.f - pcv.feather) / std::sqrt(2.f); pcv.is_super_ellipse_mode = false; pcv.is_portrait = (pcv.w < pcv.h); - if (roundness < 0.5) { + if (roundness < 0.5f) { // make super-ellipse of higher and higher degree pcv.is_super_ellipse_mode = true; - float sepf = 2 + 4 * powf (1.0 - 2 * roundness, 1.3); // gamma 1.3 used to balance the effect in the 0.0...0.5 roundness range + float sepf = 2 + 4 * std::pow(1.f - 2 * roundness, 1.3f); // gamma 1.3 used to balance the effect in the 0.0...0.5 roundness range pcv.sep = ((int)sepf) & ~0x1; - pcv.sepmix = (sepf - pcv.sep) * 0.5; // 0.0 to 1.0 - pcv.oe1_a = powf (2.0, 1.0 / pcv.sep) * long_side * 0.5; + pcv.sepmix = (sepf - pcv.sep) * 0.5f; // 0.0 to 1.0 + pcv.oe1_a = std::pow(2.f, 1.f / pcv.sep) * long_side * 0.5f; pcv.oe1_b = pcv.oe1_a * short_side / long_side; - pcv.ie1_mul = (1.0 / powf (2.0, 1.0 / pcv.sep)) * (1.0 - pcv.feather); - pcv.oe2_a = powf (2.0, 1.0 / (pcv.sep + 2)) * long_side * 0.5; + pcv.ie1_mul = (1.f - pcv.feather) / std::pow(2.f, 1.f / pcv.sep); + pcv.oe2_a = std::pow(2.f, 1.f / (pcv.sep + 2)) * long_side * 0.5f; pcv.oe2_b = pcv.oe2_a * short_side / long_side; - pcv.ie2_mul = (1.0 / powf (2.0, 1.0 / (pcv.sep + 2))) * (1.0 - pcv.feather); - } - - if (roundness > 0.5) { + pcv.ie2_mul = (1.f - pcv.feather) / std::pow(2.f, 1.f / (pcv.sep + 2)); + } else if (roundness > 0.5f) { // scale from fitted ellipse towards circle - float rad = sqrtf (pcv.w * pcv.w + pcv.h * pcv.h) / 2.0; + float rad = rtengine::norm2(static_cast(pcv.w), static_cast(pcv.h)) / 2.f; float diff_a = rad - pcv.oe_a; float diff_b = rad - pcv.oe_b; - pcv.oe_a = pcv.oe_a + diff_a * 2 * (roundness - 0.5); - pcv.oe_b = pcv.oe_b + diff_b * 2 * (roundness - 0.5); + pcv.oe_a = pcv.oe_a + diff_a * 2 * (roundness - 0.5f); + pcv.oe_b = pcv.oe_b + diff_b * 2 * (roundness - 0.5f); } - pcv.scale = powf (2, -pcvignette.strength); + pcv.scale = std::pow(2, -pcvignette.strength); if (pcvignette.strength >= 6.0) { pcv.scale = 0.0; @@ -954,23 +952,23 @@ void ImProcFunctions::transformLuminanceOnly (Imagefloat* original, Imagefloat* double r = sqrt (vig_x_d * vig_x_d + vig_y_d * vig_y_d); if (darkening) { - factor /= std::max (v + mul * tanh (b * (maxRadius - r) / maxRadius), 0.001); + factor /= std::max (v + mul * tanh(b * (maxRadius - r) / maxRadius), 0.001); } else { - factor = v + mul * tanh (b * (maxRadius - r) / maxRadius); + factor = v + mul * tanh(b * (maxRadius - r) / maxRadius); } } if (applyGradient) { - factor *= calcGradientFactor (gp, cx + x, cy + y); + factor *= static_cast(calcGradientFactor(gp, cx + x, cy + y)); } if (applyPCVignetting) { - factor *= calcPCVignetteFactor (pcv, cx + x, cy + y); + factor *= static_cast(calcPCVignetteFactor(pcv, cx + x, cy + y)); } - transformed->r (y, x) = original->r (y, x) * factor; - transformed->g (y, x) = original->g (y, x) * factor; - transformed->b (y, x) = original->b (y, x) * factor; + transformed->r(y, x) = static_cast(original->r(y, x)) * factor; + transformed->g(y, x) = static_cast(original->g(y, x)) * factor; + transformed->b(y, x) = static_cast(original->b(y, x)) * factor; } } } @@ -1147,11 +1145,11 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I } if (enableGradient) { - vignmul *= calcGradientFactor(gp, cx + x, cy + y); + vignmul *= static_cast(calcGradientFactor(gp, cx + x, cy + y)); } if (enablePCVignetting) { - vignmul *= calcPCVignetteFactor(pcv, cx + x, cy + y); + vignmul *= static_cast(calcPCVignetteFactor(pcv, cx + x, cy + y)); } if (yc > 0 && yc < original->getHeight() - 2 && xc > 0 && xc < original->getWidth() - 2) {