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();
|
const int ch = baseCrop->getHeight();
|
||||||
workingCrop = new Imagefloat(cw, ch);
|
workingCrop = new Imagefloat(cw, ch);
|
||||||
//first put gamma TRC to 1
|
//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
|
//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;
|
double rrm, ggm, bbm;
|
||||||
|
@ -94,7 +94,7 @@ ImProcCoordinator::ImProcCoordinator()
|
|||||||
pW(-1), pH(-1),
|
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),
|
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),
|
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)
|
void ImProcCoordinator::assign(ImageSource* imgsrc)
|
||||||
@ -128,6 +128,17 @@ ImProcCoordinator::~ImProcCoordinator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
imgsrc->decreaseRef();
|
imgsrc->decreaseRef();
|
||||||
|
|
||||||
|
if(customTransformIn) {
|
||||||
|
cmsDeleteTransform(customTransformIn);
|
||||||
|
customTransformIn = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(customTransformOut) {
|
||||||
|
cmsDeleteTransform(customTransformOut);
|
||||||
|
customTransformOut = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
updaterThreadStart.unlock();
|
updaterThreadStart.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,9 +527,17 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
|
|||||||
const int cw = oprevi->getWidth();
|
const int cw = oprevi->getWidth();
|
||||||
const int ch = oprevi->getHeight();
|
const int ch = oprevi->getHeight();
|
||||||
// put gamma TRC to 1
|
// 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
|
//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 colourToningSatLimit;
|
||||||
float colourToningSatLimitOpacity;
|
float colourToningSatLimitOpacity;
|
||||||
bool highQualityComputed;
|
bool highQualityComputed;
|
||||||
|
cmsHTRANSFORM customTransformIn;
|
||||||
|
cmsHTRANSFORM customTransformOut;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ImProcCoordinator ();
|
ImProcCoordinator ();
|
||||||
@ -373,6 +374,16 @@ public:
|
|||||||
return imgsrc;
|
return imgsrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmsHTRANSFORM& getCustomTransformIn ()
|
||||||
|
{
|
||||||
|
return customTransformIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmsHTRANSFORM& getCustomTransformOut ()
|
||||||
|
{
|
||||||
|
return customTransformOut;
|
||||||
|
}
|
||||||
|
|
||||||
struct DenoiseInfoStore {
|
struct DenoiseInfoStore {
|
||||||
DenoiseInfoStore () : chM (0), max_r{}, max_b{}, ch_M{}, valid (false) {}
|
DenoiseInfoStore () : chM (0), max_r{}, max_b{}, ch_M{}, valid (false) {}
|
||||||
float chM;
|
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);
|
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);
|
Imagefloat* lab2rgbOut(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm);
|
||||||
// CieImage *ciec;
|
// 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, 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);
|
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);
|
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 pwr = 1.0 / gampos;
|
||||||
double ts = slpos;
|
double ts = slpos;
|
||||||
int five = mul;
|
int five = mul;
|
||||||
@ -527,15 +532,17 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw,
|
|||||||
{p[4], p[5], 1.0} // blue
|
{p[4], p[5], 1.0} // blue
|
||||||
};
|
};
|
||||||
const cmsHPROFILE oprofdef = cmsCreateRGBProfile(&xyD, &Primaries, GammaTRC);
|
const cmsHPROFILE oprofdef = cmsCreateRGBProfile(&xyD, &Primaries, GammaTRC);
|
||||||
|
|
||||||
cmsFreeToneCurve(GammaTRC[0]);
|
cmsFreeToneCurve(GammaTRC[0]);
|
||||||
|
|
||||||
if (oprofdef) {
|
if (oprofdef) {
|
||||||
constexpr cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE;
|
constexpr cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE;
|
||||||
const cmsHPROFILE iprof = ICCStore::getInstance()->getXYZProfile();
|
const cmsHPROFILE iprof = ICCStore::getInstance()->getXYZProfile();
|
||||||
lcmsMutex->lock();
|
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();
|
lcmsMutex->unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hTransform) {
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel if (multiThread)
|
#pragma omp parallel if (multiThread)
|
||||||
#endif
|
#endif
|
||||||
@ -567,8 +574,11 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!keepTransForm) {
|
||||||
cmsDeleteTransform(hTransform);
|
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") {
|
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 cw = baseImg->getWidth();
|
||||||
const int ch = baseImg->getHeight();
|
const int ch = baseImg->getHeight();
|
||||||
|
cmsHTRANSFORM dummy = nullptr;
|
||||||
// put gamma TRC to 1
|
// 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
|
//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