From f6c864d477192a16535b27de21a006024734ff78 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 31 Oct 2018 15:02:53 +0100 Subject: [PATCH 1/6] Get rid of aehistogram files in RT cache, fixes #4904 --- rtengine/rtthumbnail.cc | 69 +++++++++++++++++++++++++++++++++++++++-- rtengine/rtthumbnail.h | 8 +++++ rtgui/thumbnail.cc | 13 +++++--- 3 files changed, 82 insertions(+), 8 deletions(-) diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index afd8836a1..1210518d4 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -279,6 +279,11 @@ Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h, printf ("loadFromImage: Unsupported image type \"%s\"!\n", img->getType()); } + ProcParams paramsForAutoExp; // Dummy for constructor + ImProcFunctions ipf (¶msForAutoExp, false); + ipf.getAutoExp (tpp->aeHistogram, tpp->aeHistCompression, 0.02, tpp->aeExposureCompensation, tpp->aeLightness, tpp->aeContrast, tpp->aeBlack, tpp->aeHighlightCompression, tpp->aeHighlightCompressionThreshold); + tpp->aeValid = true; + if (n > 0) { ColorTemp cTemp; @@ -923,6 +928,11 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati } } } + ProcParams paramsForAutoExp; // Dummy for constructor + ImProcFunctions ipf (¶msForAutoExp, false); + ipf.getAutoExp (tpp->aeHistogram, tpp->aeHistCompression, 0.02, tpp->aeExposureCompensation, tpp->aeLightness, tpp->aeContrast, tpp->aeBlack, tpp->aeHighlightCompression, tpp->aeHighlightCompressionThreshold); + tpp->aeValid = true; + if (ri->get_colors() == 1) { pixSum[0] = pixSum[1] = pixSum[2] = 1.; n[0] = n[1] = n[2] = 1; @@ -993,6 +1003,13 @@ Thumbnail::Thumbnail () : wbEqual (-1.0), wbTempBias (0.0), aeHistCompression (3), + aeValid(false), + aeExposureCompensation(0.0), + aeLightness(0), + aeContrast(0), + aeBlack(0), + aeHighlightCompression(0), + aeHighlightCompressionThreshold(0), embProfileLength (0), embProfileData (nullptr), embProfile (nullptr), @@ -1224,8 +1241,17 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT int hlcompr = params.toneCurve.hlcompr; int hlcomprthresh = params.toneCurve.hlcomprthresh; - if (params.toneCurve.autoexp && aeHistogram) { - ipf.getAutoExp (aeHistogram, aeHistCompression, params.toneCurve.clip, expcomp, bright, contr, black, hlcompr, hlcomprthresh); + if (params.toneCurve.autoexp) { + if (aeValid) { + expcomp = aeExposureCompensation; + bright = aeLightness; + contr = aeContrast; + black = aeBlack; + hlcompr = aeHighlightCompression; + hlcomprthresh = aeHighlightCompressionThreshold; + } else if (aeHistogram) { + ipf.getAutoExp (aeHistogram, aeHistCompression, 0.02, expcomp, bright, contr, black, hlcompr, hlcomprthresh); + } } LUTf curve1 (65536); @@ -1992,6 +2018,38 @@ bool Thumbnail::readData (const Glib::ustring& fname) aeHistCompression = keyFile.get_integer ("LiveThumbData", "AEHistCompression"); } + aeValid = true; + if (keyFile.has_key ("LiveThumbData", "AEExposureCompensation")) { + aeExposureCompensation = keyFile.get_double ("LiveThumbData", "AEExposureCompensation"); + } else { + aeValid = false; + } + if (keyFile.has_key ("LiveThumbData", "AELightness")) { + aeLightness = keyFile.get_integer ("LiveThumbData", "AELightness"); + } else { + aeValid = false; + } + if (keyFile.has_key ("LiveThumbData", "AEContrast")) { + aeContrast = keyFile.get_integer ("LiveThumbData", "AEContrast"); + } else { + aeValid = false; + } + if (keyFile.has_key ("LiveThumbData", "AEBlack")) { + aeBlack = keyFile.get_integer ("LiveThumbData", "AEBlack"); + } else { + aeValid = false; + } + if (keyFile.has_key ("LiveThumbData", "AEHighlightCompression")) { + aeHighlightCompression = keyFile.get_integer ("LiveThumbData", "AEHighlightCompression"); + } else { + aeValid = false; + } + if (keyFile.has_key ("LiveThumbData", "AEHighlightCompressionThreshold")) { + aeHighlightCompressionThreshold = keyFile.get_integer ("LiveThumbData", "AEHighlightCompressionThreshold"); + } else { + aeValid = false; + } + if (keyFile.has_key ("LiveThumbData", "RedMultiplier")) { redMultiplier = keyFile.get_double ("LiveThumbData", "RedMultiplier"); } @@ -2065,7 +2123,12 @@ bool Thumbnail::writeData (const Glib::ustring& fname) keyFile.set_double ("LiveThumbData", "RedAWBMul", redAWBMul); keyFile.set_double ("LiveThumbData", "GreenAWBMul", greenAWBMul); keyFile.set_double ("LiveThumbData", "BlueAWBMul", blueAWBMul); - keyFile.set_integer ("LiveThumbData", "AEHistCompression", aeHistCompression); + keyFile.set_double ("LiveThumbData", "AEExposureCompensation", aeExposureCompensation); + keyFile.set_integer ("LiveThumbData", "AELightness", aeLightness); + keyFile.set_integer ("LiveThumbData", "AEContrast", aeContrast); + keyFile.set_integer ("LiveThumbData", "AEBlack", aeBlack); + keyFile.set_integer ("LiveThumbData", "AEHighlightCompression", aeHighlightCompression); + keyFile.set_integer ("LiveThumbData", "AEHighlightCompressionThreshold", aeHighlightCompressionThreshold); keyFile.set_double ("LiveThumbData", "RedMultiplier", redMultiplier); keyFile.set_double ("LiveThumbData", "GreenMultiplier", greenMultiplier); keyFile.set_double ("LiveThumbData", "BlueMultiplier", blueMultiplier); diff --git a/rtengine/rtthumbnail.h b/rtengine/rtthumbnail.h index 558d136ee..667d8e1c9 100644 --- a/rtengine/rtthumbnail.h +++ b/rtengine/rtthumbnail.h @@ -50,6 +50,13 @@ class Thumbnail double autoWBTemp, autoWBGreen, wbEqual, wbTempBias; // autoWBTemp and autoWBGreen are updated each time autoWB is requested and if wbEqual has been modified LUTu aeHistogram; int aeHistCompression; + bool aeValid; + double aeExposureCompensation; + int aeLightness; + int aeContrast; + int aeBlack; + int aeHighlightCompression; + int aeHighlightCompressionThreshold; int embProfileLength; unsigned char* embProfileData; cmsHPROFILE embProfile; @@ -100,6 +107,7 @@ public: bool readAEHistogram (const Glib::ustring& fname); bool writeAEHistogram (const Glib::ustring& fname); + bool isAeValid() { return aeValid; }; unsigned char* getImage8Data(); // accessor to the 8bit image if it is one, which should be the case for the "Inspector" mode. // Hombre: ... let's hope that proper template can make this cleaner diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index c2d23eab2..4921a2d56 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -854,8 +854,10 @@ void Thumbnail::_loadThumbnail(bool firstTrial) } if ( cfs.thumbImgType == CacheImageData::FULL_THUMBNAIL ) { - // load aehistogram - tpp->readAEHistogram (getCacheFileName ("aehistograms", "")); + if(!tpp->isAeValid()) { + // load aehistogram + tpp->readAEHistogram (getCacheFileName ("aehistograms", "")); + } // load embedded profile tpp->readEmbProfile (getCacheFileName ("embprofiles", ".icc")); @@ -907,9 +909,10 @@ void Thumbnail::_saveThumbnail () // save thumbnail image tpp->writeImage (getCacheFileName ("images", "")); - // save aehistogram - tpp->writeAEHistogram (getCacheFileName ("aehistograms", "")); - + if(!tpp->isAeValid()) { + // save aehistogram + tpp->writeAEHistogram (getCacheFileName ("aehistograms", "")); + } // save embedded profile tpp->writeEmbProfile (getCacheFileName ("embprofiles", ".icc")); From 310e7343918d9c34ab7fc2ffd3ef8a670b22dca7 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 31 Oct 2018 16:21:26 +0100 Subject: [PATCH 2/6] Don't create aehistograms folder in RT cache, #4904 --- rtgui/cachemanager.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rtgui/cachemanager.cc b/rtgui/cachemanager.cc index 5b18d5d33..c1f81a0d2 100644 --- a/rtgui/cachemanager.cc +++ b/rtgui/cachemanager.cc @@ -57,7 +57,9 @@ void CacheManager::init () auto error = g_mkdir_with_parents (baseDir.c_str(), cacheDirMode); for (const auto& cacheDir : cacheDirs) { - error |= g_mkdir_with_parents (Glib::build_filename (baseDir, cacheDir).c_str(), cacheDirMode); + if (strncmp(cacheDir, "aehistograms", 12)) { // don't create aehistograms folder. + error |= g_mkdir_with_parents (Glib::build_filename (baseDir, cacheDir).c_str(), cacheDirMode); + } } if (error != 0 && options.rtSettings.verbose) { From 473e4bc2369bfa9c7928b9afa1fb9c168b233e58 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 31 Oct 2018 17:22:03 +0100 Subject: [PATCH 3/6] clear cache data folder, #4904 --- rtgui/cachemanager.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/rtgui/cachemanager.cc b/rtgui/cachemanager.cc index c1f81a0d2..06f4ad237 100644 --- a/rtgui/cachemanager.cc +++ b/rtgui/cachemanager.cc @@ -240,6 +240,7 @@ void CacheManager::clearImages () const { MyMutex::MyLock lock (mutex); + deleteDir ("data"); deleteDir ("images"); deleteDir ("aehistograms"); deleteDir ("embprofiles"); From bfe2ce7fe1f43616b0dc0dca06c340d7349cac78 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 31 Oct 2018 20:52:16 +0100 Subject: [PATCH 4/6] Don't check for .jpg, .cust, .cust16 files in cache/images folder, #4904 --- rtgui/cachemanager.cc | 6 ------ rtgui/thumbnail.cc | 7 +------ 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/rtgui/cachemanager.cc b/rtgui/cachemanager.cc index 06f4ad237..919f76f6d 100644 --- a/rtgui/cachemanager.cc +++ b/rtgui/cachemanager.cc @@ -185,9 +185,6 @@ void CacheManager::renameEntry (const std::string& oldfilename, const std::strin auto error = g_rename (getCacheFileName ("profiles", oldfilename, paramFileExtension, oldmd5).c_str (), getCacheFileName ("profiles", newfilename, paramFileExtension, newmd5).c_str ()); error |= g_rename (getCacheFileName ("images", oldfilename, ".rtti", oldmd5).c_str (), getCacheFileName ("images", newfilename, ".rtti", newmd5).c_str ()); - error |= g_rename (getCacheFileName ("images", oldfilename, ".cust16", oldmd5).c_str (), getCacheFileName ("images", newfilename, ".cust16", newmd5).c_str ()); - error |= g_rename (getCacheFileName ("images", oldfilename, ".cust", oldmd5).c_str (), getCacheFileName ("images", newfilename, ".cust", newmd5).c_str ()); - error |= g_rename (getCacheFileName ("images", oldfilename, ".jpg", oldmd5).c_str (), getCacheFileName ("images", newfilename, ".jpg", newmd5).c_str ()); error |= g_rename (getCacheFileName ("aehistograms", oldfilename, "", oldmd5).c_str (), getCacheFileName ("aehistograms", newfilename, "", newmd5).c_str ()); error |= g_rename (getCacheFileName ("embprofiles", oldfilename, ".icc", oldmd5).c_str (), getCacheFileName ("embprofiles", newfilename, ".icc", newmd5).c_str ()); error |= g_rename (getCacheFileName ("data", oldfilename, ".txt", oldmd5).c_str (), getCacheFileName ("data", newfilename, ".txt", newmd5).c_str ()); @@ -278,9 +275,6 @@ void CacheManager::deleteFiles (const Glib::ustring& fname, const std::string& m } auto error = g_remove (getCacheFileName ("images", fname, ".rtti", md5).c_str ()); - error |= g_remove (getCacheFileName ("images", fname, ".cust16", md5).c_str ()); - error |= g_remove (getCacheFileName ("images", fname, ".cust", md5).c_str ()); - error |= g_remove (getCacheFileName ("images", fname, ".jpg", md5).c_str ()); error |= g_remove (getCacheFileName ("aehistograms", fname, "", md5).c_str ()); error |= g_remove (getCacheFileName ("embprofiles", fname, ".icc", md5).c_str ()); diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index 4921a2d56..d3bf4ca05 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -899,12 +899,7 @@ void Thumbnail::_saveThumbnail () return; } - if (g_remove (getCacheFileName ("images", ".rtti").c_str ()) != 0) { - // No file deleted, so we try to deleted obsolete files, if any - g_remove (getCacheFileName ("images", ".cust").c_str ()); - g_remove (getCacheFileName ("images", ".cust16").c_str ()); - g_remove (getCacheFileName ("images", ".jpg").c_str ()); - } + g_remove (getCacheFileName ("images", ".rtti").c_str ()) != 0); // save thumbnail image tpp->writeImage (getCacheFileName ("images", "")); From ea5a81b9a16eadf705b6de78dec1350849606b0c Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 31 Oct 2018 20:52:58 +0100 Subject: [PATCH 5/6] Don't check for .jpg, .cust, .cust16 files in cache/images folder, second try, #4904 --- rtgui/thumbnail.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index d3bf4ca05..1365117d7 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -899,7 +899,7 @@ void Thumbnail::_saveThumbnail () return; } - g_remove (getCacheFileName ("images", ".rtti").c_str ()) != 0); + g_remove (getCacheFileName ("images", ".rtti").c_str ())); // save thumbnail image tpp->writeImage (getCacheFileName ("images", "")); From ebcd737bf857a9d430ea71029770c577470aa44f Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 31 Oct 2018 20:57:21 +0100 Subject: [PATCH 6/6] Don't check for .jpg, .cust, .cust16 files in cache/images folder, third try, #4904 --- rtgui/thumbnail.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index 1365117d7..0ae78dd62 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -899,7 +899,7 @@ void Thumbnail::_saveThumbnail () return; } - g_remove (getCacheFileName ("images", ".rtti").c_str ())); + g_remove (getCacheFileName ("images", ".rtti").c_str ()); // save thumbnail image tpp->writeImage (getCacheFileName ("images", ""));