diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 08ee9a4a0..468507385 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -518,7 +518,7 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector &src, double Dx = x_d * cost - y_d * sint; double Dy = x_d * sint + y_d * cost; - if (pLCPMap && params->lensProf.useDist) { + if (pLCPMap && params->lensProf.useDist && pLCPMap->hasDistortionCorrection()) { pLCPMap->correctDistortion(Dx, Dy, w2, h2); } @@ -1077,8 +1077,8 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I // set up stuff, depending on the mode we are enum PerspType { NONE, SIMPLE, CAMERA_BASED }; - const bool enableLCPDist = pLCPMap && params->lensProf.useDist; - const bool enableLCPCA = pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable(); + const bool enableLCPDist = pLCPMap && params->lensProf.useDist && pLCPMap->hasDistortionCorrection(); + const bool enableLCPCA = pLCPMap && params->lensProf.useCA && pLCPMap->hasCACorrection(); const bool enableCA = highQuality && needsCA(); const bool doCACorrection = enableCA || enableLCPCA; const bool enableGradient = needsGradient(); diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index ba96147dc..0947cf709 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -985,11 +985,23 @@ rtengine::LCPMapper::LCPMapper( isFisheye = pProf->isFisheye; } -bool rtengine::LCPMapper::isCACorrectionAvailable() const +bool rtengine::LCPMapper::hasDistortionCorrection() const +{ + // assume lcp always provides distortion correction + return true; +} + +bool rtengine::LCPMapper::hasCACorrection() const { return enableCA; } +bool rtengine::LCPMapper::hasVignettingCorrection() const +{ + // assume lcp always provides vignetting correction + return true; +} + void rtengine::LCPMapper::correctDistortionAndCA(double &x, double &y, int cx, int cy, int channel) const { correctDistortion(x, y, cx, cy); diff --git a/rtengine/lcp.h b/rtengine/lcp.h index 97cdd0890..114131b4a 100644 --- a/rtengine/lcp.h +++ b/rtengine/lcp.h @@ -167,9 +167,12 @@ class LensCorrection { public: virtual ~LensCorrection() {} + virtual bool hasDistortionCorrection() const = 0; + virtual bool hasCACorrection() const = 0; + virtual bool hasVignettingCorrection() const = 0; + virtual void correctDistortionAndCA(double &x, double &y, int cx, int cy, int channel) const = 0; virtual void correctDistortion(double &x, double &y, int cx, int cy) const = 0; - virtual bool isCACorrectionAvailable() const = 0; virtual void correctCA(double &x, double &y, int cx, int cy, int channel) const = 0; virtual void processVignette(int width, int height, float** rawData) const = 0; virtual void processVignette3Channels(int width, int height, float** rawData) const = 0; @@ -196,9 +199,12 @@ public: ); + bool hasDistortionCorrection() const override; + bool hasCACorrection() const override; + bool hasVignettingCorrection() const override; + void correctDistortionAndCA(double &x, double &y, int cx, int cy, int channel) const override; void correctDistortion(double &x, double &y, int cx, int cy) const override; - bool isCACorrectionAvailable() const override; void correctCA(double& x, double& y, int cx, int cy, int channel) const override; void processVignette(int width, int height, float** rawData) const override; void processVignette3Channels(int width, int height, float** rawData) const override; diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index 505346ad0..f4714b6f7 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -102,6 +102,21 @@ LFModifier::operator bool() const } +bool LFModifier::hasDistortionCorrection() const +{ + return (flags_ & LF_MODIFY_DISTORTION); +} + +bool LFModifier::hasCACorrection() const +{ + return (flags_ & LF_MODIFY_TCA); +} + +bool LFModifier::hasVignettingCorrection() const +{ + return (flags_ & LF_MODIFY_VIGNETTING); +} + void LFModifier::correctDistortion(double &x, double &y, int cx, int cy) const { if (!data_) { @@ -125,11 +140,6 @@ void LFModifier::correctDistortion(double &x, double &y, int cx, int cy) const } } -bool LFModifier::isCACorrectionAvailable() const -{ - return (flags_ & LF_MODIFY_TCA); -} - void LFModifier::correctCA(double &x, double &y, int cx, int cy, int channel) const { assert(channel >= 0 && channel <= 2); diff --git a/rtengine/rtlensfun.h b/rtengine/rtlensfun.h index 39ca67ec2..78c9c9ff6 100644 --- a/rtengine/rtlensfun.h +++ b/rtengine/rtlensfun.h @@ -53,9 +53,12 @@ public: explicit operator bool() const; + bool hasDistortionCorrection() const override; + bool hasCACorrection() const override; + bool hasVignettingCorrection() const override; + void correctDistortionAndCA(double &x, double &y, int cx, int cy, int channel) const override; void correctDistortion(double &x, double &y, int cx, int cy) const override; - bool isCACorrectionAvailable() const override; void correctCA(double &x, double &y, int cx, int cy, int channel) const override; void processVignette(int width, int height, float** rawData) const override; void processVignette3Channels(int width, int height, float** rawData) const override;