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;
|
||||
|
||||
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
|
||||
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) {
|
||||
std::unique_ptr<LensCorrection> pmap;
|
||||
if (lensProf.useLensfun()) {
|
||||
pmap = LFDatabase::findModifier(lensProf, idata, W, H, coarse, -1);
|
||||
pmap = LFDatabase::getInstance()->findModifier(lensProf, idata, W, H, coarse, -1);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
std::set<std::string> LFDatabase::notFound;
|
||||
|
||||
std::unique_ptr<LFModifier> LFDatabase::findModifier(const procparams::LensProfParams &lensProf, const FramesMetaData *idata, int width, int height, const procparams::CoarseTransformParams &coarse, int rawRotationDeg)
|
||||
std::unique_ptr<LFModifier> LFDatabase::findModifier(
|
||||
const procparams::LensProfParams &lensProf,
|
||||
const FramesMetaData *idata,
|
||||
int width,
|
||||
int height,
|
||||
const procparams::CoarseTransformParams &coarse,
|
||||
int rawRotationDeg
|
||||
) const
|
||||
{
|
||||
const float focallen = idata->getFocalLen();
|
||||
|
||||
Glib::ustring make, model, lens;
|
||||
float focallen = idata->getFocalLen();
|
||||
if (lensProf.lfAutoMatch()) {
|
||||
if (focallen <= 0) {
|
||||
if (focallen <= 0.f) {
|
||||
return nullptr;
|
||||
}
|
||||
make = idata->getMake();
|
||||
@ -518,6 +524,7 @@ std::unique_ptr<LFModifier> LFDatabase::findModifier(const procparams::LensProfP
|
||||
model = lensProf.lfCameraModel;
|
||||
lens = lensProf.lfLens;
|
||||
}
|
||||
|
||||
if (make.empty() || model.empty() || lens.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -527,15 +534,15 @@ std::unique_ptr<LFModifier> LFDatabase::findModifier(const procparams::LensProfP
|
||||
// This combination was not found => do not search again
|
||||
return nullptr;
|
||||
}
|
||||
const LFDatabase *db = getInstance();
|
||||
LFCamera c = db->findCamera(make, model);
|
||||
LFLens l = db->findLens(lensProf.lfAutoMatch() ? c : LFCamera(), lens);
|
||||
if (focallen <= 0 && l.data_ && l.data_->MinFocal == l.data_->MaxFocal) {
|
||||
focallen = l.data_->MinFocal;
|
||||
}
|
||||
if (focallen <= 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const LFCamera c = findCamera(make, model);
|
||||
const LFLens l = findLens(
|
||||
lensProf.lfAutoMatch()
|
||||
? c
|
||||
: LFCamera(),
|
||||
lens
|
||||
);
|
||||
|
||||
bool swap_xy = false;
|
||||
if (rawRotationDeg >= 0) {
|
||||
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) {
|
||||
std::cout << "LENSFUN:\n"
|
||||
<< " camera: " << c.getDisplayString() << "\n"
|
||||
<< " lens: " << l.getDisplayString() << "\n"
|
||||
<< " correction: "
|
||||
<< (ret ? ret->getDisplayString() : "NONE") << std::endl;
|
||||
<< (ret ? ret->getDisplayString() : "NONE")
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
notFound.emplace(key);
|
||||
notFound.insert(key);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -124,7 +124,13 @@ public:
|
||||
LFCamera findCamera(const Glib::ustring &make, const Glib::ustring &model) 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:
|
||||
std::unique_ptr<LFModifier> getModifier(const LFCamera &camera, const LFLens &lens,
|
||||
@ -136,7 +142,7 @@ private:
|
||||
mutable MyMutex lfDBMutex;
|
||||
static LFDatabase instance_;
|
||||
lfDatabase *data_;
|
||||
static std::set<std::string> notFound;
|
||||
mutable std::set<std::string> notFound;
|
||||
};
|
||||
|
||||
} // namespace rtengine
|
||||
|
@ -761,7 +761,7 @@ bool LensProfilePanel::checkLensfunCanCorrect(bool automatch)
|
||||
|
||||
rtengine::procparams::ProcParams 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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user