Merge pull request #5548 from Beep6581/lensfun-improvement
Make `LFDatabase::findModifier()` non-static
This commit is contained in:
commit
dba0d72ecd
@ -415,7 +415,7 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed,
|
|||||||
std::unique_ptr<const LensCorrection> pLCPMap;
|
std::unique_ptr<const LensCorrection> pLCPMap;
|
||||||
|
|
||||||
if (needsLensfun()) {
|
if (needsLensfun()) {
|
||||||
pLCPMap = LFDatabase::findModifier(params->lensProf, metadata, oW, oH, params->coarse, rawRotationDeg);
|
pLCPMap = LFDatabase::getInstance()->findModifier(params->lensProf, metadata, oW, oH, params->coarse, rawRotationDeg);
|
||||||
} else if (needsLCP()) { // don't check focal length to allow distortion correction for lenses without chip
|
} else if (needsLCP()) { // don't check focal length to allow distortion correction for lenses without chip
|
||||||
const std::shared_ptr<LCPProfile> pLCPProf = LCPStore::getInstance()->getProfile (params->lensProf.lcpFile);
|
const std::shared_ptr<LCPProfile> pLCPProf = LCPStore::getInstance()->getProfile (params->lensProf.lcpFile);
|
||||||
|
|
||||||
|
@ -1385,7 +1385,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
|
|||||||
if (!hasFlatField && lensProf.useVign && lensProf.lcMode != LensProfParams::LcMode::NONE) {
|
if (!hasFlatField && lensProf.useVign && lensProf.lcMode != LensProfParams::LcMode::NONE) {
|
||||||
std::unique_ptr<LensCorrection> pmap;
|
std::unique_ptr<LensCorrection> pmap;
|
||||||
if (lensProf.useLensfun()) {
|
if (lensProf.useLensfun()) {
|
||||||
pmap = LFDatabase::findModifier(lensProf, idata, W, H, coarse, -1);
|
pmap = LFDatabase::getInstance()->findModifier(lensProf, idata, W, H, coarse, -1);
|
||||||
} else {
|
} else {
|
||||||
const std::shared_ptr<LCPProfile> pLCPProf = LCPStore::getInstance()->getProfile(lensProf.lcpFile);
|
const std::shared_ptr<LCPProfile> pLCPProf = LCPStore::getInstance()->getProfile(lensProf.lcpFile);
|
||||||
|
|
||||||
|
@ -500,14 +500,20 @@ std::unique_ptr<LFModifier> LFDatabase::getModifier(const LFCamera &camera, cons
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::string> LFDatabase::notFound;
|
std::unique_ptr<LFModifier> LFDatabase::findModifier(
|
||||||
|
const procparams::LensProfParams &lensProf,
|
||||||
std::unique_ptr<LFModifier> LFDatabase::findModifier(const procparams::LensProfParams &lensProf, const FramesMetaData *idata, int width, int height, const procparams::CoarseTransformParams &coarse, int rawRotationDeg)
|
const FramesMetaData *idata,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
const procparams::CoarseTransformParams &coarse,
|
||||||
|
int rawRotationDeg
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
|
const float focallen = idata->getFocalLen();
|
||||||
|
|
||||||
Glib::ustring make, model, lens;
|
Glib::ustring make, model, lens;
|
||||||
float focallen = idata->getFocalLen();
|
|
||||||
if (lensProf.lfAutoMatch()) {
|
if (lensProf.lfAutoMatch()) {
|
||||||
if (focallen <= 0) {
|
if (focallen <= 0.f) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
make = idata->getMake();
|
make = idata->getMake();
|
||||||
@ -518,6 +524,7 @@ std::unique_ptr<LFModifier> LFDatabase::findModifier(const procparams::LensProfP
|
|||||||
model = lensProf.lfCameraModel;
|
model = lensProf.lfCameraModel;
|
||||||
lens = lensProf.lfLens;
|
lens = lensProf.lfLens;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (make.empty() || model.empty() || lens.empty()) {
|
if (make.empty() || model.empty() || lens.empty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -527,15 +534,15 @@ std::unique_ptr<LFModifier> LFDatabase::findModifier(const procparams::LensProfP
|
|||||||
// This combination was not found => do not search again
|
// This combination was not found => do not search again
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
const LFDatabase *db = getInstance();
|
|
||||||
LFCamera c = db->findCamera(make, model);
|
const LFCamera c = findCamera(make, model);
|
||||||
LFLens l = db->findLens(lensProf.lfAutoMatch() ? c : LFCamera(), lens);
|
const LFLens l = findLens(
|
||||||
if (focallen <= 0 && l.data_ && l.data_->MinFocal == l.data_->MaxFocal) {
|
lensProf.lfAutoMatch()
|
||||||
focallen = l.data_->MinFocal;
|
? c
|
||||||
}
|
: LFCamera(),
|
||||||
if (focallen <= 0) {
|
lens
|
||||||
return nullptr;
|
);
|
||||||
}
|
|
||||||
bool swap_xy = false;
|
bool swap_xy = false;
|
||||||
if (rawRotationDeg >= 0) {
|
if (rawRotationDeg >= 0) {
|
||||||
int rot = (coarse.rotate + rawRotationDeg) % 360;
|
int rot = (coarse.rotate + rawRotationDeg) % 360;
|
||||||
@ -545,18 +552,28 @@ std::unique_ptr<LFModifier> LFDatabase::findModifier(const procparams::LensProfP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<LFModifier> ret = db->getModifier(c, l, idata->getFocalLen(), idata->getFNumber(), idata->getFocusDist(), width, height, swap_xy);
|
std::unique_ptr<LFModifier> ret = getModifier(
|
||||||
|
c,
|
||||||
|
l,
|
||||||
|
idata->getFocalLen(),
|
||||||
|
idata->getFNumber(),
|
||||||
|
idata->getFocusDist(),
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
swap_xy
|
||||||
|
);
|
||||||
|
|
||||||
if (settings->verbose) {
|
if (settings->verbose) {
|
||||||
std::cout << "LENSFUN:\n"
|
std::cout << "LENSFUN:\n"
|
||||||
<< " camera: " << c.getDisplayString() << "\n"
|
<< " camera: " << c.getDisplayString() << "\n"
|
||||||
<< " lens: " << l.getDisplayString() << "\n"
|
<< " lens: " << l.getDisplayString() << "\n"
|
||||||
<< " correction: "
|
<< " correction: "
|
||||||
<< (ret ? ret->getDisplayString() : "NONE") << std::endl;
|
<< (ret ? ret->getDisplayString() : "NONE")
|
||||||
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
notFound.emplace(key);
|
notFound.insert(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -124,7 +124,13 @@ public:
|
|||||||
LFCamera findCamera(const Glib::ustring &make, const Glib::ustring &model) const;
|
LFCamera findCamera(const Glib::ustring &make, const Glib::ustring &model) const;
|
||||||
LFLens findLens(const LFCamera &camera, const Glib::ustring &name) const;
|
LFLens findLens(const LFCamera &camera, const Glib::ustring &name) const;
|
||||||
|
|
||||||
static std::unique_ptr<LFModifier> findModifier(const procparams::LensProfParams &lensProf, const FramesMetaData *idata, int width, int height, const procparams::CoarseTransformParams &coarse, int rawRotationDeg);
|
std::unique_ptr<LFModifier> findModifier(
|
||||||
|
const procparams::LensProfParams &lensProf,
|
||||||
|
const FramesMetaData *idata,
|
||||||
|
int width, int height,
|
||||||
|
const procparams::CoarseTransformParams &coarse,
|
||||||
|
int rawRotationDeg
|
||||||
|
) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<LFModifier> getModifier(const LFCamera &camera, const LFLens &lens,
|
std::unique_ptr<LFModifier> getModifier(const LFCamera &camera, const LFLens &lens,
|
||||||
@ -136,7 +142,7 @@ private:
|
|||||||
mutable MyMutex lfDBMutex;
|
mutable MyMutex lfDBMutex;
|
||||||
static LFDatabase instance_;
|
static LFDatabase instance_;
|
||||||
lfDatabase *data_;
|
lfDatabase *data_;
|
||||||
static std::set<std::string> notFound;
|
mutable std::set<std::string> notFound;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace rtengine
|
} // namespace rtengine
|
||||||
|
@ -761,7 +761,7 @@ bool LensProfilePanel::checkLensfunCanCorrect(bool automatch)
|
|||||||
|
|
||||||
rtengine::procparams::ProcParams lpp;
|
rtengine::procparams::ProcParams lpp;
|
||||||
write(&lpp);
|
write(&lpp);
|
||||||
const std::unique_ptr<LFModifier> mod(LFDatabase::findModifier(lpp.lensProf, metadata, 100, 100, lpp.coarse, -1));
|
const std::unique_ptr<LFModifier> mod(LFDatabase::getInstance()->findModifier(lpp.lensProf, metadata, 100, 100, lpp.coarse, -1));
|
||||||
return static_cast<bool>(mod);
|
return static_cast<bool>(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user