Reduced memory consumption esp. when sharpening is off

This commit is contained in:
Oliver Duis
2011-04-25 20:11:31 +02:00
parent 051d34a21c
commit c66bd4317d
7 changed files with 36 additions and 37 deletions

View File

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

View File

@@ -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; i<pH; i++)
buffer[i] = new float[pW];
ipf.sharpening (nprevl, (float**)buffer);
for (int i=0; i<pH; i++)
delete [] buffer[i];
delete [] buffer;
}
progress ("Pyramid equalizer...",100*readyphase/numofphases);
ipf.dirpyrequalizer (nprevl);
@@ -265,8 +278,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
}
catch(char * str)
{
progress ("Error converting file...",0);
previmg->getMutex().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; i<pH; i++)
delete [] buffer[i];
delete [] buffer;
}
allocated = false;
}
@@ -358,10 +369,7 @@ if (settings->verbose) 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; i<pH; i++)
buffer[i] = new float[pW];
allocated = true;
}

View File

@@ -50,8 +50,6 @@ class ImProcCoordinator : public StagedImageProcessor {
ImageSource* imgsrc;
float** buffer;
SHMap* shmap;
ColorTemp currWB;

View File

@@ -698,22 +698,11 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
// update blurmap
SHMap* shmap = NULL;
if (params.sh.enabled) {
float** buffer = NULL;
if (params.sh.hq) {
buffer = new float*[fh];
for (int i=0; i<fh; i++)
buffer[i] = new float[fw];
}
shmap = new SHMap (fw, fh, false);
double radius = sqrt (double(fw*fw+fh*fh)) / 2.0;
double shradius = params.sh.radius;
if (!params.sh.hq) shradius *= radius / 1800.0;
shmap->update (baseImg, buffer, shradius, ipf.lumimul, params.sh.hq, 16);
if (buffer) {
for (int i=0; i<fh; i++)
delete [] buffer[i];
delete [] buffer;
}
shmap->update (baseImg, shradius, ipf.lumimul, params.sh.hq, 16);
}
// RGB processing

View File

@@ -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; i<H; i++)

View File

@@ -35,7 +35,7 @@ class SHMap {
SHMap (int w, int h, bool multiThread);
~SHMap ();
void update (Imagefloat* img, float** buffer, double radius, double lumi[3], bool hq, int skip);
void update (Imagefloat* img, double radius, double lumi[3], bool hq, int skip);
void forceStat (float max_, float min_, float avg_);
void dirpyr_shmap (float ** data_fine, float ** data_coarse,
int width, int height, LUTf & rangefn, int level, int scale);

View File

@@ -121,9 +121,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
}
// update blurmap
float** buffer = new float*[fh];
for (int i=0; i<fh; i++)
buffer[i] = new float[fw];
SHMap* shmap = NULL;
if (params.sh.enabled) {
@@ -131,7 +129,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
double radius = sqrt (double(fw*fw+fh*fh)) / 2.0;
double shradius = params.sh.radius;
if (!params.sh.hq) shradius *= radius / 1800.0;
shmap->update (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; i<fh; i++)
buffer[i] = new float[fw];
ipf.sharpening (labView, (float**)buffer);
for (int i=0; i<fh; i++)
delete [] buffer[i];
delete [] buffer; buffer=NULL;
}
// wavelet equalizer
//ipf.waveletEqualizer (labView, true, true);
@@ -191,9 +198,6 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
// directional pyramid equalizer
ipf.dirpyrequalizer (labView);//TODO: this is the luminance tonecurve, not the RGB one
for (int i=0; i<fh; i++)
delete [] buffer[i];
delete [] buffer;
if (pl) pl->setProgress (0.60);