Merge pull request #3276 from Floessie/fix-haldclut-overrun
Fix buffer overrun when applying HaldCLUT (#3154)
This commit is contained in:
commit
678315672b
@ -4354,12 +4354,14 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
|||||||
if (hald_clut) {
|
if (hald_clut) {
|
||||||
float out_rgbx[4 * TS] ALIGNED16;
|
float out_rgbx[4 * TS] ALIGNED16;
|
||||||
|
|
||||||
|
|
||||||
for (int i = istart, ti = 0; i < tH; i++, ti++) {
|
for (int i = istart, ti = 0; i < tH; i++, ti++) {
|
||||||
if (!clutAndWorkingProfilesAreSame) {
|
if (!clutAndWorkingProfilesAreSame) {
|
||||||
// Convert from working to clut profile
|
// Convert from working to clut profile
|
||||||
|
int j = jstart;
|
||||||
|
int tj = 0;
|
||||||
#ifdef __SSE2__
|
#ifdef __SSE2__
|
||||||
if (!(std::min(TS, tW - jstart) & ~3)) {
|
for (; j < tW - 3; j += 4, tj += 4) {
|
||||||
for (int j = jstart, tj = 0; j < tW; j += 4, tj += 4) {
|
|
||||||
vfloat sourceR = LVF(rtemp[ti * TS + tj]);
|
vfloat sourceR = LVF(rtemp[ti * TS + tj]);
|
||||||
vfloat sourceG = LVF(gtemp[ti * TS + tj]);
|
vfloat sourceG = LVF(gtemp[ti * TS + tj]);
|
||||||
vfloat sourceB = LVF(btemp[ti * TS + tj]);
|
vfloat sourceB = LVF(btemp[ti * TS + tj]);
|
||||||
@ -4374,11 +4376,8 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
|||||||
STVF(gtemp[ti * TS + tj], sourceG);
|
STVF(gtemp[ti * TS + tj], sourceG);
|
||||||
STVF(btemp[ti * TS + tj], sourceB);
|
STVF(btemp[ti * TS + tj], sourceB);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
for (; j < tW; j++, tj++) {
|
||||||
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
|
|
||||||
float &sourceR = rtemp[ti * TS + tj];
|
float &sourceR = rtemp[ti * TS + tj];
|
||||||
float &sourceG = gtemp[ti * TS + tj];
|
float &sourceG = gtemp[ti * TS + tj];
|
||||||
float &sourceB = btemp[ti * TS + tj];
|
float &sourceB = btemp[ti * TS + tj];
|
||||||
@ -4388,7 +4387,6 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
|||||||
Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, xyz2clut);
|
Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, xyz2clut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
|
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
|
||||||
float &sourceR = rtemp[ti * TS + tj];
|
float &sourceR = rtemp[ti * TS + tj];
|
||||||
@ -4424,9 +4422,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
|||||||
|
|
||||||
if (!clutAndWorkingProfilesAreSame) {
|
if (!clutAndWorkingProfilesAreSame) {
|
||||||
// Convert from clut to working profile
|
// Convert from clut to working profile
|
||||||
|
int j = jstart;
|
||||||
|
int tj = 0;
|
||||||
#ifdef __SSE2__
|
#ifdef __SSE2__
|
||||||
if (!(std::min(TS, tW - jstart) & ~3)) {
|
for (; j < tW - 3; j += 4, tj += 4) {
|
||||||
for (int j = jstart, tj = 0; j < tW; j += 4, tj += 4) {
|
|
||||||
vfloat sourceR = LVF(rtemp[ti * TS + tj]);
|
vfloat sourceR = LVF(rtemp[ti * TS + tj]);
|
||||||
vfloat sourceG = LVF(gtemp[ti * TS + tj]);
|
vfloat sourceG = LVF(gtemp[ti * TS + tj]);
|
||||||
vfloat sourceB = LVF(btemp[ti * TS + tj]);
|
vfloat sourceB = LVF(btemp[ti * TS + tj]);
|
||||||
@ -4441,11 +4440,8 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
|||||||
STVF(gtemp[ti * TS + tj], sourceG);
|
STVF(gtemp[ti * TS + tj], sourceG);
|
||||||
STVF(btemp[ti * TS + tj], sourceB);
|
STVF(btemp[ti * TS + tj], sourceB);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
for (; j < tW; j++, tj++) {
|
||||||
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
|
|
||||||
float &sourceR = rtemp[ti * TS + tj];
|
float &sourceR = rtemp[ti * TS + tj];
|
||||||
float &sourceG = gtemp[ti * TS + tj];
|
float &sourceG = gtemp[ti * TS + tj];
|
||||||
float &sourceB = btemp[ti * TS + tj];
|
float &sourceB = btemp[ti * TS + tj];
|
||||||
@ -4457,7 +4453,6 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!blackwhite) {
|
if (!blackwhite) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user