Fixed crash when Rt-spot is too small for Denoise and Dehaze

This commit is contained in:
Desmis
2019-09-30 17:42:32 +02:00
parent 3ba153ae62
commit 2ed52360f5
2 changed files with 680 additions and 672 deletions

View File

@@ -52,6 +52,7 @@
#define MAXSCOPE 1.25f
#define MINSCOPE 0.025f
#define mSP 5 //minimum size Spot
#define mDEN 64 //minimum size Spot Denoise
#define CLIPC(a) LIM(a, -42000.f, 42000.f) // limit a and b to 130 probably enough ?
#define CLIPL(x) LIM(x,0.f,40000.f) // limit L to about L=120 probably enough ?
@@ -5438,6 +5439,9 @@ void ImProcFunctions::DeNoise(int call, int del, float * slidL, float * slida, f
levred = 7;
}
int GW = transformed->W;
int GH = transformed->H;
#ifdef _OPENMP
const int numThreads = omp_get_max_threads();
@@ -5446,7 +5450,7 @@ void ImProcFunctions::DeNoise(int call, int del, float * slidL, float * slida, f
#endif
if (call == 1) {
if (call == 1 && GW >= mDEN && GH >= mDEN) {
LabImage tmp1(transformed->W, transformed->H);
@@ -6021,6 +6025,8 @@ void ImProcFunctions::DeNoise(int call, int del, float * slidL, float * slida, f
int bfh = int (lp.ly + lp.lyT) + del; //bfw bfh real size of square zone
int bfw = int (lp.lx + lp.lxL) + del;
if (bfh >= mDEN && bfw >= mDEN) {
LabImage bufwv(bfw, bfh);
bufwv.clear(true);
array2D<float> *Lin = nullptr;
@@ -6584,7 +6590,7 @@ void ImProcFunctions::DeNoise(int call, int del, float * slidL, float * slida, f
DeNoise_Local(call, lp, originalmaskbl, levred, huerefblur, lumarefblur, chromarefblur, original, transformed, bufwv, cx, cy, sk);
}
}
}
}
@@ -8648,6 +8654,8 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
int xend = std::min(static_cast<int>(lp.xc + lp.lx) - cx, original->W);
int bfh = yend - ystart;
int bfw = xend - xstart;
if (bfh >= mSP && bfw >= mSP) {
std::unique_ptr<LabImage> bufexporig(new LabImage(bfw, bfh)); //buffer for data in zone limit
std::unique_ptr<LabImage> bufexpfin(new LabImage(bfw, bfh)); //buffer for data in zone limit
JaggedArray<float> buflight(bfw, bfh);
@@ -8730,6 +8738,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
bufexpfin.reset();
transit_shapedetect(30, bufexporig.get(), nullptr, buflight, bufl_ab, nullptr, nullptr, nullptr, false, hueref, chromaref, lumaref, sobelref, 0.f, nullptr, lp, original, transformed, cx, cy, sk);
}
}
if (lp.str >= 0.2f && lp.retiena && call != 2) {
int GW = transformed->W;
@@ -8739,8 +8748,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
LabImage *buforig = nullptr;
LabImage *buforigmas = nullptr;
if (GW > 2 && GH > 2)
if (GW >= mSP && GH >= mSP)
{
@@ -9135,7 +9143,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
bool reduH = false;
bool reduW = false;
if (bfw > 2 && bfh > 2) {
if (bfw >= mSP && bfh > mSP) {
if (lp.ftwreti) {
int ftsizeH = 1;

View File

@@ -870,7 +870,7 @@ void maskforretinex(int sp, int before, float ** luminance, float ** out, int W_
for (int x = 0; x < W_L; x++) {
if (before == 1 && retiMasktmap) {
loctemp[y][x] = LIM(luminance[y][x], 0.f, 32768.f);
} else if(before == 0 && retiMasktmap ){
} else if (before == 0 && retiMasktmap) {
loctemp[y][x] = out[y][x];
} else {
loctemp[y][x] = bufreti->L[y][x];
@@ -1259,13 +1259,13 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L
}
}
/*
/*
if (lum == 1 && scale == 1 && (llretiMask == 3 || llretiMask == 0 || llretiMask == 2 || llretiMask == 4)) { //only mask with luminance on last scale
int before = 0;
maskforretinex(sp, before, luminance, out, W_L, H_L, skip, locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, retiMasktmap, retiMask,
loc, bufreti, bufmask, buforig, buforigmas, multiThread);
}
*/
*/
#ifdef __SSE2__
vfloat pondv = F2V(pond);