diff --git a/rtengine/curves.h b/rtengine/curves.h index 248bfe487..33e944959 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -1219,11 +1219,12 @@ inline float WeightedStdToneCurve::Triangle(float a, float a1, float b) const #ifdef __SSE2__ inline vfloat WeightedStdToneCurve::Triangle(vfloat a, vfloat a1, vfloat b) const { + vmask eqmask = vmaskf_eq(b, a); vfloat a2 = a1 - a; vmask cmask = vmaskf_lt(b, a); vfloat b3 = vself(cmask, b, F2V(65535.f) - b); vfloat a3 = vself(cmask, a, F2V(65535.f) - a); - return b + a2 * b3 / a3; + return vself(eqmask, a1, b + a2 * b3 / a3); } #endif diff --git a/rtengine/dcp.cc b/rtengine/dcp.cc index c18ee8915..c60e80587 100644 --- a/rtengine/dcp.cc +++ b/rtengine/dcp.cc @@ -419,7 +419,7 @@ std::map getAliases(const Glib::ustring& profile_dir) buffer[read] = 0; cJSON_Minify(buffer.get()); - const std::unique_ptr root(cJSON_Parse(buffer.get())); + const std::unique_ptr root(cJSON_Parse(buffer.get()), cJSON_Delete); if (!root || !root->child) { if (settings->verbose) { std::cout << "Could not parse 'camera_model_aliases.json' file." << std::endl; diff --git a/rtengine/imagedata.cc b/rtengine/imagedata.cc index 844c4df08..2a9f68bbc 100644 --- a/rtengine/imagedata.cc +++ b/rtengine/imagedata.cc @@ -825,11 +825,6 @@ unsigned int FramesData::getFrameCount() const return dcrawFrameCount ? dcrawFrameCount : frames.size(); } -FrameData *FramesData::getFrameData(unsigned int frame) const -{ - return frames.empty() || frame >= frames.size() ? nullptr : frames.at(frame); -} - bool FramesData::getPixelShift () const { // So far only Pentax and Sony provide multi-frame Pixel Shift files. @@ -1139,9 +1134,7 @@ FramesData::FramesData(const Glib::ustring& fname, std::unique_ptrgetRoot(), roots.at(0)); - - frames.push_back(fd); + frames.push_back(std::unique_ptr(new FrameData(currFrame, currFrame->getRoot(), roots.at(0)))); } for (auto currRoot : roots) { @@ -1167,8 +1160,7 @@ FramesData::FramesData(const Glib::ustring& fname, std::unique_ptrgetRoot(), roots.at(0)); - frames.push_back(fd); + frames.push_back(std::unique_ptr(new FrameData(currFrame, currFrame->getRoot(), roots.at(0)))); } rewind(exifManager.f); // Not sure this is necessary @@ -1188,9 +1180,7 @@ FramesData::FramesData(const Glib::ustring& fname, std::unique_ptrgetRoot(), roots.at(0)); - - frames.push_back(fd); + frames.push_back(std::unique_ptr(new FrameData(currFrame, currFrame->getRoot(), roots.at(0)))); } for (auto currRoot : roots) { diff --git a/rtengine/imagedata.h b/rtengine/imagedata.h index 0427ee519..1c3aff7e9 100644 --- a/rtengine/imagedata.h +++ b/rtengine/imagedata.h @@ -20,6 +20,7 @@ #define __IMAGEDATA_H__ #include +#include #include "rawimage.h" #include #include @@ -89,7 +90,7 @@ public: class FramesData : public FramesMetaData { private: // frame's root IFD, can be a file root IFD or a SUB-IFD - std::vector frames; + std::vector> frames; // root IFD in the file std::vector roots; IptcData* iptc; @@ -102,7 +103,6 @@ public: void setDCRawFrameCount (unsigned int frameCount); unsigned int getRootCount () const; unsigned int getFrameCount () const; - FrameData *getFrameData (unsigned int frame) const; bool getPixelShift () const; bool getHDR (unsigned int frame = 0) const; std::string getImageType (unsigned int frame) const; diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index a7c867e08..c1bd8fd64 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -110,7 +110,6 @@ public: return 0; } - virtual FrameData* getImageData (unsigned int frameNum) = 0; virtual ImageMatrices* getImageMatrices () = 0; virtual bool isRAW () const = 0; virtual DCPProfile* getDCP (const ColorManagementParams &cmp, DCPProfile::ApplyState &as) diff --git a/rtengine/ipdehaze.cc b/rtengine/ipdehaze.cc index fecc73e7d..5522107e0 100644 --- a/rtengine/ipdehaze.cc +++ b/rtengine/ipdehaze.cc @@ -197,23 +197,16 @@ void extract_channels(Imagefloat *img, array2D &r, array2D &g, arr const int W = img->getWidth(); const int H = img->getHeight(); -#ifdef _OPENMP - #pragma omp parallel for if (multithread) -#endif - for (int y = 0; y < H; ++y) { - for (int x = 0; x < W; ++x) { - r[y][x] = img->r(y, x); - g[y][x] = img->g(y, x); - b[y][x] = img->b(y, x); - } - } + array2D imgR(W, H, img->r.ptrs, ARRAY2D_BYREFERENCE); + guidedFilter(imgR, imgR, r, radius, epsilon, multithread); - guidedFilter(r, r, r, radius, epsilon, multithread); - guidedFilter(g, g, g, radius, epsilon, multithread); - guidedFilter(b, b, b, radius, epsilon, multithread); + array2D imgG(W, H, img->g.ptrs, ARRAY2D_BYREFERENCE); + guidedFilter(imgG, imgG, g, radius, epsilon, multithread); + + array2D imgB(W, H, img->b.ptrs, ARRAY2D_BYREFERENCE); + guidedFilter(imgB, imgB, b, radius, epsilon, multithread); } - } // namespace diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index f725d634f..df6cd7a9d 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -168,10 +168,6 @@ public: return ri->get_rotateDegree(); } - FrameData* getImageData(unsigned int frameNum) - { - return idata->getFrameData(frameNum); - } ImageMatrices* getImageMatrices() { return &imatrices; diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index 792a86b61..50b3c8a66 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -33,7 +33,7 @@ extern const Settings *settings; LFModifier::~LFModifier() { if (data_) { - MyMutex::MyLock lock(*lfModifierMutex); + MyMutex::MyLock lock(lfModifierMutex); data_->Destroy(); } } @@ -113,14 +113,14 @@ void LFModifier::correctCA(double &x, double &y, int cx, int cy, int channel) co void LFModifier::processVignetteLine(int width, int y, float *line) const { - MyMutex::MyLock lock(*lfModifierMutex); + MyMutex::MyLock lock(lfModifierMutex); data_->ApplyColorModification(line, 0, y, width, 1, LF_CR_1(INTENSITY), 0); } void LFModifier::processVignetteLine3Channels(int width, int y, float *line) const { - MyMutex::MyLock lock(*lfModifierMutex); + MyMutex::MyLock lock(lfModifierMutex); data_->ApplyColorModification(line, 0, y, width, 1, LF_CR_3(RED, GREEN, BLUE), 0); } @@ -160,7 +160,6 @@ LFModifier::LFModifier(lfModifier *m, bool swap_xy, int flags): swap_xy_(swap_xy), flags_(flags) { - lfModifierMutex = new MyMutex; } @@ -378,14 +377,13 @@ bool LFDatabase::LoadDirectory(const char *dirname) LFDatabase::LFDatabase(): data_(nullptr) { - lfDBMutex = new MyMutex; } LFDatabase::~LFDatabase() { if (data_) { - MyMutex::MyLock lock(*lfDBMutex); + MyMutex::MyLock lock(lfDBMutex); data_->Destroy(); } } @@ -401,7 +399,7 @@ std::vector LFDatabase::getCameras() const { std::vector ret; if (data_) { - MyMutex::MyLock lock(*lfDBMutex); + MyMutex::MyLock lock(lfDBMutex); auto cams = data_->GetCameras(); while (*cams) { ret.emplace_back(); @@ -417,7 +415,7 @@ std::vector LFDatabase::getLenses() const { std::vector ret; if (data_) { - MyMutex::MyLock lock(*lfDBMutex); + MyMutex::MyLock lock(lfDBMutex); auto lenses = data_->GetLenses(); while (*lenses) { ret.emplace_back(); @@ -433,7 +431,7 @@ LFCamera LFDatabase::findCamera(const Glib::ustring &make, const Glib::ustring & { LFCamera ret; if (data_) { - MyMutex::MyLock lock(*lfDBMutex); + MyMutex::MyLock lock(lfDBMutex); auto found = data_->FindCamerasExt(make.c_str(), model.c_str()); if (found) { ret.data_ = found[0]; @@ -448,7 +446,7 @@ LFLens LFDatabase::findLens(const LFCamera &camera, const Glib::ustring &name) c { LFLens ret; if (data_) { - MyMutex::MyLock lock(*lfDBMutex); + MyMutex::MyLock lock(lfDBMutex); auto found = data_->FindLenses(camera.data_, nullptr, name.c_str()); for (size_t pos = 0; !found && pos < name.size(); ) { // try to split the maker from the model of the lens -- we have to @@ -486,7 +484,7 @@ std::unique_ptr LFDatabase::getModifier(const LFCamera &camera, cons { std::unique_ptr ret; if (data_) { - MyMutex::MyLock lock(*lfDBMutex); + MyMutex::MyLock lock(lfDBMutex); if (camera && lens) { lfModifier *mod = lfModifier::Create(lens.data_, camera.getCropFactor(), width, height); int flags = LF_MODIFY_DISTORTION | LF_MODIFY_SCALE | LF_MODIFY_TCA; diff --git a/rtengine/rtlensfun.h b/rtengine/rtlensfun.h index f75f25d4f..ef6d2192b 100644 --- a/rtengine/rtlensfun.h +++ b/rtengine/rtlensfun.h @@ -57,7 +57,7 @@ private: lfModifier *data_; bool swap_xy_; int flags_; - MyMutex *lfModifierMutex; + mutable MyMutex lfModifierMutex; }; class LFCamera final @@ -122,7 +122,7 @@ private: LFDatabase(); bool LoadDirectory(const char *dirname); - MyMutex *lfDBMutex; + mutable MyMutex lfDBMutex; static LFDatabase instance_; lfDatabase *data_; }; diff --git a/rtengine/stdimagesource.h b/rtengine/stdimagesource.h index 1dbb65001..605b2926c 100644 --- a/rtengine/stdimagesource.h +++ b/rtengine/stdimagesource.h @@ -69,10 +69,6 @@ public: void getFullSize (int& w, int& h, int tr = TR_NONE); void getSize (const PreviewProps &pp, int& w, int& h); - FrameData* getImageData (unsigned int frameNum) - { - return idata->getFrameData (frameNum); - } ImageIO* getImageIO () { return img;