From dd6e411c13f1f947f770fd1cbe4686b5de77e70e Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Tue, 31 Oct 2017 09:02:37 +0100 Subject: [PATCH] lensfun: improved logic for handling fixed-lens cameras Fixes #4161 --- rtengine/rtlensfun.cc | 19 +++++++++++++------ rtengine/rtlensfun.h | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index ed19f44f0..c73458824 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -172,6 +172,15 @@ float LFCamera::getCropFactor() const } +bool LFCamera::isFixedLens() const +{ + // per lensfun's main developer Torsten Bronger: + // "Compact camera mounts can be identified by the fact that the mount + // starts with a lowercase letter" + return data_ && data_->Mount && std::islower(data_->Mount[0]); +} + + Glib::ustring LFCamera::getDisplayString() const { if (data_) { @@ -387,12 +396,7 @@ LFLens LFDatabase::findLens(const LFCamera &camera, const Glib::ustring &name) c { LFLens ret; if (data_) { - Glib::ustring lname = name; - bool stdlens = camera && (name.empty() || name.find("Unknown") == 0); - if (stdlens) { - lname = camera.getModel(); // "Standard" - } - auto found = data_->FindLenses(camera.data_, nullptr, lname.c_str()); + auto found = data_->FindLenses(camera.data_, nullptr, name.c_str()); for (size_t pos = 0; !found && pos < name.size(); ) { // try to split the maker from the model of the lens -- we have to // guess a bit here, since there are makers with a multi-word name @@ -411,6 +415,9 @@ LFLens LFDatabase::findLens(const LFCamera &camera, const Glib::ustring &name) c break; } } + if (!found && camera && camera.isFixedLens()) { + found = data_->FindLenses(camera.data_, nullptr, ""); + } if (found) { ret.data_ = found[0]; lf_free(found); diff --git a/rtengine/rtlensfun.h b/rtengine/rtlensfun.h index 207e4e86e..686b8b9c4 100644 --- a/rtengine/rtlensfun.h +++ b/rtengine/rtlensfun.h @@ -69,6 +69,7 @@ public: Glib::ustring getMake() const; Glib::ustring getModel() const; float getCropFactor() const; + bool isFixedLens() const; Glib::ustring getDisplayString() const;