Merge pull request #5034 from Beep6581/custom-trc-speedup
custom trc: speedup for preview and detail windows
This commit is contained in:
commit
1bfe03418e
@ -819,9 +819,9 @@ void Crop::update(int todo)
|
||||
const int ch = baseCrop->getHeight();
|
||||
workingCrop = new Imagefloat(cw, ch);
|
||||
//first put gamma TRC to 1
|
||||
parent->ipf.workingtrc(baseCrop, workingCrop, cw, ch, -5, params.icm.workingProfile, 2.4, 12.92310, true, false);
|
||||
parent->ipf.workingtrc(baseCrop, workingCrop, cw, ch, -5, params.icm.workingProfile, 2.4, 12.92310, parent->getCustomTransformIn(), true, false, true);
|
||||
//adjust gamma TRC
|
||||
parent->ipf.workingtrc(workingCrop, workingCrop, cw, ch, 5, params.icm.workingProfile, params.icm.workingTRCGamma, params.icm.workingTRCSlope, false, true);
|
||||
parent->ipf.workingtrc(workingCrop, workingCrop, cw, ch, 5, params.icm.workingProfile, params.icm.workingTRCGamma, params.icm.workingTRCSlope, parent->getCustomTransformOut(), false, true, true);
|
||||
}
|
||||
}
|
||||
double rrm, ggm, bbm;
|
||||
|
@ -94,7 +94,7 @@ ImProcCoordinator::ImProcCoordinator()
|
||||
pW(-1), pH(-1),
|
||||
plistener(nullptr), imageListener(nullptr), aeListener(nullptr), acListener(nullptr), abwListener(nullptr), awbListener(nullptr), flatFieldAutoClipListener(nullptr), bayerAutoContrastListener(nullptr), xtransAutoContrastListener(nullptr), frameCountListener(nullptr), imageTypeListener(nullptr), actListener(nullptr), adnListener(nullptr), awavListener(nullptr), dehaListener(nullptr), hListener(nullptr),
|
||||
resultValid(false), lastOutputProfile("BADFOOD"), lastOutputIntent(RI__COUNT), lastOutputBPC(false), thread(nullptr), changeSinceLast(0), updaterRunning(false), destroying(false), utili(false), autili(false),
|
||||
butili(false), ccutili(false), cclutili(false), clcutili(false), opautili(false), wavcontlutili(false), colourToningSatLimit(0.f), colourToningSatLimitOpacity(0.f), highQualityComputed(false)
|
||||
butili(false), ccutili(false), cclutili(false), clcutili(false), opautili(false), wavcontlutili(false), colourToningSatLimit(0.f), colourToningSatLimitOpacity(0.f), highQualityComputed(false), customTransformIn(nullptr), customTransformOut(nullptr)
|
||||
{}
|
||||
|
||||
void ImProcCoordinator::assign(ImageSource* imgsrc)
|
||||
@ -128,6 +128,17 @@ ImProcCoordinator::~ImProcCoordinator()
|
||||
}
|
||||
|
||||
imgsrc->decreaseRef();
|
||||
|
||||
if(customTransformIn) {
|
||||
cmsDeleteTransform(customTransformIn);
|
||||
customTransformIn = nullptr;
|
||||
}
|
||||
|
||||
if(customTransformOut) {
|
||||
cmsDeleteTransform(customTransformOut);
|
||||
customTransformOut = nullptr;
|
||||
}
|
||||
|
||||
updaterThreadStart.unlock();
|
||||
}
|
||||
|
||||
@ -516,9 +527,17 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
|
||||
const int cw = oprevi->getWidth();
|
||||
const int ch = oprevi->getHeight();
|
||||
// put gamma TRC to 1
|
||||
ipf.workingtrc(oprevi, oprevi, cw, ch, -5, params.icm.workingProfile, 2.4, 12.92310, true, false);
|
||||
if(customTransformIn) {
|
||||
cmsDeleteTransform(customTransformIn);
|
||||
customTransformIn = nullptr;
|
||||
}
|
||||
ipf.workingtrc(oprevi, oprevi, cw, ch, -5, params.icm.workingProfile, 2.4, 12.92310, customTransformIn, true, false, true);
|
||||
//adjust TRC
|
||||
ipf.workingtrc(oprevi, oprevi, cw, ch, 5, params.icm.workingProfile, params.icm.workingTRCGamma, params.icm.workingTRCSlope, false, true);
|
||||
if(customTransformOut) {
|
||||
cmsDeleteTransform(customTransformOut);
|
||||
customTransformOut = nullptr;
|
||||
}
|
||||
ipf.workingtrc(oprevi, oprevi, cw, ch, 5, params.icm.workingProfile, params.icm.workingTRCGamma, params.icm.workingTRCSlope, customTransformOut, false, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,8 @@ protected:
|
||||
float colourToningSatLimit;
|
||||
float colourToningSatLimitOpacity;
|
||||
bool highQualityComputed;
|
||||
|
||||
cmsHTRANSFORM customTransformIn;
|
||||
cmsHTRANSFORM customTransformOut;
|
||||
public:
|
||||
|
||||
ImProcCoordinator ();
|
||||
@ -373,6 +374,16 @@ public:
|
||||
return imgsrc;
|
||||
}
|
||||
|
||||
cmsHTRANSFORM& getCustomTransformIn ()
|
||||
{
|
||||
return customTransformIn;
|
||||
}
|
||||
|
||||
cmsHTRANSFORM& getCustomTransformOut ()
|
||||
{
|
||||
return customTransformOut;
|
||||
}
|
||||
|
||||
struct DenoiseInfoStore {
|
||||
DenoiseInfoStore () : chM (0), max_r{}, max_b{}, ch_M{}, valid (false) {}
|
||||
float chM;
|
||||
|
@ -350,7 +350,7 @@ public:
|
||||
Image8* lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool consider_histogram_settings = true);
|
||||
Imagefloat* lab2rgbOut(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm);
|
||||
// CieImage *ciec;
|
||||
void workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, int ch, int mul, const Glib::ustring &profile, double gampos, double slpos, bool normalizeIn = true, bool normalizeOut = true);
|
||||
void workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, int ch, int mul, const Glib::ustring &profile, double gampos, double slpos, cmsHTRANSFORM &transform, bool normalizeIn = true, bool normalizeOut = true, bool keepTransForm = false) const;
|
||||
|
||||
bool transCoord(int W, int H, int x, int y, int w, int h, int& xv, int& yv, int& wv, int& hv, double ascaleDef = -1, const LensCorrection *pLCPMap = nullptr);
|
||||
bool transCoord(int W, int H, const std::vector<Coord2D> &src, std::vector<Coord2D> &red, std::vector<Coord2D> &green, std::vector<Coord2D> &blue, double ascaleDef = -1, const LensCorrection *pLCPMap = nullptr);
|
||||
|
@ -357,7 +357,7 @@ Imagefloat* ImProcFunctions::lab2rgbOut(LabImage* lab, int cx, int cy, int cw, i
|
||||
}
|
||||
|
||||
|
||||
void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, int ch, int mul, const Glib::ustring &profile, double gampos, double slpos, bool normalizeIn, bool normalizeOut)
|
||||
void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, int ch, int mul, const Glib::ustring &profile, double gampos, double slpos, cmsHTRANSFORM &transform, bool normalizeIn, bool normalizeOut, bool keepTransForm) const
|
||||
{
|
||||
const TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix(params->icm.workingProfile);
|
||||
|
||||
@ -382,6 +382,11 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw,
|
||||
}
|
||||
};
|
||||
|
||||
cmsHTRANSFORM hTransform = nullptr;
|
||||
if (transform) {
|
||||
hTransform = transform;
|
||||
} else {
|
||||
|
||||
double pwr = 1.0 / gampos;
|
||||
double ts = slpos;
|
||||
int five = mul;
|
||||
@ -527,15 +532,17 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw,
|
||||
{p[4], p[5], 1.0} // blue
|
||||
};
|
||||
const cmsHPROFILE oprofdef = cmsCreateRGBProfile(&xyD, &Primaries, GammaTRC);
|
||||
|
||||
cmsFreeToneCurve(GammaTRC[0]);
|
||||
|
||||
if (oprofdef) {
|
||||
constexpr cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE;
|
||||
const cmsHPROFILE iprof = ICCStore::getInstance()->getXYZProfile();
|
||||
lcmsMutex->lock();
|
||||
const cmsHTRANSFORM hTransform = cmsCreateTransform(iprof, TYPE_RGB_FLT, oprofdef, TYPE_RGB_FLT, params->icm.outputIntent, flags);
|
||||
hTransform = cmsCreateTransform(iprof, TYPE_RGB_FLT, oprofdef, TYPE_RGB_FLT, params->icm.outputIntent, flags);
|
||||
lcmsMutex->unlock();
|
||||
}
|
||||
}
|
||||
if (hTransform) {
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel if (multiThread)
|
||||
#endif
|
||||
@ -567,8 +574,11 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!keepTransForm) {
|
||||
cmsDeleteTransform(hTransform);
|
||||
hTransform = nullptr;
|
||||
}
|
||||
transform = hTransform;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -898,10 +898,11 @@ private:
|
||||
if (profile == "sRGB" || profile == "Adobe RGB" || profile == "ProPhoto" || profile == "WideGamut" || profile == "BruceRGB" || profile == "Beta RGB" || profile == "BestRGB" || profile == "Rec2020" || profile == "ACESp0" || profile == "ACESp1") {
|
||||
const int cw = baseImg->getWidth();
|
||||
const int ch = baseImg->getHeight();
|
||||
cmsHTRANSFORM dummy = nullptr;
|
||||
// put gamma TRC to 1
|
||||
ipf.workingtrc(baseImg, baseImg, cw, ch, -5, params.icm.workingProfile, 2.4, 12.92310, true, false);
|
||||
ipf.workingtrc(baseImg, baseImg, cw, ch, -5, params.icm.workingProfile, 2.4, 12.92310, dummy, true, false, false);
|
||||
//adjust TRC
|
||||
ipf.workingtrc(baseImg, baseImg, cw, ch, 5, params.icm.workingProfile, params.icm.workingTRCGamma, params.icm.workingTRCSlope, false, true);
|
||||
ipf.workingtrc(baseImg, baseImg, cw, ch, 5, params.icm.workingProfile, params.icm.workingTRCGamma, params.icm.workingTRCSlope, dummy, false, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user