Change ALIGND16 buffer with std::unique_ptr<JaggedArray>

This commit is contained in:
Desmis 2019-10-28 07:22:23 +01:00
parent 5af042af67
commit 23e36a5daa
2 changed files with 39 additions and 68 deletions

View File

@ -3341,12 +3341,8 @@ void ImProcFunctions::maskcalccol(bool invmask, bool pde, int bfw, int bfh, int
} }
if (delt) { if (delt) {
float *rdE[bfh] ALIGNED16; std::unique_ptr<JaggedArray<float>> rdEBuffer(new JaggedArray<float>(bfw, bfh));
float *rdEBuffer = new float[bfh * bfw]; float** rdE = *(rdEBuffer.get());
for (int i = 0; i < bfh; i++) {
rdE[i] = &rdEBuffer[i * bfw];
}
deltaEforMask(rdE, bfw, bfh, bufcolorig, hueref, chromaref, lumaref, maxdE, mindE, maxdElim, mindElim, iterat, limscope, scope, lp.balance); deltaEforMask(rdE, bfw, bfh, bufcolorig, hueref, chromaref, lumaref, maxdE, mindE, maxdElim, mindElim, iterat, limscope, scope, lp.balance);
// printf("rde1=%f rde2=%f\n", rdE[1][1], rdE[100][100]); // printf("rde1=%f rde2=%f\n", rdE[1][1], rdE[100][100]);
@ -3366,7 +3362,7 @@ void ImProcFunctions::maskcalccol(bool invmask, bool pde, int bfw, int bfh, int
bufmaskblurcol->b[ir][jr] = bufprov->b[ir][jr] + rdE[ir][jr] * delta->b[ir][jr]; bufmaskblurcol->b[ir][jr] = bufprov->b[ir][jr] + rdE[ir][jr] * delta->b[ir][jr];
} }
delete [] rdEBuffer; rdEBuffer.reset();
} }
@ -4553,14 +4549,16 @@ void ImProcFunctions::InverseColorLight_Local(bool tonequ, bool tonecurv, int sp
Imagefloat *tmpImage = nullptr; Imagefloat *tmpImage = nullptr;
tmpImage = new Imagefloat(GW, GH); tmpImage = new Imagefloat(GW, GH);
lab2rgb(*temp, *tmpImage, params->icm.workingProfile); lab2rgb(*temp, *tmpImage, params->icm.workingProfile);
if(tonecurv) {//Tone response curve : does nothing if gamma=2.4 and slope=12.92 ==> gamma sRGB
if (tonecurv) { //Tone response curve : does nothing if gamma=2.4 and slope=12.92 ==> gamma sRGB
float gamtone = params->locallab.spots.at(sp).gamSH; float gamtone = params->locallab.spots.at(sp).gamSH;
float slotone = params->locallab.spots.at(sp).sloSH; float slotone = params->locallab.spots.at(sp).sloSH;
cmsHTRANSFORM dummy = nullptr; cmsHTRANSFORM dummy = nullptr;
workingtrc(tmpImage, tmpImage, GW, GH, -5, params->icm.workingProfile, 2.4, 12.92310, dummy, true, false, false); workingtrc(tmpImage, tmpImage, GW, GH, -5, params->icm.workingProfile, 2.4, 12.92310, dummy, true, false, false);
workingtrc(tmpImage, tmpImage, GW, GH, 5, params->icm.workingProfile, gamtone, slotone, dummy, false, true, true); workingtrc(tmpImage, tmpImage, GW, GH, 5, params->icm.workingProfile, gamtone, slotone, dummy, false, true, true);
} }
if(tonequ) {
if (tonequ) {
tmpImage->normalizeFloatTo1(); tmpImage->normalizeFloatTo1();
array2D<float> Rtemp(GW, GH, tmpImage->r.ptrs, ARRAY2D_BYREFERENCE); array2D<float> Rtemp(GW, GH, tmpImage->r.ptrs, ARRAY2D_BYREFERENCE);
array2D<float> Gtemp(GW, GH, tmpImage->g.ptrs, ARRAY2D_BYREFERENCE); array2D<float> Gtemp(GW, GH, tmpImage->g.ptrs, ARRAY2D_BYREFERENCE);
@ -4568,6 +4566,7 @@ void ImProcFunctions::InverseColorLight_Local(bool tonequ, bool tonecurv, int sp
tone_eq(Rtemp, Gtemp, Btemp, lp, params->icm.workingProfile, scal, multiThread); tone_eq(Rtemp, Gtemp, Btemp, lp, params->icm.workingProfile, scal, multiThread);
tmpImage->normalizeFloatTo65535(); tmpImage->normalizeFloatTo65535();
} }
rgb2lab(*tmpImage, *temp, params->icm.workingProfile); rgb2lab(*tmpImage, *temp, params->icm.workingProfile);
delete tmpImage; delete tmpImage;
@ -5999,7 +5998,7 @@ void ImProcFunctions::fftw_denoise(int GW, int GH, int max_numblox_W, int min_nu
for (int hblk = 0; hblk < numblox_W; ++hblk) { for (int hblk = 0; hblk < numblox_W; ++hblk) {
ImProcFunctions::RGBtile_denoise(fLblox, hblk, noisevar_Ldetail); ImProcFunctions::RGBtile_denoise(fLblox, hblk, noisevar_Ldetail);
}//end of horizontal block loop }//end of horizontal block loop
@ -7614,12 +7613,8 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
const float maxdElim = 5.f + MAXSCOPE * limscope * (1 + 0.1f * lp.thr); const float maxdElim = 5.f + MAXSCOPE * limscope * (1 + 0.1f * lp.thr);
if (delt && lp.blurmet == 0 && (lp.enablMask || lp.showmaskblmet == 3)) { if (delt && lp.blurmet == 0 && (lp.enablMask || lp.showmaskblmet == 3)) {
float *rdE[GH] ALIGNED16; std::unique_ptr<JaggedArray<float>> rdEBuffer(new JaggedArray<float>(GW, GH));
float *rdEBuffer = new float[GH * GW]; float** rdE = *(rdEBuffer.get());
for (int i = 0; i < GH; i++) {
rdE[i] = &rdEBuffer[i * GW];
}
deltaEforMask(rdE, GW, GH, bufgb.get(), hueref, chromaref, lumaref, maxdE, mindE, maxdElim, mindElim, lp.iterat, limscope, sco, lp.balance); deltaEforMask(rdE, GW, GH, bufgb.get(), hueref, chromaref, lumaref, maxdE, mindE, maxdElim, mindElim, lp.iterat, limscope, sco, lp.balance);
// printf("rde1=%f rde2=%f\n", rdE[1][1], rdE[100][100]); // printf("rde1=%f rde2=%f\n", rdE[1][1], rdE[100][100]);
@ -7639,7 +7634,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
bufmaskblurbl->b[ir][jr] = bufprov->b[ir][jr] + rdE[ir][jr] * delta->b[ir][jr]; bufmaskblurbl->b[ir][jr] = bufprov->b[ir][jr] + rdE[ir][jr] * delta->b[ir][jr];
} }
delete [] rdEBuffer; rdEBuffer.reset();
} }
@ -8668,10 +8663,10 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
bool tonecurv = false; bool tonecurv = false;
if(params->locallab.spots.at(sp).gamSH != 2.4 || params->locallab.spots.at(sp).sloSH != 12.92) { if (params->locallab.spots.at(sp).gamSH != 2.4 || params->locallab.spots.at(sp).sloSH != 12.92) {
tonecurv = true; tonecurv = true;
} }
if (! lp.invsh && (lp.highlihs > 0.f || lp.shadowhs > 0.f || tonequ || tonecurv || lp.showmaskSHmet == 2 || lp.enaSHMask || lp.showmaskSHmet == 3 || lp.showmaskSHmet == 4) && call < 3 && lp.hsena) { if (! lp.invsh && (lp.highlihs > 0.f || lp.shadowhs > 0.f || tonequ || tonecurv || lp.showmaskSHmet == 2 || lp.enaSHMask || lp.showmaskSHmet == 3 || lp.showmaskSHmet == 4) && call < 3 && lp.hsena) {
const int ystart = std::max(static_cast<int>(lp.yc - lp.lyT) - cy, 0); const int ystart = std::max(static_cast<int>(lp.yc - lp.lyT) - cy, 0);
const int yend = std::min(static_cast<int>(lp.yc + lp.ly) - cy, original->H); const int yend = std::min(static_cast<int>(lp.yc + lp.ly) - cy, original->H);
@ -8802,14 +8797,16 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
Imagefloat *tmpImage = nullptr; Imagefloat *tmpImage = nullptr;
tmpImage = new Imagefloat(bfw, bfh); tmpImage = new Imagefloat(bfw, bfh);
lab2rgb(*bufexpfin, *tmpImage, params->icm.workingProfile); lab2rgb(*bufexpfin, *tmpImage, params->icm.workingProfile);
if(tonecurv) {//Tone response curve : does nothing if gamma=2.4 and slope=12.92 ==> gamma sRGB
if (tonecurv) { //Tone response curve : does nothing if gamma=2.4 and slope=12.92 ==> gamma sRGB
float gamtone = params->locallab.spots.at(sp).gamSH; float gamtone = params->locallab.spots.at(sp).gamSH;
float slotone = params->locallab.spots.at(sp).sloSH; float slotone = params->locallab.spots.at(sp).sloSH;
cmsHTRANSFORM dummy = nullptr; cmsHTRANSFORM dummy = nullptr;
workingtrc(tmpImage, tmpImage, bfw, bfh, -5, params->icm.workingProfile, 2.4, 12.92310, dummy, true, false, false); workingtrc(tmpImage, tmpImage, bfw, bfh, -5, params->icm.workingProfile, 2.4, 12.92310, dummy, true, false, false);
workingtrc(tmpImage, tmpImage, bfw, bfh, 5, params->icm.workingProfile, gamtone, slotone, dummy, false, true, true); workingtrc(tmpImage, tmpImage, bfw, bfh, 5, params->icm.workingProfile, gamtone, slotone, dummy, false, true, true);
} }
if(tonequ) {
if (tonequ) {
tmpImage->normalizeFloatTo1(); tmpImage->normalizeFloatTo1();
array2D<float> Rtemp(bfw, bfh, tmpImage->r.ptrs, ARRAY2D_BYREFERENCE); array2D<float> Rtemp(bfw, bfh, tmpImage->r.ptrs, ARRAY2D_BYREFERENCE);
array2D<float> Gtemp(bfw, bfh, tmpImage->g.ptrs, ARRAY2D_BYREFERENCE); array2D<float> Gtemp(bfw, bfh, tmpImage->g.ptrs, ARRAY2D_BYREFERENCE);
@ -8817,6 +8814,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
tone_eq(Rtemp, Gtemp, Btemp, lp, params->icm.workingProfile, scal, multiThread); tone_eq(Rtemp, Gtemp, Btemp, lp, params->icm.workingProfile, scal, multiThread);
tmpImage->normalizeFloatTo65535(); tmpImage->normalizeFloatTo65535();
} }
rgb2lab(*tmpImage, *bufexpfin, params->icm.workingProfile); rgb2lab(*tmpImage, *bufexpfin, params->icm.workingProfile);
delete tmpImage; delete tmpImage;
@ -9800,13 +9798,8 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
const float refa = chromaref * cos(hueref); const float refa = chromaref * cos(hueref);
const float refb = chromaref * sin(hueref); const float refb = chromaref * sin(hueref);
std::unique_ptr<JaggedArray<float>> reducDEBuffer(new JaggedArray<float>(Wd, Hd));
float *reducDE[Hd] ALIGNED16; float** reducDE = *(reducDEBuffer.get());
float *reducDEBuffer = new float[Hd * Wd];
for (int i = 0; i < Hd; i++) {
reducDE[i] = &reducDEBuffer[i * Wd];
}
// float minreduc = 1000000.f; // float minreduc = 1000000.f;
// float maxreduc = -1000000.f; // float maxreduc = -1000000.f;
@ -9829,19 +9822,11 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
} }
// printf("reducdemax=%f reducmin=%f\n", maxreduc, minreduc); // printf("reducdemax=%f reducmin=%f\n", maxreduc, minreduc);
float *orig[Hd] ALIGNED16; std::unique_ptr<JaggedArray<float>> origBuffer(new JaggedArray<float>(Wd, Hd));
float *origBuffer = new float[Hd * Wd]; float** orig = *(origBuffer.get());
for (int i = 0; i < Hd; i++) { std::unique_ptr<JaggedArray<float>> origBuffer1(new JaggedArray<float>(Wd, Hd));
orig[i] = &origBuffer[i * Wd]; float** orig1 = *(origBuffer1.get());
}
float *orig1[Hd] ALIGNED16;
float *origBuffer1 = new float[Hd * Wd];
for (int i = 0; i < Hd; i++) {
orig1[i] = &origBuffer1[i * Wd];
}
@ -10145,9 +10130,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
} }
delete tmpl; delete tmpl;
delete [] reducDEBuffer; reducDEBuffer.reset();
delete [] origBuffer; origBuffer.reset();
delete [] origBuffer1; origBuffer1.reset();
if (bufmask) { if (bufmask) {
delete bufmask; delete bufmask;
@ -10332,14 +10317,8 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
const float refa = chromaref * cos(hueref); const float refa = chromaref * cos(hueref);
const float refb = chromaref * sin(hueref); const float refb = chromaref * sin(hueref);
std::unique_ptr<JaggedArray<float>> reducDEBuffer(new JaggedArray<float>(Wd, Hd));
float *reducDE[Hd] ALIGNED16; float** reducDE = *(reducDEBuffer.get());
float *reducDEBuffer = new float[Hd * Wd];
for (int i = 0; i < Hd; i++) {
reducDE[i] = &reducDEBuffer[i * Wd];
}
float ade = 0.01f * raddE; float ade = 0.01f * raddE;
float bde = 100.f - raddE; float bde = 100.f - raddE;
float sensibefore = ade * lp.sensh + bde;//we can change sensitivity 0.1 90 or 0.3 70 or 0.4 60 float sensibefore = ade * lp.sensh + bde;//we can change sensitivity 0.1 90 or 0.3 70 or 0.4 60
@ -10356,19 +10335,11 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
} }
float *orig[Hd] ALIGNED16; std::unique_ptr<JaggedArray<float>> origBuffer(new JaggedArray<float>(Wd, Hd));
float *origBuffer = new float[Hd * Wd]; float** orig = *(origBuffer.get());
for (int i = 0; i < Hd; i++) { std::unique_ptr<JaggedArray<float>> origBuffer1(new JaggedArray<float>(Wd, Hd));
orig[i] = &origBuffer[i * Wd]; float** orig1 = *(origBuffer1.get());
}
float *orig1[Hd] ALIGNED16;
float *origBuffer1 = new float[Hd * Wd];
for (int i = 0; i < Hd; i++) {
orig1[i] = &origBuffer1[i * Wd];
}
LabImage *tmpl = nullptr; LabImage *tmpl = nullptr;
@ -10684,9 +10655,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
} }
delete tmpl; delete tmpl;
delete [] reducDEBuffer; origBuffer.reset();
delete [] origBuffer; origBuffer1.reset();
delete [] origBuffer1; reducDEBuffer.reset();
if (bufmask) { if (bufmask) {
delete bufmask; delete bufmask;

View File

@ -248,8 +248,8 @@ Locallab::Locallab():
detailSH(Gtk::manage(new Adjuster(M("TP_LOCALLAB_DETAILSH"), -5, 5, 1, 0))), detailSH(Gtk::manage(new Adjuster(M("TP_LOCALLAB_DETAILSH"), -5, 5, 1, 0))),
fatamountSH(Gtk::manage(new Adjuster(M("TP_LOCALLAB_FATAMOUNT"), 1., 100., 1., 1.))), fatamountSH(Gtk::manage(new Adjuster(M("TP_LOCALLAB_FATAMOUNT"), 1., 100., 1., 1.))),
fatanchorSH(Gtk::manage(new Adjuster(M("TP_LOCALLAB_FATANCHOR"), 1., 100., 1., 50., Gtk::manage(new RTImage("circle-black-small.png")), Gtk::manage(new RTImage("circle-white-small.png"))))), fatanchorSH(Gtk::manage(new Adjuster(M("TP_LOCALLAB_FATANCHOR"), 1., 100., 1., 50., Gtk::manage(new RTImage("circle-black-small.png")), Gtk::manage(new RTImage("circle-white-small.png"))))),
gamSH(Gtk::manage(new Adjuster(M("TP_LOCALLAB_GAMSH"), 0.25, 8.0, 0.01, 2.4))), gamSH(Gtk::manage(new Adjuster(M("TP_LOCALLAB_GAMSH"), 0.25, 15.0, 0.01, 2.4))),
sloSH(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SLOSH"), 0.0, 30.0, 0.01, 12.92))), sloSH(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SLOSH"), 0.0, 100.0, 0.01, 12.92))),
// Vibrance // Vibrance
saturated(Gtk::manage(new Adjuster(M("TP_VIBRANCE_SATURATED"), -100., 100., 1., 0.))), saturated(Gtk::manage(new Adjuster(M("TP_VIBRANCE_SATURATED"), -100., 100., 1., 0.))),
pastels(Gtk::manage(new Adjuster(M("TP_VIBRANCE_PASTELS"), -100., 100., 1., 0.))), pastels(Gtk::manage(new Adjuster(M("TP_VIBRANCE_PASTELS"), -100., 100., 1., 0.))),