diff --git a/rtengine/EdgePreservingDecomposition.cc b/rtengine/EdgePreservingDecomposition.cc index 8c1ca56a7..0a92d41cd 100644 --- a/rtengine/EdgePreservingDecomposition.cc +++ b/rtengine/EdgePreservingDecomposition.cc @@ -6,7 +6,7 @@ #endif #include "sleef.c" #include "opthelper.h" - +#include #define pow_F(a,b) (xexpf(b*xlogf(a))) #define DIAGONALS 5 @@ -883,7 +883,7 @@ float *EdgePreservingDecomposition::CreateIteratedBlur(float *Source, float Scal return Blur; } -SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Source, float Scale, float EdgeStopping, float CompressionExponent, float DetailBoost, int Iterates, int Reweightings, float *Compressed) +SSEFUNCTION void EdgePreservingDecomposition::CompressDynamicRange(float *Source, float Scale, float EdgeStopping, float CompressionExponent, float DetailBoost, int Iterates, int Reweightings) { if(w < 300 && h < 300) { // set number of Reweightings to zero for small images (thumbnails). We could try to find a better solution here. Reweightings = 0; @@ -926,12 +926,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour //Blur. Also setup memory for Compressed (we can just use u since each element of u is used in one calculation). float *u = CreateIteratedBlur(Source, Scale, EdgeStopping, Iterates, Reweightings); - if(Compressed == nullptr) { - Compressed = u; - } - //Apply compression, detail boost, unlogging. Compression is done on the logged data and detail boost on unlogged. -// float temp = CompressionExponent - 1.0f; float temp; if(DetailBoost > 0.f) { @@ -958,8 +953,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour cev = xexpf(LVFU(Source[i]) + LVFU(u[i]) * (tempv)) - epsv; uev = xexpf(LVFU(u[i])) - epsv; sourcev = xexpf(LVFU(Source[i])) - epsv; - _mm_storeu_ps( &Source[i], sourcev); - _mm_storeu_ps( &Compressed[i], cev + DetailBoostv * (sourcev - uev) ); + _mm_storeu_ps( &Source[i], cev + DetailBoostv * (sourcev - uev) ); } } @@ -967,7 +961,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour float ce = xexpf(Source[i] + u[i] * (temp)) - eps; float ue = xexpf(u[i]) - eps; Source[i] = xexpf(Source[i]) - eps; - Compressed[i] = ce + DetailBoost * (Source[i] - ue); + Source[i] = ce + DetailBoost * (Source[i] - ue); } #else @@ -979,16 +973,11 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour float ce = xexpf(Source[i] + u[i] * (temp)) - eps; float ue = xexpf(u[i]) - eps; Source[i] = xexpf(Source[i]) - eps; - Compressed[i] = ce + DetailBoost * (Source[i] - ue); + Source[i] = ce + DetailBoost * (Source[i] - ue); } #endif - if(Compressed != u) { - delete[] u; - } - - return Compressed; - + delete[] u; } diff --git a/rtengine/EdgePreservingDecomposition.h b/rtengine/EdgePreservingDecomposition.h index bf567f103..1eca7b2c8 100644 --- a/rtengine/EdgePreservingDecomposition.h +++ b/rtengine/EdgePreservingDecomposition.h @@ -152,7 +152,7 @@ public: the more compression is applied, with Compression = 1 giving no effect and above 1 the opposite effect. You can totally use Compression = 1 and play with DetailBoost for some really sweet unsharp masking. If working on luma/grey, consider giving it a logarithm. In place calculation to save memory (Source == Compressed) is totally ok. Reweightings > 0 invokes CreateIteratedBlur instead of CreateBlur. */ - float *CompressDynamicRange(float *Source, float Scale = 1.0f, float EdgeStopping = 1.4f, float CompressionExponent = 0.8f, float DetailBoost = 0.1f, int Iterates = 20, int Reweightings = 0, float *Compressed = nullptr); + void CompressDynamicRange(float *Source, float Scale = 1.0f, float EdgeStopping = 1.4f, float CompressionExponent = 0.8f, float DetailBoost = 0.1f, int Iterates = 20, int Reweightings = 0); private: MultiDiagonalSymmetricMatrix *A; //The equations are simple enough to not mandate a matrix class, but fast solution NEEDS a complicated preconditioner. diff --git a/rtengine/camconst.cc b/rtengine/camconst.cc index 2449a1cd1..40e13d8e8 100644 --- a/rtengine/camconst.cc +++ b/rtengine/camconst.cc @@ -317,6 +317,7 @@ CameraConst::parseEntry(void *cJSON_, const char *make_model) return cc; parse_error: + delete cc; return nullptr; } diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 5c96aa6fd..95c3848ba 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -6438,7 +6438,7 @@ void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, float //Jacques Desmis : always Iterates=5 for compatibility images between preview and output - epd.CompressDynamicRange (Qpr, (float)sca / skip, (float)edgest, Compression, DetailBoost, Iterates, rew, Qpr); + epd.CompressDynamicRange (Qpr, (float)sca / skip, (float)edgest, Compression, DetailBoost, Iterates, rew); //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f)); @@ -6585,7 +6585,7 @@ void ImProcFunctions::EPDToneMap (LabImage *lab, unsigned int Iterates, int skip fwrite(L, N, sizeof(float), f); fclose(f);*/ - epd.CompressDynamicRange (L, sca / float (skip), edgest, Compression, DetailBoost, Iterates, rew, L); + epd.CompressDynamicRange (L, sca / float (skip), edgest, Compression, DetailBoost, Iterates, rew); //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f)); diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index d981c803d..cbde6aef1 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -1654,7 +1654,7 @@ void ImProcFunctions::EPDToneMapResid(float * WavCoeffs_L0, unsigned int Iterat } - epd2.CompressDynamicRange(WavCoeffs_L0, (float)sca / skip, edgest, Compression, DetailBoost, Iterates, rew, WavCoeffs_L0); + epd2.CompressDynamicRange(WavCoeffs_L0, (float)sca / skip, edgest, Compression, DetailBoost, Iterates, rew); //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. #ifdef _RT_NESTED_OPENMP diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index d64288c21..51e0bebf9 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -8502,6 +8502,12 @@ PartialProfile::PartialProfile(const ProcParams* pp, const ParamsEdited* pe) } } +PartialProfile::~PartialProfile() +{ + delete pparams; + delete pedited; +} + int PartialProfile::load (const Glib::ustring &fName) { if (!pparams) { diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 973986d85..5b2b2ebc4 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1435,6 +1435,7 @@ public: PartialProfile (bool createInstance = false, bool paramsEditedValue = false); PartialProfile (ProcParams* pp, ParamsEdited* pe = nullptr, bool fullCopy = false); PartialProfile (const ProcParams* pp, const ParamsEdited* pe = nullptr); + ~PartialProfile (); void deleteInstance (); void clearGeneral (); int load (const Glib::ustring &fName); diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 459abbe5b..b67fef8bd 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -451,7 +451,7 @@ public: }; EditorPanel::EditorPanel (FilePanel* filePanel) - : catalogPane(nullptr), realized(false), iHistoryShow(nullptr), iHistoryHide(nullptr), iTopPanel_1_Show(nullptr), iTopPanel_1_Hide(nullptr), iRightPanel_1_Show(nullptr), iRightPanel_1_Hide(nullptr), iBeforeLockON(nullptr), iBeforeLockOFF(nullptr), beforePreviewHandler(nullptr), beforeIarea(nullptr), beforeBox(nullptr), afterBox(nullptr), afterHeaderBox(nullptr), parent(nullptr), openThm(nullptr), ipc(nullptr), beforeIpc(nullptr), isProcessing(false) + : catalogPane(nullptr), realized(false), tbBeforeLock(nullptr), iHistoryShow(nullptr), iHistoryHide(nullptr), iTopPanel_1_Show(nullptr), iTopPanel_1_Hide(nullptr), iRightPanel_1_Show(nullptr), iRightPanel_1_Hide(nullptr), iBeforeLockON(nullptr), iBeforeLockOFF(nullptr), previewHandler(nullptr), beforePreviewHandler(nullptr), beforeIarea(nullptr), beforeBox(nullptr), afterBox(nullptr), beforeLabel(nullptr), afterLabel(nullptr), beforeHeaderBox(nullptr), afterHeaderBox(nullptr), parent(nullptr), openThm(nullptr), isrc(nullptr), ipc(nullptr), beforeIpc(nullptr), err(0), isProcessing(false) { epih = new EditorPanelIdleHelper; @@ -1689,6 +1689,8 @@ bool EditorPanel::idle_saveImage (ProgressConnector *pc, Gl else if (sf.format == "jpg") ld->startFunc (sigc::bind (sigc::mem_fun (img, &rtengine::IImage16::saveAsJPEG), fname, sf.jpegQuality, sf.jpegSubSamp), sigc::bind (sigc::mem_fun (*this, &EditorPanel::idle_imageSaved), ld, img, fname, sf)); + else + delete ld; } else { Glib::ustring msg_ = Glib::ustring ("") + fname + ": Error during image processing\n"; Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); diff --git a/rtgui/previewloader.cc b/rtgui/previewloader.cc index 0c0ecf9f6..a43c47d2e 100644 --- a/rtgui/previewloader.cc +++ b/rtgui/previewloader.cc @@ -168,6 +168,11 @@ PreviewLoader::PreviewLoader(): { } +PreviewLoader::~PreviewLoader() +{ + delete impl_; +} + PreviewLoader* PreviewLoader::getInstance() { static PreviewLoader instance_; diff --git a/rtgui/previewloader.h b/rtgui/previewloader.h index d5207cd44..d2f21b013 100644 --- a/rtgui/previewloader.h +++ b/rtgui/previewloader.h @@ -88,6 +88,7 @@ public: private: PreviewLoader(); + ~PreviewLoader(); class Impl; Impl* impl_; diff --git a/rtgui/thumbimageupdater.cc b/rtgui/thumbimageupdater.cc index 95618d5ab..b30047c2f 100644 --- a/rtgui/thumbimageupdater.cc +++ b/rtgui/thumbimageupdater.cc @@ -184,6 +184,11 @@ ThumbImageUpdater::ThumbImageUpdater(): { } +ThumbImageUpdater::~ThumbImageUpdater() +{ + delete impl_; +} + void ThumbImageUpdater::add(ThumbBrowserEntryBase* tbe, bool* priority, bool upgrade, ThumbImageUpdateListener* l) { diff --git a/rtgui/thumbimageupdater.h b/rtgui/thumbimageupdater.h index 3b34c9456..0ac92a31a 100644 --- a/rtgui/thumbimageupdater.h +++ b/rtgui/thumbimageupdater.h @@ -93,6 +93,7 @@ public: private: ThumbImageUpdater(); + ~ThumbImageUpdater(); class Impl; Impl* impl_;