diff --git a/rtengine/colortemp.cc b/rtengine/colortemp.cc index 2ccbcba8d..c99e4bd41 100644 --- a/rtengine/colortemp.cc +++ b/rtengine/colortemp.cc @@ -70,7 +70,7 @@ static const double cie_colour_match_jd[97][3] = {//350nm to 830nm 5 nm J.Desm {0.000001251141, 0.00000045181, 0.000000} }; -ColorTemp::ColorTemp (double t, double g, double e, Glib::ustring m) : temp(t), green(g), equal(e), method(m) +ColorTemp::ColorTemp (double t, double g, double e, const Glib::ustring &m) : temp(t), green(g), equal(e), method(m) { clip (temp, green, equal); @@ -120,7 +120,7 @@ ColorTemp::ColorTemp (double mulr, double mulg, double mulb, double e) : equal(e mul2temp (mulr, mulg, mulb, equal, temp, green); } -void ColorTemp::mul2temp (const double rmul, const double gmul, const double bmul, const double equal, double& temp, double& green) +void ColorTemp::mul2temp (const double rmul, const double gmul, const double bmul, const double equal, double& temp, double& green) const { double maxtemp = double(MAXTEMP), mintemp = double(MINTEMP); @@ -849,7 +849,7 @@ const double ColorTemp::ColabSky42_0_m24_spect[97] = { /* LERP(a,b,c) = linear interpolation macro, is 'a' when c == 0.0 and 'b' when c == 1.0 */ #define LERP(a,b,c) (((b) - (a)) * (c) + (a)) -int ColorTemp::XYZtoCorColorTemp(double x0, double y0, double z0, double &temp) +int ColorTemp::XYZtoCorColorTemp(double x0, double y0, double z0, double &temp) const { typedef struct UVT { @@ -1128,7 +1128,7 @@ void ColorTemp::temp2mulxyz (double tem, double gree, std::string method , doubl //printf("Xxyz=%f Zxyz=%f\n",Xxyz,Zxyz); } -void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double& gmul, double& bmul) +void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double& gmul, double& bmul) const { clip (temp, green, equal); diff --git a/rtengine/colortemp.h b/rtengine/colortemp.h index c79ebb4bf..a1a805092 100644 --- a/rtengine/colortemp.h +++ b/rtengine/colortemp.h @@ -47,12 +47,14 @@ private: std::string method; static void clip (double &temp, double &green); static void clip (double &temp, double &green, double &equal); + int XYZtoCorColorTemp(double x0, double y0 , double z0, double &temp) const; + void temp2mul (double temp, double green, double equal, double& rmul, double& gmul, double& bmul) const; public: ColorTemp () : temp(-1.), green(-1.), equal (1.), method("Custom") {} ColorTemp (double e) : temp(-1.), green(-1.), equal (e), method("Custom") {} - ColorTemp (double t, double g, double e, Glib::ustring m); + ColorTemp (double t, double g, double e, const Glib::ustring &m); ColorTemp (double mulr, double mulg, double mulb, double e); void update (const double rmul, const double gmul, const double bmul, const double equal) @@ -67,42 +69,40 @@ public: this->equal = equal; } - inline std::string getMethod() + inline std::string getMethod() const { return method; } - inline double getTemp () + inline double getTemp () const { return temp; } - inline double getGreen () + inline double getGreen () const { return green; } - inline double getEqual () + inline double getEqual () const { return equal; } - void getMultipliers (double &mulr, double &mulg, double &mulb) + void getMultipliers (double &mulr, double &mulg, double &mulb) const { temp2mul (temp, green, equal, mulr, mulg, mulb); } - void mul2temp (const double rmul, const double gmul, const double bmul, const double equal, double& temp, double& green); - void temp2mul (double temp, double green, double equal, double& rmul, double& gmul, double& bmul); + void mul2temp (const double rmul, const double gmul, const double bmul, const double equal, double& temp, double& green) const; static void temp2mulxyz (double tem, double gree, std::string method, double &Xxyz, double &Zxyz); - int XYZtoCorColorTemp(double x0, double y0 , double z0, double &temp); static void cieCAT02(double Xw, double Yw, double Zw, double &CAM02BB00, double &CAM02BB01, double &CAM02BB02, double &CAM02BB10, double &CAM02BB11, double &CAM02BB12, double &CAM02BB20, double &CAM02BB21, double &CAM02BB22, double adap ); //static void CAT02 (Imagefloat* baseImg, const ProcParams* params); //static void ciecam_02 (LabImage* lab, const ProcParams* params); - bool operator== (const ColorTemp& other) + bool operator== (const ColorTemp& other) const { return fabs(temp - other.temp) < 1e-10 && fabs(green - other.green) < 1e-10; } - bool operator!= (const ColorTemp& other) + bool operator!= (const ColorTemp& other) const { return !(*this == other); } diff --git a/rtengine/dcp.cc b/rtengine/dcp.cc index 8e6ce6728..89eec3773 100644 --- a/rtengine/dcp.cc +++ b/rtengine/dcp.cc @@ -542,7 +542,7 @@ static double calibrationIlluminantToTemperature(int light) return 0.0; } } -void DCPProfile::MakeXYZCAM(ColorTemp &wb, double pre_mul[3], double camWbMatrix[3][3], int preferredIlluminant, double (*mXYZCAM)[3]) const +void DCPProfile::MakeXYZCAM(const ColorTemp &wb, double pre_mul[3], double camWbMatrix[3][3], int preferredIlluminant, double (*mXYZCAM)[3]) const { // code adapted from dng_color_spec::FindXYZtoCamera // note that we do not support monochrome or colorplanes > 3 (no reductionMatrix support) @@ -742,7 +742,7 @@ void DCPProfile::MakeXYZCAM(ColorTemp &wb, double pre_mul[3], double camWbMatrix } } -const DCPProfile::HSBModify* DCPProfile::MakeHueSatMap(ColorTemp &wb, int preferredIlluminant, HSBModify **deleteHandle) const +const DCPProfile::HSBModify* DCPProfile::MakeHueSatMap(const ColorTemp &wb, int preferredIlluminant, HSBModify **deleteHandle) const { *deleteHandle = NULL; @@ -813,7 +813,7 @@ const DCPProfile::HSBModify* DCPProfile::MakeHueSatMap(ColorTemp &wb, int prefer return aDeltas; } -DCPProfile::DCPProfile(Glib::ustring fname) +DCPProfile::DCPProfile(const Glib::ustring &fname) { const int TIFFFloatSize = 4; const int TagColorMatrix1 = 50721, TagColorMatrix2 = 50722, TagProfileHueSatMapDims = 50937; @@ -1433,7 +1433,7 @@ void DCPProfile::dngref_NeutralToXY(double neutral[3], int preferredIlluminant, XY[1] = lastXY[1]; } -void DCPProfile::Apply(Imagefloat *pImg, int preferredIlluminant, Glib::ustring workingSpace, ColorTemp &wb, double pre_mul[3], double camWbMatrix[3][3], bool useToneCurve, bool applyHueSatMap, bool applyLookTable) const +void DCPProfile::Apply(Imagefloat *pImg, int preferredIlluminant, const Glib::ustring &workingSpace, const ColorTemp &wb, double pre_mul[3], double camWbMatrix[3][3], bool useToneCurve, bool applyHueSatMap, bool applyLookTable) const { TMatrix mWork = iccStore->workingSpaceInverseMatrix (workingSpace); @@ -1551,7 +1551,7 @@ void DCPProfile::Apply(Imagefloat *pImg, int preferredIlluminant, Glib::ustring } } -void DCPProfile::setStep2ApplyState(Glib::ustring workingSpace, bool useToneCurve, bool applyLookTable, bool applyBaselineExposure) +void DCPProfile::setStep2ApplyState(const Glib::ustring &workingSpace, bool useToneCurve, bool applyLookTable, bool applyBaselineExposure) { applyState.useToneCurve = useToneCurve; @@ -1695,18 +1695,16 @@ DCPStore* DCPStore::getInstance() } // Reads all profiles from the given profiles dir -void DCPStore::init (Glib::ustring rtProfileDir) +void DCPStore::init (const Glib::ustring &rtProfileDir) { MyMutex::MyLock lock(mtx); fileStdProfiles.clear(); - Glib::ustring rootDirName = rtProfileDir; - - if (rootDirName != "") { + if (rtProfileDir != "") { std::deque qDirs; - qDirs.push_front(rootDirName); + qDirs.push_front(rtProfileDir); while (!qDirs.empty()) { // process directory @@ -1749,7 +1747,7 @@ void DCPStore::init (Glib::ustring rtProfileDir) } } -DCPProfile* DCPStore::getProfile (Glib::ustring filename) +DCPProfile* DCPStore::getProfile (const Glib::ustring &filename) { MyMutex::MyLock lock(mtx); @@ -1765,7 +1763,7 @@ DCPProfile* DCPStore::getProfile (Glib::ustring filename) return profileCache[filename]; } -DCPProfile* DCPStore::getStdProfile(Glib::ustring camShortName) +DCPProfile* DCPStore::getStdProfile(const Glib::ustring &camShortName) { Glib::ustring name2 = camShortName.uppercase(); @@ -1778,7 +1776,7 @@ DCPProfile* DCPStore::getStdProfile(Glib::ustring camShortName) return NULL; } -bool DCPStore::isValidDCPFileName(Glib::ustring filename) const +bool DCPStore::isValidDCPFileName(const Glib::ustring &filename) const { if (!Glib::file_test (filename, Glib::FILE_TEST_EXISTS) || Glib::file_test (filename, Glib::FILE_TEST_IS_DIR)) { return false; diff --git a/rtengine/dcp.h b/rtengine/dcp.h index 7a960edc9..f20f3543c 100644 --- a/rtengine/dcp.h +++ b/rtengine/dcp.h @@ -26,7 +26,7 @@ #include "../rtgui/threadutils.h" #include #include -#include +//#include namespace rtengine { @@ -71,39 +71,39 @@ class DCPProfile void dngref_XYCoord2Temperature(const double whiteXY[2], double *temp, double *tint) const; void dngref_FindXYZtoCamera(const double whiteXY[2], int preferredIlluminant, double (*xyzToCamera)[3]) const; void dngref_NeutralToXY(double neutral[3], int preferredIlluminant, double XY[2]) const; - void MakeXYZCAM(ColorTemp &wb, double pre_mul[3], double camWbMatrix[3][3], int preferredIlluminant, double (*mXYZCAM)[3]) const; - const HSBModify* MakeHueSatMap(ColorTemp &wb, int preferredIlluminant, HSBModify **deleteHandle) const; + void MakeXYZCAM(const ColorTemp &wb, double pre_mul[3], double camWbMatrix[3][3], int preferredIlluminant, double (*mXYZCAM)[3]) const; + const HSBModify* MakeHueSatMap(const ColorTemp &wb, int preferredIlluminant, HSBModify **deleteHandle) const; void HSDApply(const HSDTableInfo &ti, const HSBModify *tableBase, float &h, float &s, float &v) const; public: - DCPProfile(Glib::ustring fname); + DCPProfile(const Glib::ustring &fname); ~DCPProfile(); - bool getHasToneCurve() + bool getHasToneCurve() const { return hasToneCurve; } - bool getHasLookTable() + bool getHasLookTable() const { return !!aLookTable; } - bool getHasHueSatMap() + bool getHasHueSatMap() const { return !!aDeltas1; } - bool getHasBaselineExposureOffset() + bool getHasBaselineExposureOffset() const { return hasBaselineExposureOffset; } - void getIlluminants(int &i1, double &temp1, int &i2, double &temp2, bool &willInterpolate_) + void getIlluminants(int &i1, double &temp1, int &i2, double &temp2, bool &willInterpolate_) const { i1 = iLightSource1; i2 = iLightSource2; temp1 = temperature1, temp2 = temperature2; willInterpolate_ = willInterpolate; }; - void Apply(Imagefloat *pImg, int preferredIlluminant, Glib::ustring workingSpace, ColorTemp &wb, double pre_mul[3], double camMatrix[3][3], bool useToneCurve = false, bool applyHueSatMap = true, bool applyLookTable = false) const; - void setStep2ApplyState(Glib::ustring workingSpace, bool useToneCurve, bool applyLookTable, bool applyBaselineExposure); + void Apply(Imagefloat *pImg, int preferredIlluminant, const Glib::ustring &workingSpace, const ColorTemp &wb, double pre_mul[3], double camMatrix[3][3], bool useToneCurve = false, bool applyHueSatMap = true, bool applyLookTable = false) const; + void setStep2ApplyState(const Glib::ustring &workingSpace, bool useToneCurve, bool applyLookTable, bool applyBaselineExposure); void step2ApplyTile(float *r, float *g, float *b, int width, int height, int tileWidth) const; }; @@ -118,12 +118,12 @@ class DCPStore std::map profileCache; public: - void init(Glib::ustring rtProfileDir); + void init(const Glib::ustring &rtProfileDir); - bool isValidDCPFileName(Glib::ustring filename) const; + bool isValidDCPFileName(const Glib::ustring &filename) const; - DCPProfile* getProfile(Glib::ustring filename); - DCPProfile* getStdProfile(Glib::ustring camShortName); + DCPProfile* getProfile(const Glib::ustring &filename); + DCPProfile* getStdProfile(const Glib::ustring &camShortName); static DCPStore* getInstance(); }; diff --git a/rtengine/iimage.h b/rtengine/iimage.h index 4b0450e54..e7dd5865d 100644 --- a/rtengine/iimage.h +++ b/rtengine/iimage.h @@ -1010,9 +1010,6 @@ public: avg_r += double(r_); avg_g += double(g_); avg_b += double(b_); - /*avg_r += intpow( (double)r(i, j), p); - avg_g += intpow( (double)g(i, j), p); - avg_b += intpow( (double)b(i, j), p);*/ n++; } @@ -1616,9 +1613,6 @@ public: avg_r += double(r_); avg_g += double(g_); avg_b += double(b_); - /*avg_r += intpow( (double)r(i, j), p); - avg_g += intpow( (double)g(i, j), p); - avg_b += intpow( (double)b(i, j), p);*/ n++; } diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index 80fc53f23..79389f24c 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -66,7 +66,7 @@ public: embProfile(NULL), idata(NULL), dirpyrdenoiseExpComp(INFINITY) {} virtual ~ImageSource () {} - virtual int load (Glib::ustring fname, bool batch = false) = 0; + virtual int load (const Glib::ustring &fname, bool batch = false) = 0; virtual void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse) {}; virtual void demosaic (const RAWParams &raw) {}; virtual void retinex (ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI) {}; @@ -78,10 +78,10 @@ public: virtual void HLRecovery_inpaint (float** red, float** green, float** blue) {}; virtual void MSR(LabImage* lab, LUTf & mapcurve, bool &mapcontlutili, int width, int height, int skip, RetinexParams deh, const RetinextransmissionCurve & dehatransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) {}; - virtual bool IsrgbSourceModified() = 0; // tracks whether cached rgb output of demosaic has been modified + virtual bool IsrgbSourceModified() const = 0; // tracks whether cached rgb output of demosaic has been modified // use right after demosaicing image, add coarse transformation and put the result in the provided Imagefloat* - virtual void getImage (ColorTemp ctemp, int tran, Imagefloat* image, PreviewProps pp, ToneCurveParams hlp, ColorManagementParams cmp, RAWParams raw) {} + virtual void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hlp, const ColorManagementParams &cmp, const RAWParams &raw) = 0; virtual eSensorType getSensorType () { return ST_NONE; @@ -89,12 +89,12 @@ public: // true is ready to provide the AutoWB, i.e. when the image has been demosaiced for RawImageSource virtual bool isWBProviderReady () = 0; - virtual void convertColorSpace (Imagefloat* image, ColorManagementParams cmp, ColorTemp &wb) = 0; // DIRTY HACK: this method is derived in rawimagesource and strimagesource, but (...,RAWParams raw) will be used ONLY for raw images + virtual void convertColorSpace (Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb) = 0; // DIRTY HACK: this method is derived in rawimagesource and strimagesource, but (...,RAWParams raw) will be used ONLY for raw images virtual void getAutoWBMultipliers (double &rm, double &gm, double &bm) = 0; - virtual ColorTemp getWB () = 0; + virtual ColorTemp getWB () const = 0; virtual ColorTemp getSpotWB (std::vector &red, std::vector &green, std::vector &blue, int tran, double equal) = 0; - virtual double getDefGain () + virtual double getDefGain () const { return 1.0; } diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index d3b12adcd..d954e5edc 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -19,7 +19,7 @@ #include #include "procparams.h" #include "rt_math.h" -#include "dcp.h" +#include "curves.h" #include "../rtgui/multilangmgr.h" #include "../rtgui/version.h" #include "../rtgui/ppversion.h" @@ -1251,7 +1251,7 @@ void ProcParams::setDefaults () ppVersion = PPVERSION; } -static Glib::ustring expandRelativePath(Glib::ustring procparams_fname, Glib::ustring prefix, Glib::ustring embedded_fname) +static Glib::ustring expandRelativePath(const Glib::ustring &procparams_fname, const Glib::ustring &prefix, Glib::ustring embedded_fname) { if (embedded_fname == "" || !Glib::path_is_absolute(procparams_fname)) { return embedded_fname; @@ -1273,7 +1273,7 @@ static Glib::ustring expandRelativePath(Glib::ustring procparams_fname, Glib::us return absPath; } -static Glib::ustring relativePathIfInside(Glib::ustring procparams_fname, bool fnameAbsolute, Glib::ustring embedded_fname) +static Glib::ustring relativePathIfInside(const Glib::ustring &procparams_fname, bool fnameAbsolute, Glib::ustring embedded_fname) { if (fnameAbsolute || embedded_fname == "" || !Glib::path_is_absolute(procparams_fname)) { return embedded_fname; @@ -1301,7 +1301,7 @@ static Glib::ustring relativePathIfInside(Glib::ustring procparams_fname, bool f return prefix + embedded_fname.substr(dir1.length()); } -int ProcParams::save (Glib::ustring fname, Glib::ustring fname2, bool fnameAbsolute, ParamsEdited* pedited) +int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, bool fnameAbsolute, ParamsEdited* pedited) { if (fname.empty () && fname2.empty ()) { @@ -3397,7 +3397,7 @@ int ProcParams::save (Glib::ustring fname, Glib::ustring fname2, bool fnameAbsol } } -int ProcParams::write (Glib::ustring &fname, Glib::ustring &content) const +int ProcParams::write (const Glib::ustring &fname, const Glib::ustring &content) const { int error = 0; @@ -3417,7 +3417,7 @@ int ProcParams::write (Glib::ustring &fname, Glib::ustring &content) const return error; } -int ProcParams::load (Glib::ustring fname, ParamsEdited* pedited) +int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) { setlocale(LC_NUMERIC, "C"); // to set decimal point to "." @@ -8005,7 +8005,7 @@ PartialProfile::PartialProfile(const ProcParams* pp, const ParamsEdited* pe) } } -int PartialProfile::load (Glib::ustring fName) +int PartialProfile::load (const Glib::ustring &fName) { if (!pparams) { pparams = new ProcParams(); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 7946ce4d9..aa6c78922 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -524,7 +524,7 @@ public: double green; double equal; - WBEntry(Glib::ustring p, enum WBTypes t, Glib::ustring l, int temp, double green, double equal) : ppLabel(p), type(t), GUILabel(l), temperature(temp), green(green), equal(equal) {}; + WBEntry(const Glib::ustring &p, enum WBTypes t, const Glib::ustring &l, int temp, double green, double equal) : ppLabel(p), type(t), GUILabel(l), temperature(temp), green(green), equal(equal) {}; }; class WBParams @@ -1312,14 +1312,14 @@ public: * @param pedited pointer to a ParamsEdited object (optional) to store which values has to be saved * @return Error code (=0 if all supplied filenames where created correctly) */ - int save (Glib::ustring fname, Glib::ustring fname2 = "", bool fnameAbsolute = true, ParamsEdited* pedited = NULL); + int save (const Glib::ustring &fname, const Glib::ustring &fname2 = "", bool fnameAbsolute = true, ParamsEdited* pedited = NULL); /** * Loads the parameters from a file. * @param fname the name of the file * @params pedited pointer to a ParamsEdited object (optional) to store which values has been loaded * @return Error code (=0 if no error) */ - int load (Glib::ustring fname, ParamsEdited* pedited = NULL); + int load (const Glib::ustring &fname, ParamsEdited* pedited = NULL); /** Creates a new instance of ProcParams. * @return a pointer to the new ProcParams instance. */ @@ -1341,7 +1341,7 @@ private: * @param content the text to write * @return Error code (=0 if no error) * */ - int write (Glib::ustring &fname, Glib::ustring &content) const; + int write (const Glib::ustring &fname, const Glib::ustring &content) const; }; @@ -1371,7 +1371,7 @@ public: PartialProfile (const ProcParams* pp, const ParamsEdited* pe = NULL); void deleteInstance (); void clearGeneral (); - int load (Glib::ustring fName); + int load (const Glib::ustring &fName); void set (bool v); const void applyTo (ProcParams *destParams) const ; }; diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 7d9dd0bf3..a16ec1194 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -587,9 +587,7 @@ void RawImageSource::transformRect (PreviewProps pp, int tran, int &ssx1, int &s } } -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -static float -calculate_scale_mul(float scale_mul[4], const float pre_mul_[4], const float c_white[4], const float c_black[4], bool isMono, int colors) +float calculate_scale_mul(float scale_mul[4], const float pre_mul_[4], const float c_white[4], const float c_black[4], bool isMono, int colors) { if (isMono || colors == 1) { for (int c = 0; c < 4; c++) { @@ -617,7 +615,7 @@ calculate_scale_mul(float scale_mul[4], const float pre_mul_[4], const float c_w return gain; } -void RawImageSource::getImage (ColorTemp ctemp, int tran, Imagefloat* image, PreviewProps pp, ToneCurveParams hrp, ColorManagementParams cmp, RAWParams raw ) +void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw ) { MyMutex::MyLock lock(getImageMutex); @@ -727,7 +725,7 @@ void RawImageSource::getImage (ColorTemp ctemp, int tran, Imagefloat* image, Pre float line_blue[imwidth] ALIGNED16; #ifdef _OPENMP - #pragma omp for + #pragma omp for schedule(dynamic,16) #endif for (int ix = 0; ix < imheight; ix++) { @@ -891,7 +889,7 @@ void RawImageSource::getImage (ColorTemp ctemp, int tran, Imagefloat* image, Pre } } -DCPProfile *RawImageSource::getDCP(ColorManagementParams cmp, ColorTemp &wb) +DCPProfile *RawImageSource::getDCP(const ColorManagementParams &cmp, ColorTemp &wb) { DCPProfile *dcpProf = NULL; cmsHPROFILE dummy; @@ -905,7 +903,7 @@ DCPProfile *RawImageSource::getDCP(ColorManagementParams cmp, ColorTemp &wb) return dcpProf; } -void RawImageSource::convertColorSpace(Imagefloat* image, ColorManagementParams cmp, ColorTemp &wb) +void RawImageSource::convertColorSpace(Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb) { double pre_mul[3] = { ri->get_pre_mul(0), ri->get_pre_mul(1), ri->get_pre_mul(2) }; colorSpaceConversion (image, cmp, wb, pre_mul, embProfile, camProfile, imatrices.xyz_cam, (static_cast(getMetaData()))->getCamera()); @@ -1501,7 +1499,7 @@ void RawImageSource::vflip (Imagefloat* image) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -int RawImageSource::load (Glib::ustring fname, bool batch) +int RawImageSource::load (const Glib::ustring &fname, bool batch) { MyTime t1, t2; @@ -3651,7 +3649,7 @@ lab2ProphotoRgbD50(float L, float A, float B, float& r, float& g, float& b) } // Converts raw image including ICC input profile to working space - floating point version -void RawImageSource::colorSpaceConversion_ (Imagefloat* im, ColorManagementParams &cmp, ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double camMatrix[3][3], const std::string &camName) +void RawImageSource::colorSpaceConversion_ (Imagefloat* im, ColorManagementParams &cmp, const ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double camMatrix[3][3], const std::string &camName) { // MyTime t1, t2, t3; diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index 0dd6c9098..6eebba3ca 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -39,7 +39,8 @@ private: static DiagonalCurve *phaseOneIccCurveInv; static LUTf invGrad; // for fast_demosaic static LUTf initInvGrad (); - static void colorSpaceConversion_ (Imagefloat* im, ColorManagementParams &cmp, ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], const std::string &camName); + static void colorSpaceConversion_ (Imagefloat* im, ColorManagementParams &cmp, const ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], const std::string &camName); + int defTransform (int tran); protected: MyMutex getImageMutex; // locks getImage @@ -97,7 +98,6 @@ protected: void hphd_green (float** hpmap); void processFalseColorCorrectionThread (Imagefloat* im, array2D &rbconv_Y, array2D &rbconv_I, array2D &rbconv_Q, array2D &rbout_I, array2D &rbout_Q, const int row_from, const int row_to); void hlRecovery (std::string method, float* red, float* green, float* blue, int i, int sx1, int width, int skip, const RAWParams &raw, float* hlmax); - int defTransform (int tran); void transformRect (PreviewProps pp, int tran, int &sx1, int &sy1, int &width, int &height, int &fw); void transformPosition (int x, int y, int tran, int& tx, int& ty); @@ -115,7 +115,7 @@ public: RawImageSource (); ~RawImageSource (); - int load (Glib::ustring fname, bool batch = false); + int load (const Glib::ustring &fname, bool batch = false); void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse); void demosaic (const RAWParams &raw); void retinex (ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI); @@ -127,7 +127,7 @@ public: void refinement_lassus (int PassCount); void refinement(int PassCount); - bool IsrgbSourceModified() + bool IsrgbSourceModified() const { return rgbSourceModified; // tracks whether cached rgb output of demosaic has been modified } @@ -137,12 +137,12 @@ public: void cfaboxblur (RawImage *riFlatFile, float* cfablur, int boxH, int boxW ); void scaleColors (int winx, int winy, int winw, int winh, const RAWParams &raw); // raw for cblack - void getImage (ColorTemp ctemp, int tran, Imagefloat* image, PreviewProps pp, ToneCurveParams hrp, ColorManagementParams cmp, RAWParams raw); - eSensorType getSensorType () + void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw); + eSensorType getSensorType () const { return ri != NULL ? ri->getSensorType() : ST_NONE; } - ColorTemp getWB () + ColorTemp getWB () const { return camera_wb; } @@ -153,7 +153,7 @@ public: return rawData; } - double getDefGain () + double getDefGain () const { return defGain; } @@ -184,11 +184,11 @@ public: } void getAutoExpHistogram (LUTu & histogram, int& histcompr); void getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw); - DCPProfile *getDCP(ColorManagementParams cmp, ColorTemp &wb); + DCPProfile *getDCP(const ColorManagementParams &cmp, ColorTemp &wb); - void convertColorSpace(Imagefloat* image, ColorManagementParams cmp, ColorTemp &wb); + void convertColorSpace(Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb); static bool findInputProfile(Glib::ustring inProfile, cmsHPROFILE embedded, std::string camName, DCPProfile **dcpProf, cmsHPROFILE& in); - static void colorSpaceConversion (Imagefloat* im, ColorManagementParams cmp, ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], std::string camName) + static void colorSpaceConversion (Imagefloat* im, ColorManagementParams cmp, const ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], std::string camName) { colorSpaceConversion_ (im, cmp, wb, pre_mul, embedded, camprofile, cam, camName); } diff --git a/rtengine/stdimagesource.cc b/rtengine/stdimagesource.cc index aabb35a30..e422d23b2 100644 --- a/rtengine/stdimagesource.cc +++ b/rtengine/stdimagesource.cc @@ -83,7 +83,7 @@ StdImageSource::~StdImageSource () } } -void StdImageSource::getSampleFormat (Glib::ustring &fname, IIOSampleFormat &sFormat, IIOSampleArrangement &sArrangement) +void StdImageSource::getSampleFormat (const Glib::ustring &fname, IIOSampleFormat &sFormat, IIOSampleArrangement &sArrangement) { sFormat = IIOSF_UNKNOWN; @@ -125,7 +125,7 @@ void StdImageSource::getSampleFormat (Glib::ustring &fname, IIOSampleFormat &sFo * and RT's image data type (Image8, Image16 and Imagefloat), then it will * load the image into it */ -int StdImageSource::load (Glib::ustring fname, bool batch) +int StdImageSource::load (const Glib::ustring &fname, bool batch) { fileName = fname; @@ -213,7 +213,7 @@ int StdImageSource::load (Glib::ustring fname, bool batch) return 0; } -void StdImageSource::getImage (ColorTemp ctemp, int tran, Imagefloat* image, PreviewProps pp, ToneCurveParams hrp, ColorManagementParams cmp, RAWParams raw) +void StdImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw) { // the code will use OpenMP as of now. @@ -234,12 +234,12 @@ void StdImageSource::getImage (ColorTemp ctemp, int tran, Imagefloat* image, Pre } } -void StdImageSource::convertColorSpace(Imagefloat* image, ColorManagementParams cmp, ColorTemp &wb) +void StdImageSource::convertColorSpace(Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb) { colorSpaceConversion (image, cmp, embProfile, img->getSampleFormat()); } -void StdImageSource::colorSpaceConversion (Imagefloat* im, ColorManagementParams cmp, cmsHPROFILE embedded, IIOSampleFormat sampleFormat) +void StdImageSource::colorSpaceConversion (Imagefloat* im, const ColorManagementParams &cmp, cmsHPROFILE embedded, IIOSampleFormat sampleFormat) { bool skipTransform = false; diff --git a/rtengine/stdimagesource.h b/rtengine/stdimagesource.h index 6017fae74..048f3b3c0 100644 --- a/rtengine/stdimagesource.h +++ b/rtengine/stdimagesource.h @@ -38,15 +38,15 @@ protected: bool rgbSourceModified; //void transformPixel (int x, int y, int tran, int& tx, int& ty); - void getSampleFormat (Glib::ustring &fname, IIOSampleFormat &sFormat, IIOSampleArrangement &sArrangement); + void getSampleFormat (const Glib::ustring &fname, IIOSampleFormat &sFormat, IIOSampleArrangement &sArrangement); public: StdImageSource (); ~StdImageSource (); - int load (Glib::ustring fname, bool batch = false); - void getImage (ColorTemp ctemp, int tran, Imagefloat* image, PreviewProps pp, ToneCurveParams hrp, ColorManagementParams cmp, RAWParams raw); - ColorTemp getWB () + int load (const Glib::ustring &fname, bool batch = false); + void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw); + ColorTemp getWB () const { return wb; } @@ -60,7 +60,7 @@ public: void getAutoExpHistogram (LUTu &histogram, int& histcompr); - double getDefGain () + double getDefGain () const { return 0.0; } @@ -90,20 +90,10 @@ public: plistener = pl; } - void convertColorSpace(Imagefloat* image, ColorManagementParams cmp, ColorTemp &wb);// RAWParams raw will not be used for non-raw files (see imagesource.h) - static void colorSpaceConversion (Imagefloat* im, ColorManagementParams cmp, cmsHPROFILE embedded, IIOSampleFormat sampleFormat); + void convertColorSpace(Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb);// RAWParams raw will not be used for non-raw files (see imagesource.h) + static void colorSpaceConversion (Imagefloat* im, const ColorManagementParams &cmp, cmsHPROFILE embedded, IIOSampleFormat sampleFormat); - static inline double intpow (double a, int b) - { - double r = 1.0; - - for (int i = 0; i < b; i++) { - r *= a; - } - - return r; - } - bool IsrgbSourceModified() + bool IsrgbSourceModified() const { return rgbSourceModified; }