diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 28188b0f6..779f2b33d 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -68,7 +68,7 @@ public: pl(pl), flush(flush), // internal state - ii(nullptr), + initialImage(nullptr), imgsrc(nullptr), fw(0), fh(0), @@ -97,6 +97,7 @@ public: hlcomprthresh(0), baseImg(nullptr), labView(nullptr), + ctColorCurve(), autili(false), butili(false) { @@ -150,10 +151,10 @@ private: pl->setProgress(0.0); } - ii = job->initialImage; + initialImage = job->initialImage; - if (!ii) { - ii = InitialImage::load(job->fname, job->isRaw, &errorCode); + if (!initialImage) { + initialImage = InitialImage::load(job->fname, job->isRaw, &errorCode); if (errorCode) { delete job; @@ -164,7 +165,7 @@ private: procparams::ProcParams& params = job->pparams; // acquire image from imagesource - imgsrc = ii->getImageSource(); + imgsrc = initialImage->getImageSource(); tr = getCoarseBitMask(params.coarse); @@ -245,7 +246,6 @@ private: if (params.retinex.enabled) { //enabled Retinex LUTf cdcurve(65536, 0); LUTf mapcurve(65536, 0); - LUTu dummy; RetinextransmissionCurve dehatransmissionCurve; RetinexgaintransmissionCurve dehagaintransmissionCurve; bool dehacontlutili = false; @@ -921,11 +921,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; + cmsHTRANSFORM dummyTransForm = nullptr; // put gamma TRC to 1 - ipf.workingtrc(baseImg, baseImg, cw, ch, -5, params.icm.workingProfile, 2.4, 12.92310, dummy, true, false, false); + ipf.workingtrc(baseImg, baseImg, cw, ch, -5, params.icm.workingProfile, 2.4, 12.92310, dummyTransForm, true, false, false); //adjust TRC - ipf.workingtrc(baseImg, baseImg, cw, ch, 5, params.icm.workingProfile, params.icm.workingTRCGamma, params.icm.workingTRCSlope, dummy, false, true, false); + ipf.workingtrc(baseImg, baseImg, cw, ch, 5, params.icm.workingProfile, params.icm.workingTRCGamma, params.icm.workingTRCSlope, dummyTransForm, false, true, false); } } @@ -1155,9 +1155,7 @@ private: ipf.ip_wavelet(labView, labView, 2, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, 1); unshar->CopyFrom(labView); params.wavelet.CLmethod = provis; - } - if ((WaveParams.ushamethod == "sharp" || WaveParams.ushamethod == "clari") && WaveParams.expclari && WaveParams.CLmethod != "all") { WaveParams.expcontrast = false; WaveParams.expchroma = false; WaveParams.expedge = false; @@ -1402,9 +1400,6 @@ private: } } - cmsHPROFILE jprof = nullptr; - constexpr bool customGamma = false; - constexpr bool useLCMS = false; bool bwonly = params.blackwhite.enabled && !params.colorToning.enabled && !autili && !butili && !params.colorappearance.enabled; ///////////// Custom output gamma has been removed, the user now has to create @@ -1453,12 +1448,12 @@ private: case MetaDataParams::TUNNEL: // Sending back the whole first root, which won't necessarily be the selected frame number // and may contain subframe depending on initial raw's hierarchy - readyImg->setMetadata(ii->getMetaData()->getRootExifData()); + readyImg->setMetadata(initialImage->getMetaData()->getRootExifData()); break; case MetaDataParams::EDIT: // ask for the correct frame number, but may contain subframe depending on initial raw's hierarchy - readyImg->setMetadata(ii->getMetaData()->getBestExifData(imgsrc, ¶ms.raw), params.exif, params.iptc); + readyImg->setMetadata(initialImage->getMetaData()->getBestExifData(imgsrc, ¶ms.raw), params.exif, params.iptc); break; default: // case MetaDataParams::STRIP @@ -1468,36 +1463,28 @@ private: // Setting the output curve to readyImg - if (customGamma) { - if (!useLCMS) { - // use corrected sRGB profile in order to apply a good TRC if present, otherwise use LCMS2 profile generated by lab2rgb16 w/ gamma - ProfileContent pc(jprof); + // use the selected output profile if present, otherwise use LCMS2 profile generate by lab2rgb16 w/ gamma + + if (!params.icm.outputProfile.empty() && params.icm.outputProfile != ColorManagementParams::NoICMString) { + + // if ICCStore::getInstance()->getProfile send back an object, then ICCStore::getInstance()->getContent will do too + cmsHPROFILE jprof = ICCStore::getInstance()->getProfile(params.icm.outputProfile); //get outProfile + + if (jprof == nullptr) { + if (settings->verbose) { + printf("\"%s\" ICC output profile not found!\n - use LCMS2 substitution\n", params.icm.outputProfile.c_str()); + } + } else { + if (settings->verbose) { + printf("Using \"%s\" output profile\n", params.icm.outputProfile.c_str()); + } + + ProfileContent pc = ICCStore::getInstance()->getContent(params.icm.outputProfile); readyImg->setOutputProfile(pc.getData().c_str(), pc.getData().size()); } } else { - // use the selected output profile if present, otherwise use LCMS2 profile generate by lab2rgb16 w/ gamma - - if (!params.icm.outputProfile.empty() && params.icm.outputProfile != ColorManagementParams::NoICMString) { - - // if ICCStore::getInstance()->getProfile send back an object, then ICCStore::getInstance()->getContent will do too - cmsHPROFILE jprof = ICCStore::getInstance()->getProfile(params.icm.outputProfile); //get outProfile - - if (jprof == nullptr) { - if (settings->verbose) { - printf("\"%s\" ICC output profile not found!\n - use LCMS2 substitution\n", params.icm.outputProfile.c_str()); - } - } else { - if (settings->verbose) { - printf("Using \"%s\" output profile\n", params.icm.outputProfile.c_str()); - } - - ProfileContent pc = ICCStore::getInstance()->getContent(params.icm.outputProfile); - readyImg->setOutputProfile(pc.getData().c_str(), pc.getData().size()); - } - } else { - // No ICM - readyImg->setOutputProfile(nullptr, 0); - } + // No ICM + readyImg->setOutputProfile(nullptr, 0); } // t2.set(); @@ -1505,7 +1492,7 @@ private: // printf("Total:- %d usec\n", t2.etime(t1)); if (!job->initialImage) { - ii->decreaseRef(); + initialImage->decreaseRef(); } delete job; @@ -1669,7 +1656,7 @@ private: // internal state std::unique_ptr ipf_p; - InitialImage *ii; + InitialImage *initialImage; ImageSource *imgsrc; int fw; int fh;