From c66bd4317d4edd63c2b612a96ec4d5970a9c8bc2 Mon Sep 17 00:00:00 2001 From: Oliver Duis Date: Mon, 25 Apr 2011 20:11:31 +0200 Subject: [PATCH] Reduced memory consumption esp. when sharpening is off --- rtengine/dcrop.cc | 2 +- rtengine/improccoordinator.cc | 32 ++++++++++++++++++++------------ rtengine/improccoordinator.h | 2 -- rtengine/rtthumbnail.cc | 13 +------------ rtengine/shmap.cc | 2 +- rtengine/shmap.h | 2 +- rtengine/simpleprocess.cc | 20 ++++++++++++-------- 7 files changed, 36 insertions(+), 37 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index c87abb7e4..0e6cf5643 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -124,7 +124,7 @@ void Crop::update (int todo) { double radius = sqrt (double(SKIPS(parent->fw,skip)*SKIPS(parent->fw,skip)+SKIPS(parent->fh,skip)*SKIPS(parent->fh,skip))) / 2.0; double shradius = params.sh.radius; if (!params.sh.hq) shradius *= radius / 1800.0; - cshmap->update (baseCrop, cbuffer, shradius, parent->ipf.lumimul, params.sh.hq, skip); + cshmap->update (baseCrop, shradius, parent->ipf.lumimul, params.sh.hq, skip); cshmap->forceStat (parent->shmap->max, parent->shmap->min, parent->shmap->avg); } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 9589c8840..cd7b1edd5 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -172,7 +172,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { double radius = sqrt (double(pW*pW+pH*pH)) / 2.0; double shradius = params.sh.radius; if (!params.sh.hq) shradius *= radius / 1800.0; - shmap->update (oprevi, buffer, shradius, ipf.lumimul, params.sh.hq, scale); + shmap->update (oprevi, shradius, ipf.lumimul, params.sh.hq, scale); } readyphase++; @@ -238,8 +238,21 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { // ipf.colordenoise (nprevl, buffer); progress ("Denoising luma/chroma...",100*readyphase/numofphases); ipf.dirpyrdenoise (nprevl); - progress ("Sharpening...",100*readyphase/numofphases); - ipf.sharpening (nprevl, (float**)buffer); + + if (params.sharpening.enabled) { + progress ("Sharpening...",100*readyphase/numofphases); + + float **buffer = new float*[pH]; + for (int i=0; igetMutex().unlock(); + progress ("Error converting file...",0); + previmg->getMutex().unlock(); mProcessing.unlock (); return; } @@ -318,9 +331,7 @@ void ImProcCoordinator::freeAll () { delete workimg; delete shmap; - for (int i=0; iverbose) printf ("setscale before lock\n"); previmg = new Image8 (pW, pH); workimg = new Image8 (pW, pH); shmap = new SHMap (pW, pH, true); - - buffer = new float*[pH]; - for (int i=0; iupdate (baseImg, buffer, shradius, ipf.lumimul, params.sh.hq, 16); - if (buffer) { - for (int i=0; iupdate (baseImg, shradius, ipf.lumimul, params.sh.hq, 16); } // RGB processing diff --git a/rtengine/shmap.cc b/rtengine/shmap.cc index 030fbec93..c81b79147 100644 --- a/rtengine/shmap.cc +++ b/rtengine/shmap.cc @@ -56,7 +56,7 @@ SHMap::~SHMap () { delete [] map; } -void SHMap::update (Imagefloat* img, float** buffer, double radius, double lumi[3], bool hq, int skip) { +void SHMap::update (Imagefloat* img, double radius, double lumi[3], bool hq, int skip) { // fill with luminance for (int i=0; iupdate (baseImg, buffer, shradius, ipf.lumimul, params.sh.hq, 1); + shmap->update (baseImg, shradius, ipf.lumimul, params.sh.hq, 1); } // RGB processing //!!!// auto exposure!!! @@ -181,9 +179,18 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p ipf.defringe (labView); //ipf.lumadenoise (labView, buffer); ipf.dirpyrdenoise (labView); - ipf.sharpening (labView, (float**)buffer); + if (params.sharpening.enabled) { + float** buffer = new float*[fh]; + for (int i=0; isetProgress (0.60);