Fix performance issue when using working profile for histogram, #5891
This commit is contained in:
parent
49937a589f
commit
7dcccc223c
@ -172,11 +172,10 @@ Image8* ImProcFunctions::lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch,
|
|||||||
Image8* image = new Image8(cw, ch);
|
Image8* image = new Image8(cw, ch);
|
||||||
Glib::ustring profile;
|
Glib::ustring profile;
|
||||||
|
|
||||||
bool standard_gamma;
|
cmsHPROFILE oprof = nullptr;
|
||||||
|
|
||||||
if (settings->HistogramWorking && consider_histogram_settings) {
|
if (settings->HistogramWorking && consider_histogram_settings) {
|
||||||
profile = icm.workingProfile;
|
profile = icm.workingProfile;
|
||||||
standard_gamma = true;
|
|
||||||
} else {
|
} else {
|
||||||
profile = icm.outputProfile;
|
profile = icm.outputProfile;
|
||||||
|
|
||||||
@ -184,27 +183,15 @@ Image8* ImProcFunctions::lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch,
|
|||||||
profile = "sRGB";
|
profile = "sRGB";
|
||||||
}
|
}
|
||||||
|
|
||||||
standard_gamma = false;
|
oprof = ICCStore::getInstance()->getProfile(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmsHPROFILE oprof = ICCStore::getInstance()->getProfile(profile);
|
|
||||||
|
|
||||||
if (oprof) {
|
if (oprof) {
|
||||||
cmsHPROFILE oprofG = oprof;
|
const cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE | (icm.outputBPC ? cmsFLAGS_BLACKPOINTCOMPENSATION : 0); // NOCACHE is important for thread safety
|
||||||
|
|
||||||
if (standard_gamma) {
|
|
||||||
oprofG = ICCStore::makeStdGammaProfile(oprof);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE;
|
|
||||||
|
|
||||||
if (icm.outputBPC) {
|
|
||||||
flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
lcmsMutex->lock();
|
lcmsMutex->lock();
|
||||||
cmsHPROFILE LabIProf = cmsCreateLab4Profile(nullptr);
|
cmsHPROFILE LabIProf = cmsCreateLab4Profile(nullptr);
|
||||||
cmsHTRANSFORM hTransform = cmsCreateTransform (LabIProf, TYPE_Lab_DBL, oprofG, TYPE_RGB_FLT, icm.outputIntent, flags); // NOCACHE is important for thread safety
|
cmsHTRANSFORM hTransform = cmsCreateTransform (LabIProf, TYPE_Lab_DBL, oprof, TYPE_RGB_FLT, icm.outputIntent, flags);
|
||||||
cmsCloseProfile(LabIProf);
|
cmsCloseProfile(LabIProf);
|
||||||
lcmsMutex->unlock();
|
lcmsMutex->unlock();
|
||||||
|
|
||||||
@ -245,9 +232,6 @@ Image8* ImProcFunctions::lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch,
|
|||||||
|
|
||||||
cmsDeleteTransform(hTransform);
|
cmsDeleteTransform(hTransform);
|
||||||
|
|
||||||
if (oprofG != oprof) {
|
|
||||||
cmsCloseProfile(oprofG);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const auto xyz_rgb = ICCStore::getInstance()->workingSpaceInverseMatrix(profile);
|
const auto xyz_rgb = ICCStore::getInstance()->workingSpaceInverseMatrix(profile);
|
||||||
copyAndClamp(lab, image->data, xyz_rgb, multiThread);
|
copyAndClamp(lab, image->data, xyz_rgb, multiThread);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user