Solving issue 1103: I can't process my 16MPix images (RT crash because it lacks memory)
This commit is contained in:
@@ -245,8 +245,15 @@ namespace rtengine {
|
||||
|
||||
scale = scales[0];
|
||||
pitch = pitches[0];
|
||||
// freeing as much memory as possible since the next call to idirpyr will need lots
|
||||
for(int i = 1; i < maxlevel; i++) {
|
||||
delete dirpyrLablo[i];
|
||||
}
|
||||
|
||||
idirpyr(dirpyrLablo[0], dst, 0, rangefn_L, nrwt_l, nrwt_ab, pitch, scale, dnparams.luma, dnparams.chroma/*, Lcurve, abcurve*/ );
|
||||
|
||||
// freeing the last bunch of memory
|
||||
delete dirpyrLablo[0];
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
@@ -271,16 +278,6 @@ namespace rtengine {
|
||||
}
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
for(int i = 0; i < maxlevel; i++)
|
||||
{
|
||||
delete dirpyrLablo[i];
|
||||
}
|
||||
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
};
|
||||
|
||||
void ImProcFunctions::dirpyr(LabImage* data_fine, LabImage* data_coarse, int level, \
|
||||
|
@@ -70,6 +70,8 @@ class ImageSource : public InitialImage {
|
||||
virtual int load (Glib::ustring fname, bool batch = false) =0;
|
||||
virtual void preprocess (const RAWParams &raw){};
|
||||
virtual void demosaic (const RAWParams &raw){};
|
||||
virtual void flushRawData (){};
|
||||
virtual void flushRGB (){};
|
||||
virtual void HLRecovery_Global (HRecParams hrp){};
|
||||
virtual void HLRecovery_inpaint (float** red, float** green, float** blue){};
|
||||
|
||||
|
@@ -1132,6 +1132,32 @@ void RawImageSource::demosaic(const RAWParams &raw)
|
||||
}
|
||||
}
|
||||
|
||||
void RawImageSource::flushRawData() {
|
||||
if(cache) {
|
||||
delete [] cache;
|
||||
cache = 0;
|
||||
}
|
||||
if (rawData) {
|
||||
freeArray<float>(rawData, H);
|
||||
rawData = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void RawImageSource::flushRGB() {
|
||||
if (green) {
|
||||
freeArray<float>(green, H);
|
||||
green = 0;
|
||||
}
|
||||
if (red) {
|
||||
freeArray<float>(red, H);
|
||||
red = 0;
|
||||
}
|
||||
if (blue) {
|
||||
freeArray<float>(blue, H);
|
||||
blue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void RawImageSource::HLRecovery_Global(HRecParams hrp )
|
||||
{
|
||||
//color propagation highlight recovery
|
||||
|
@@ -102,7 +102,7 @@ class RawImageSource : public ImageSource {
|
||||
double* cache;
|
||||
int threshold;
|
||||
|
||||
float** rawData; // holds preprocessed pixel values, data[i][j] corresponds to the ith row and jth column
|
||||
float** rawData; // holds preprocessed pixel values, rowData[i][j] corresponds to the ith row and jth column
|
||||
|
||||
// the interpolated green plane:
|
||||
float** green;
|
||||
@@ -134,6 +134,8 @@ class RawImageSource : public ImageSource {
|
||||
int load (Glib::ustring fname, bool batch = false);
|
||||
void preprocess (const RAWParams &raw);
|
||||
void demosaic (const RAWParams &raw);
|
||||
void flushRawData ();
|
||||
void flushRGB ();
|
||||
void HLRecovery_Global (HRecParams hrp);
|
||||
void refinement_lassus ();
|
||||
|
||||
|
@@ -110,7 +110,6 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
imgsrc->getImage (currWB, tr, baseImg, pp, params.hlrecovery, params.icm, params.raw);
|
||||
if (pl) pl->setProgress (0.45);
|
||||
|
||||
|
||||
// perform first analysis
|
||||
LUTu hist16 (65536);
|
||||
ipf.firstAnalysis (baseImg, ¶ms, hist16, imgsrc->getGamma());
|
||||
@@ -145,6 +144,12 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
ipf.getAutoExp (aehist, aehistcompr, imgsrc->getDefGain(), params.toneCurve.clip, br, bl);
|
||||
}
|
||||
|
||||
// at this stage, we can flush the raw data to free up quite an important amount of memory
|
||||
imgsrc->flushRawData();
|
||||
|
||||
// at this stage, we can flush the raw data to free up quite an important amount of memory
|
||||
imgsrc->flushRGB();
|
||||
|
||||
LUTf curve1 (65536,0);
|
||||
LUTf curve2 (65536,0);
|
||||
LUTf curve (65536,0);
|
||||
@@ -216,8 +221,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
cw = params.crop.w;
|
||||
ch = params.crop.h;
|
||||
}
|
||||
if(params.icm.gamma != "default" || params.icm.freegamma)
|
||||
{ // if select gamma output between BT709, sRGB, linear, low, high, 2.2 , 1.8
|
||||
if(params.icm.gamma != "default" || params.icm.freegamma) { // if select gamma output between BT709, sRGB, linear, low, high, 2.2 , 1.8
|
||||
//or selected Free gamma
|
||||
Image16* readyImgP;
|
||||
Image16* readyImg = ipf.lab2rgb16b (labView, cx, cy, cw, ch, params.icm.output, params.icm.working, params.icm.gamma, params.icm.freegamma, params.icm.gampos, params.icm.slpos);
|
||||
@@ -242,10 +246,13 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
else if(j==5) chpro=options.rtSettings.bruce;
|
||||
else if(j==6) chpro=options.rtSettings.srgb;
|
||||
for (int i=0; i<opnames.size(); i++) {
|
||||
if(chpro.compare(opnames[i]) ==0) present_space[j]=1; }
|
||||
if(chpro.compare(opnames[i]) ==0) present_space[j]=1;
|
||||
}
|
||||
if (present_space[j]==0) {
|
||||
if (pl) pl->setProgressStr ("Missing file..");pl->setProgress (0.0);// display file not present: not very good display information...!!
|
||||
if (settings->verbose) printf("Missing file: %s \n", chpro.c_str());} //c_str()
|
||||
if (pl) pl->setProgressStr ("Missing file..");
|
||||
pl->setProgress (0.0);// display file not present: not very good display information...!!
|
||||
if (settings->verbose) printf("Missing file: %s \n", chpro.c_str());
|
||||
} //c_str()
|
||||
}
|
||||
|
||||
// Check that output profiles exist, otherwise use LCMS2
|
||||
@@ -287,12 +294,10 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
break;
|
||||
case (3):
|
||||
// FitBox
|
||||
if ((double)refw/(double)refh > (double)params.resize.width/(double)params.resize.height) {
|
||||
if ((double)refw/(double)refh > (double)params.resize.width/(double)params.resize.height)
|
||||
tmpScale = (double)params.resize.width/(double)refw;
|
||||
}
|
||||
else {
|
||||
else
|
||||
tmpScale = (double)params.resize.height/(double)refh;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Scale
|
||||
@@ -301,8 +306,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
}
|
||||
|
||||
// resize image
|
||||
if (fabs(tmpScale-1.0)>1e-5)
|
||||
{
|
||||
if (fabs(tmpScale-1.0)>1e-5) {
|
||||
int imw, imh;
|
||||
if (params.crop.enabled && params.resize.appliesTo == "Full image") {
|
||||
imw = cw;
|
||||
@@ -345,8 +349,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
|
||||
return readyImg;
|
||||
}
|
||||
else
|
||||
{//if default mode : profil = selection by choice in list (Prophoto.icm, sRGB.icm, etc., etc.) , gamma = gamma of profile or not selected Free gamma
|
||||
else {
|
||||
//if default mode : profil = selection by choice in list (Prophoto.icm, sRGB.icm, etc., etc.) , gamma = gamma of profile or not selected Free gamma
|
||||
Image16* readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm.output);
|
||||
delete labView;
|
||||
if (pl) pl->setProgress (0.70);
|
||||
@@ -380,12 +384,10 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
break;
|
||||
case (3):
|
||||
// FitBox
|
||||
if ((double)refw/(double)refh > (double)params.resize.width/(double)params.resize.height) {
|
||||
if ((double)refw/(double)refh > (double)params.resize.width/(double)params.resize.height)
|
||||
tmpScale = (double)params.resize.width/(double)refw;
|
||||
}
|
||||
else {
|
||||
else
|
||||
tmpScale = (double)params.resize.height/(double)refh;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Scale
|
||||
@@ -394,8 +396,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
}
|
||||
|
||||
// resize image
|
||||
if (fabs(tmpScale-1.0)>1e-5)
|
||||
{
|
||||
if (fabs(tmpScale-1.0)>1e-5) {
|
||||
int imw, imh;
|
||||
if (params.crop.enabled && params.resize.appliesTo == "Full image") {
|
||||
imw = cw;
|
||||
|
Reference in New Issue
Block a user