Reduced peak memory usage of Noise Reduction, Issue 2557
This commit is contained in:
@@ -717,8 +717,8 @@ do {
|
||||
const float noisevarab_r = SQR(realred);
|
||||
const float noisevarab_b = SQR(realblue);
|
||||
|
||||
//input L channel
|
||||
array2D<float> Lin(width,height);
|
||||
//input L channel
|
||||
array2D<float> *Lin;
|
||||
//wavelet denoised image
|
||||
LabImage * labdn = new LabImage(width,height);
|
||||
|
||||
@@ -760,8 +760,6 @@ do {
|
||||
labdn->a[i1][j1] = a;
|
||||
labdn->b[i1][j1] = b;
|
||||
|
||||
Lin[i1][j1] = L;
|
||||
|
||||
if(((i1|j1)&1) == 0) {
|
||||
if(numTries == 1) {
|
||||
noisevarlum[(i1>>1)*width2+(j1>>1)] = useNoiseLCurve ? lumcalc[i>>1][j>>1] : noisevarL;
|
||||
@@ -795,8 +793,6 @@ do {
|
||||
labdn->a[i1][j1] = (X-Y);
|
||||
labdn->b[i1][j1] = (Y-Z);
|
||||
|
||||
Lin[i1][j1] = Y;
|
||||
|
||||
if(((i1|j1)&1) == 0) {
|
||||
if(numTries == 1) {
|
||||
noisevarlum[(i1>>1)*width2+(j1>>1)] = useNoiseLCurve ? lumcalc[i>>1][j>>1] : noisevarL;
|
||||
@@ -843,8 +839,6 @@ do {
|
||||
labdn->a[i1][j1] = a;
|
||||
labdn->b[i1][j1] = b;
|
||||
|
||||
Lin[i1][j1] = L;
|
||||
|
||||
if(((i1|j1)&1) == 0) {
|
||||
float Llum,alum,blum;
|
||||
if(useNoiseLCurve || useNoiseCCurve) {
|
||||
@@ -1006,7 +1000,7 @@ do {
|
||||
bdecomp->reconstruct(labdn->data+2*datalen);
|
||||
}
|
||||
delete bdecomp;
|
||||
if(!memoryAllocationFailed) {
|
||||
if(!memoryAllocationFailed) {
|
||||
if(nrQuality==QUALITY_STANDARD) {
|
||||
if(!WaveletDenoiseAllL(*Ldecomp, noisevarL, noisevarlum, madL, width, height, useNoiseLCurve, denoiseMethodRgb ))//enhance mode
|
||||
memoryAllocationFailed = true;
|
||||
@@ -1017,8 +1011,17 @@ do {
|
||||
if(!WaveletDenoiseAllL(*Ldecomp, noisevarL, noisevarlum, madL, width, height, useNoiseLCurve, denoiseMethodRgb ))
|
||||
memoryAllocationFailed = true;
|
||||
}
|
||||
if(!memoryAllocationFailed)
|
||||
Ldecomp->reconstruct(labdn->data);
|
||||
if(!memoryAllocationFailed) {
|
||||
// copy labdn->L to Lin before it gets modified by reconstruction
|
||||
Lin = new array2D<float>(width,height);
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for num_threads(denoiseNestedLevels) if(denoiseNestedLevels>1)
|
||||
#endif
|
||||
for(int i=0;i<height;i++)
|
||||
for(int j=0;j<width;j++)
|
||||
(*Lin)[i][j] = labdn->L[i][j];
|
||||
Ldecomp->reconstruct(labdn->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete Ldecomp;
|
||||
@@ -1156,7 +1159,7 @@ do {
|
||||
}
|
||||
|
||||
for (int j=0; j<labdn->W; j++) {
|
||||
datarow[j] = (Lin[rr][j]-labdn->L[rr][j]);
|
||||
datarow[j] = ((*Lin)[rr][j]-labdn->L[rr][j]);
|
||||
}
|
||||
|
||||
for (int j=-blkrad*offset; j<0; j++) {
|
||||
@@ -1396,7 +1399,8 @@ do {
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
}
|
||||
delete labdn;
|
||||
delete labdn;
|
||||
delete Lin;
|
||||
|
||||
}//end of tile row
|
||||
}//end of tile loop
|
||||
|
Reference in New Issue
Block a user