From 7dcccc223c7d73cf8f4e5b8a8df1bbdfff1ee33d Mon Sep 17 00:00:00 2001 From: Ingo Weyrich Date: Tue, 15 Sep 2020 13:19:51 +0200 Subject: [PATCH] Fix performance issue when using working profile for histogram, #5891 --- rtengine/iplab2rgb.cc | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/rtengine/iplab2rgb.cc b/rtengine/iplab2rgb.cc index 0549995dd..af7c454a3 100644 --- a/rtengine/iplab2rgb.cc +++ b/rtengine/iplab2rgb.cc @@ -172,11 +172,10 @@ Image8* ImProcFunctions::lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, Image8* image = new Image8(cw, ch); Glib::ustring profile; - bool standard_gamma; + cmsHPROFILE oprof = nullptr; if (settings->HistogramWorking && consider_histogram_settings) { profile = icm.workingProfile; - standard_gamma = true; } else { profile = icm.outputProfile; @@ -184,27 +183,15 @@ Image8* ImProcFunctions::lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, profile = "sRGB"; } - standard_gamma = false; + oprof = ICCStore::getInstance()->getProfile(profile); } - cmsHPROFILE oprof = ICCStore::getInstance()->getProfile(profile); - if (oprof) { - cmsHPROFILE oprofG = oprof; - - if (standard_gamma) { - oprofG = ICCStore::makeStdGammaProfile(oprof); - } - - cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE; - - if (icm.outputBPC) { - flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; - } + const cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE | (icm.outputBPC ? cmsFLAGS_BLACKPOINTCOMPENSATION : 0); // NOCACHE is important for thread safety lcmsMutex->lock(); 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); lcmsMutex->unlock(); @@ -245,9 +232,6 @@ Image8* ImProcFunctions::lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, cmsDeleteTransform(hTransform); - if (oprofG != oprof) { - cmsCloseProfile(oprofG); - } } else { const auto xyz_rgb = ICCStore::getInstance()->workingSpaceInverseMatrix(profile); copyAndClamp(lab, image->data, xyz_rgb, multiThread);