Fattal: one less buffer alloc/dealloc

This commit is contained in:
heckflosse
2017-11-09 13:06:12 +01:00
parent b0ebcc30eb
commit 67b6aec64e
2 changed files with 6 additions and 5 deletions

View File

@@ -117,7 +117,7 @@ void do_median_denoise(float **src, float **dst, float upperBound, const int wid
// we need a buffer if src == dst or if (src != dst && iterations > 1)
if (src == dst || iterations > 1) {
if (buffer == nullptr) { // we didn't get a buufer => create one
if (buffer == nullptr) { // we didn't get a buffer => create one
allocBuffer = new float*[height];
for (int i = 0; i < height; ++i) {

View File

@@ -1248,6 +1248,10 @@ void ImProcFunctions::ToneMapFattal02(Imagefloat *rgb)
}
}
// median filter on the deep shadows, to avoid boosting noise
// because w2 >= w and h2 >= h, we can use the L buffer as temporary buffer for Median_Denoise()
int w2 = find_fast_dim(w) + 1;
int h2 = find_fast_dim(h) + 1;
Array2Df L(w2, h2);
{
#ifdef _OPENMP
int num_threads = multiThread ? omp_get_max_threads() : 1;
@@ -1265,7 +1269,7 @@ void ImProcFunctions::ToneMapFattal02(Imagefloat *rgb)
} else {
med = Median::TYPE_3X3_STRONG;
}
Median_Denoise(Yr, Yr, luminance_noise_floor, w, h, med, 1, num_threads);
Median_Denoise(Yr, Yr, luminance_noise_floor, w, h, med, 1, num_threads, L);
}
float noise = alpha * 0.01f;
@@ -1275,9 +1279,6 @@ void ImProcFunctions::ToneMapFattal02(Imagefloat *rgb)
<< ", detail_level = " << detail_level << std::endl;
}
int w2 = find_fast_dim(w) + 1;
int h2 = find_fast_dim(h) + 1;
Array2Df L(w2, h2);
rescale_nearest(Yr, L, multiThread);
tmo_fattal02(w2, h2, L, L, alpha, beta, noise, detail_level, multiThread);