Small (~ 4%) speedup for perceptual tone curve
This commit is contained in:
parent
4c3e7b8efa
commit
057861b882
@ -1822,7 +1822,7 @@ float PerceptualToneCurve::calculateToneCurveContrastValue() const
|
|||||||
return maxslope;
|
return maxslope;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurveState & state) const
|
void PerceptualToneCurve::Apply(float &r, float &g, float &b, const PerceptualToneCurveState &state) const
|
||||||
{
|
{
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
|
|
||||||
@ -2012,14 +2012,13 @@ void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurv
|
|||||||
// we use the RGB-HSV hue-stable "Adobe" curve as reference. For S-curve contrast it increases
|
// we use the RGB-HSV hue-stable "Adobe" curve as reference. For S-curve contrast it increases
|
||||||
// saturation greatly, but desaturates extreme highlights and thus provide a smooth transition to
|
// saturation greatly, but desaturates extreme highlights and thus provide a smooth transition to
|
||||||
// the white point. However the desaturation effect is quite strong so we make a weighting
|
// the white point. However the desaturation effect is quite strong so we make a weighting
|
||||||
float ah, as, av, h, s, v;
|
float as = Color::rgb2s(ar, ag, ab);
|
||||||
Color::rgb2hsv(ar, ag, ab, ah, as, av);
|
float s = Color::rgb2s(r, g, b);
|
||||||
Color::rgb2hsv(r, g, b, h, s, v);
|
|
||||||
|
|
||||||
float sat_scale = as <= 0.f ? 1.f : s / as; // saturation scale compared to Adobe curve
|
float sat_scale = as <= 0.f ? 1.f : s / as; // saturation scale compared to Adobe curve
|
||||||
float keep = 0.2f;
|
float keep = 0.2f;
|
||||||
const float lolim = 1.00f; // only mix in the Adobe curve if we have increased saturation compared to it
|
constexpr float lolim = 1.00f; // only mix in the Adobe curve if we have increased saturation compared to it
|
||||||
const float hilim = 1.20f;
|
constexpr float hilim = 1.20f;
|
||||||
|
|
||||||
if (sat_scale < lolim) {
|
if (sat_scale < lolim) {
|
||||||
// saturation is low enough, don't desaturate
|
// saturation is low enough, don't desaturate
|
||||||
@ -2041,9 +2040,9 @@ void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurv
|
|||||||
|
|
||||||
if (keep < 1.f) {
|
if (keep < 1.f) {
|
||||||
// mix in some of the Adobe curve result
|
// mix in some of the Adobe curve result
|
||||||
r = r * keep + (1.f - keep) * ar;
|
r = intp(keep, r, ar);
|
||||||
g = g * keep + (1.f - keep) * ag;
|
g = intp(keep, g, ag);
|
||||||
b = b * keep + (1.f - keep) * ab;
|
b = intp(keep, b, ab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,7 +868,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
static void init();
|
static void init();
|
||||||
void initApplyState(PerceptualToneCurveState & state, Glib::ustring workingSpace) const;
|
void initApplyState(PerceptualToneCurveState & state, Glib::ustring workingSpace) const;
|
||||||
void Apply(float& r, float& g, float& b, PerceptualToneCurveState & state) const;
|
void Apply(float& r, float& g, float& b, const PerceptualToneCurveState &state) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Standard tone curve
|
// Standard tone curve
|
||||||
|
Loading…
x
Reference in New Issue
Block a user