From b8dcd93a6ad42540e530489bb02a905a346f5c5b Mon Sep 17 00:00:00 2001 From: Ingo Weyrich Date: Fri, 29 Nov 2019 13:09:37 +0100 Subject: [PATCH 1/2] Reduce searches for lensfun data if there is no entry for the combo of camera and lens --- rtengine/rtlensfun.cc | 11 ++++++++++- rtengine/rtlensfun.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index 665fbd199..6ad475beb 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -24,7 +24,6 @@ #include "procparams.h" #include "rtlensfun.h" #include "settings.h" - namespace rtengine { @@ -500,6 +499,7 @@ std::unique_ptr LFDatabase::getModifier(const LFCamera &camera, cons return ret; } +Glib::ustring LFDatabase::lastKey; std::unique_ptr LFDatabase::findModifier(const procparams::LensProfParams &lensProf, const FramesMetaData *idata, int width, int height, const procparams::CoarseTransformParams &coarse, int rawRotationDeg) { @@ -521,6 +521,11 @@ std::unique_ptr LFDatabase::findModifier(const procparams::LensProfP return nullptr; } + Glib::ustring temp = make + model + lens; + if (lastKey == temp) { + // This combination was not found in last search => 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); @@ -549,6 +554,10 @@ std::unique_ptr LFDatabase::findModifier(const procparams::LensProfP << (ret ? ret->getDisplayString() : "NONE") << std::endl; } + if (!ret) { + lastKey = temp; + } + return ret; } diff --git a/rtengine/rtlensfun.h b/rtengine/rtlensfun.h index 7dcd96007..302045695 100644 --- a/rtengine/rtlensfun.h +++ b/rtengine/rtlensfun.h @@ -135,6 +135,7 @@ private: mutable MyMutex lfDBMutex; static LFDatabase instance_; lfDatabase *data_; + static Glib::ustring lastKey; }; } // namespace rtengine From 92e6768bee473fcf0f22f3564cb1267d1ab151c4 Mon Sep 17 00:00:00 2001 From: Ingo Weyrich Date: Fri, 29 Nov 2019 15:19:34 +0100 Subject: [PATCH 2/2] Improve caching of lensfun mismatches --- rtengine/rtlensfun.cc | 11 ++++++----- rtengine/rtlensfun.h | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index 6ad475beb..7b959ce8b 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -24,6 +24,7 @@ #include "procparams.h" #include "rtlensfun.h" #include "settings.h" + namespace rtengine { @@ -499,7 +500,7 @@ std::unique_ptr LFDatabase::getModifier(const LFCamera &camera, cons return ret; } -Glib::ustring LFDatabase::lastKey; +std::set LFDatabase::notFound; std::unique_ptr LFDatabase::findModifier(const procparams::LensProfParams &lensProf, const FramesMetaData *idata, int width, int height, const procparams::CoarseTransformParams &coarse, int rawRotationDeg) { @@ -521,9 +522,9 @@ std::unique_ptr LFDatabase::findModifier(const procparams::LensProfP return nullptr; } - Glib::ustring temp = make + model + lens; - if (lastKey == temp) { - // This combination was not found in last search => do not search again + const std::string key = (make + model + lens).collate_key(); + if (notFound.find(key) != notFound.end()) { + // This combination was not found => do not search again return nullptr; } const LFDatabase *db = getInstance(); @@ -555,7 +556,7 @@ std::unique_ptr LFDatabase::findModifier(const procparams::LensProfP } if (!ret) { - lastKey = temp; + notFound.emplace(key); } return ret; diff --git a/rtengine/rtlensfun.h b/rtengine/rtlensfun.h index 302045695..573b93fca 100644 --- a/rtengine/rtlensfun.h +++ b/rtengine/rtlensfun.h @@ -21,6 +21,7 @@ #pragma once #include +#include #include #include @@ -135,7 +136,7 @@ private: mutable MyMutex lfDBMutex; static LFDatabase instance_; lfDatabase *data_; - static Glib::ustring lastKey; + static std::set notFound; }; } // namespace rtengine