From 03dc855fc73898b5957fdf1d39c26a612d6938f5 Mon Sep 17 00:00:00 2001 From: rom9 <4711834+rom9@users.noreply.github.com> Date: Tue, 18 Jun 2019 21:08:18 +0200 Subject: [PATCH] Merged cleanup patch proposed by heckflosse, moves exponents negation to a single place. Now it's much easier to read. --- rtengine/filmnegativeproc.cc | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/rtengine/filmnegativeproc.cc b/rtengine/filmnegativeproc.cc index bd68314e3..f5a231c05 100644 --- a/rtengine/filmnegativeproc.cc +++ b/rtengine/filmnegativeproc.cc @@ -172,10 +172,12 @@ void rtengine::RawImageSource::filmNegativeProcess(const procparams::FilmNegativ return; } + // Exponents are expressed as positive in the parameters, so negate them in order + // to get the reciprocals. const std::array exps = { - static_cast(params.redExp), - static_cast(params.greenExp), - static_cast(params.blueExp) + static_cast(-params.redExp), + static_cast(-params.greenExp), + static_cast(-params.blueExp) }; MyTime t1, t2, t3,t4, t5; @@ -244,8 +246,8 @@ void rtengine::RawImageSource::filmNegativeProcess(const procparams::FilmNegativ // Find median values for each channel if (!cvs[c].empty()) { findMinMaxPercentile(cvs[c].data(), cvs[c].size(), 0.5f, medians[c], 0.5f, medians[c], true); - medians[c] = pow_F(rtengine::max(medians[c], 1.f), -exps[c]); - // Determine the channel multipler so that N times the median becomes 65k. This clips away + medians[c] = pow_F(rtengine::max(medians[c], 1.f), exps[c]); + // Determine the channel multiplier so that N times the median becomes 65k. This clips away // the values in the dark border surrounding the negative (due to the film holder, for example), // the reciprocal of which have blown up to stellar values. mults[c] = MAX_OUT_VALUE / (medians[c] * 24.f); @@ -274,10 +276,9 @@ void rtengine::RawImageSource::filmNegativeProcess(const procparams::FilmNegativ #endif for (int row = 0; row < H; ++row) { int col = 0; - // Exponents are expressed as positive in the parameters, so negate them in order - // to get the reciprocals. Avoid trouble with zeroes, minimum pixel value is 1. - const float exps0 = -exps[FC(row, col)]; - const float exps1 = -exps[FC(row, col + 1)]; + // Avoid trouble with zeroes, minimum pixel value is 1. + const float exps0 = exps[FC(row, col)]; + const float exps1 = exps[FC(row, col + 1)]; const float mult0 = mults[FC(row, col)]; const float mult1 = mults[FC(row, col + 1)]; #ifdef __SSE2__ @@ -306,15 +307,14 @@ void rtengine::RawImageSource::filmNegativeProcess(const procparams::FilmNegativ #endif for (int row = 0; row < H; row ++) { int col = 0; - // Exponents are expressed as positive in the parameters, so negate them in order - // to get the reciprocals. Avoid trouble with zeroes, minimum pixel value is 1. + // Avoid trouble with zeroes, minimum pixel value is 1. const std::array expsc = { - -exps[ri->XTRANSFC(row, 0)], - -exps[ri->XTRANSFC(row, 1)], - -exps[ri->XTRANSFC(row, 2)], - -exps[ri->XTRANSFC(row, 3)], - -exps[ri->XTRANSFC(row, 4)], - -exps[ri->XTRANSFC(row, 5)] + exps[ri->XTRANSFC(row, 0)], + exps[ri->XTRANSFC(row, 1)], + exps[ri->XTRANSFC(row, 2)], + exps[ri->XTRANSFC(row, 3)], + exps[ri->XTRANSFC(row, 4)], + exps[ri->XTRANSFC(row, 5)] }; const std::array multsc = { mults[ri->XTRANSFC(row, 0)],