lensfun: improved logic for handling fixed-lens cameras

Fixes #4161
This commit is contained in:
Alberto Griggio 2017-10-31 09:02:37 +01:00
parent a2a70bffdf
commit dd6e411c13
2 changed files with 14 additions and 6 deletions

View File

@ -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);

View File

@ -69,6 +69,7 @@ public:
Glib::ustring getMake() const;
Glib::ustring getModel() const;
float getCropFactor() const;
bool isFixedLens() const;
Glib::ustring getDisplayString() const;