merge with dev

This commit is contained in:
Desmis 2017-06-11 18:38:31 +02:00
commit f1a90dad54
33 changed files with 215 additions and 138 deletions

View File

@ -6,7 +6,6 @@
#endif #endif
#include "sleef.c" #include "sleef.c"
#include "opthelper.h" #include "opthelper.h"
#define pow_F(a,b) (xexpf(b*xlogf(a))) #define pow_F(a,b) (xexpf(b*xlogf(a)))
#define DIAGONALS 5 #define DIAGONALS 5
@ -883,7 +882,7 @@ float *EdgePreservingDecomposition::CreateIteratedBlur(float *Source, float Scal
return Blur; return Blur;
} }
SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Source, float Scale, float EdgeStopping, float CompressionExponent, float DetailBoost, int Iterates, int Reweightings, float *Compressed) SSEFUNCTION void EdgePreservingDecomposition::CompressDynamicRange(float *Source, float Scale, float EdgeStopping, float CompressionExponent, float DetailBoost, int Iterates, int Reweightings)
{ {
if(w < 300 && h < 300) { // set number of Reweightings to zero for small images (thumbnails). We could try to find a better solution here. if(w < 300 && h < 300) { // set number of Reweightings to zero for small images (thumbnails). We could try to find a better solution here.
Reweightings = 0; Reweightings = 0;
@ -926,12 +925,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour
//Blur. Also setup memory for Compressed (we can just use u since each element of u is used in one calculation). //Blur. Also setup memory for Compressed (we can just use u since each element of u is used in one calculation).
float *u = CreateIteratedBlur(Source, Scale, EdgeStopping, Iterates, Reweightings); float *u = CreateIteratedBlur(Source, Scale, EdgeStopping, Iterates, Reweightings);
if(Compressed == nullptr) {
Compressed = u;
}
//Apply compression, detail boost, unlogging. Compression is done on the logged data and detail boost on unlogged. //Apply compression, detail boost, unlogging. Compression is done on the logged data and detail boost on unlogged.
// float temp = CompressionExponent - 1.0f;
float temp; float temp;
if(DetailBoost > 0.f) { if(DetailBoost > 0.f) {
@ -958,8 +952,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour
cev = xexpf(LVFU(Source[i]) + LVFU(u[i]) * (tempv)) - epsv; cev = xexpf(LVFU(Source[i]) + LVFU(u[i]) * (tempv)) - epsv;
uev = xexpf(LVFU(u[i])) - epsv; uev = xexpf(LVFU(u[i])) - epsv;
sourcev = xexpf(LVFU(Source[i])) - epsv; sourcev = xexpf(LVFU(Source[i])) - epsv;
_mm_storeu_ps( &Source[i], sourcev); _mm_storeu_ps( &Source[i], cev + DetailBoostv * (sourcev - uev) );
_mm_storeu_ps( &Compressed[i], cev + DetailBoostv * (sourcev - uev) );
} }
} }
@ -967,7 +960,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour
float ce = xexpf(Source[i] + u[i] * (temp)) - eps; float ce = xexpf(Source[i] + u[i] * (temp)) - eps;
float ue = xexpf(u[i]) - eps; float ue = xexpf(u[i]) - eps;
Source[i] = xexpf(Source[i]) - eps; Source[i] = xexpf(Source[i]) - eps;
Compressed[i] = ce + DetailBoost * (Source[i] - ue); Source[i] = ce + DetailBoost * (Source[i] - ue);
} }
#else #else
@ -979,16 +972,11 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour
float ce = xexpf(Source[i] + u[i] * (temp)) - eps; float ce = xexpf(Source[i] + u[i] * (temp)) - eps;
float ue = xexpf(u[i]) - eps; float ue = xexpf(u[i]) - eps;
Source[i] = xexpf(Source[i]) - eps; Source[i] = xexpf(Source[i]) - eps;
Compressed[i] = ce + DetailBoost * (Source[i] - ue); Source[i] = ce + DetailBoost * (Source[i] - ue);
} }
#endif #endif
if(Compressed != u) { delete[] u;
delete[] u;
}
return Compressed;
} }

View File

@ -152,7 +152,7 @@ public:
the more compression is applied, with Compression = 1 giving no effect and above 1 the opposite effect. You can totally the more compression is applied, with Compression = 1 giving no effect and above 1 the opposite effect. You can totally
use Compression = 1 and play with DetailBoost for some really sweet unsharp masking. If working on luma/grey, consider giving it a logarithm. use Compression = 1 and play with DetailBoost for some really sweet unsharp masking. If working on luma/grey, consider giving it a logarithm.
In place calculation to save memory (Source == Compressed) is totally ok. Reweightings > 0 invokes CreateIteratedBlur instead of CreateBlur. */ In place calculation to save memory (Source == Compressed) is totally ok. Reweightings > 0 invokes CreateIteratedBlur instead of CreateBlur. */
float *CompressDynamicRange(float *Source, float Scale = 1.0f, float EdgeStopping = 1.4f, float CompressionExponent = 0.8f, float DetailBoost = 0.1f, int Iterates = 20, int Reweightings = 0, float *Compressed = nullptr); void CompressDynamicRange(float *Source, float Scale = 1.0f, float EdgeStopping = 1.4f, float CompressionExponent = 0.8f, float DetailBoost = 0.1f, int Iterates = 20, int Reweightings = 0);
private: private:
MultiDiagonalSymmetricMatrix *A; //The equations are simple enough to not mandate a matrix class, but fast solution NEEDS a complicated preconditioner. MultiDiagonalSymmetricMatrix *A; //The equations are simple enough to not mandate a matrix class, but fast solution NEEDS a complicated preconditioner.

View File

@ -113,7 +113,7 @@ public:
// use as empty declaration, resize before use! // use as empty declaration, resize before use!
// very useful as a member object // very useful as a member object
array2D() : array2D() :
x(0), y(0), owner(0), flags(0), ptr(nullptr), data(nullptr), lock(0) x(0), y(0), owner(0), flags(0), ptr(nullptr), data(nullptr), lock(false)
{ {
//printf("got empty array2D init\n"); //printf("got empty array2D init\n");
} }
@ -143,7 +143,7 @@ public:
{ {
flags = flgs; flags = flgs;
//if (lock) { printf("array2D attempt to overwrite data\n");raise(SIGSEGV);} //if (lock) { printf("array2D attempt to overwrite data\n");raise(SIGSEGV);}
lock |= flags & ARRAY2D_LOCK_DATA; lock = flags & ARRAY2D_LOCK_DATA;
// when by reference // when by reference
// TODO: improve this code with ar_realloc() // TODO: improve this code with ar_realloc()
owner = (flags & ARRAY2D_BYREFERENCE) ? 0 : 1; owner = (flags & ARRAY2D_BYREFERENCE) ? 0 : 1;

View File

@ -27,9 +27,6 @@ CameraConst::CameraConst()
white_max = 0; white_max = 0;
} }
CameraConst::~CameraConst()
{
}
bool bool
CameraConst::parseApertureScaling(CameraConst *cc, void *ji_) CameraConst::parseApertureScaling(CameraConst *cc, void *ji_)
@ -317,6 +314,7 @@ CameraConst::parseEntry(void *cJSON_, const char *make_model)
return cc; return cc;
parse_error: parse_error:
delete cc;
return nullptr; return nullptr;
} }
@ -709,6 +707,14 @@ CameraConstantsStore::CameraConstantsStore()
{ {
} }
CameraConstantsStore::~CameraConstantsStore()
{
for (auto &p : mCameraConstants) {
delete p.second;
}
}
void CameraConstantsStore::init(Glib::ustring baseDir, Glib::ustring userSettingsDir) void CameraConstantsStore::init(Glib::ustring baseDir, Glib::ustring userSettingsDir)
{ {
parse_camera_constants_file(Glib::build_filename(baseDir, "camconst.json")); parse_camera_constants_file(Glib::build_filename(baseDir, "camconst.json"));

View File

@ -26,7 +26,6 @@ private:
std::map<float, float> mApertureScaling; std::map<float, float> mApertureScaling;
CameraConst(); CameraConst();
~CameraConst();
static bool parseLevels(CameraConst *cc, int bw, void *ji); static bool parseLevels(CameraConst *cc, int bw, void *ji);
static bool parseApertureScaling(CameraConst *cc, void *ji); static bool parseApertureScaling(CameraConst *cc, void *ji);
bool get_Levels(struct camera_const_levels & lvl, int bw, int iso, float fnumber); bool get_Levels(struct camera_const_levels & lvl, int bw, int iso, float fnumber);
@ -55,6 +54,7 @@ private:
bool parse_camera_constants_file(Glib::ustring filename); bool parse_camera_constants_file(Glib::ustring filename);
public: public:
~CameraConstantsStore();
void init(Glib::ustring baseDir, Glib::ustring userSettingsDir); void init(Glib::ustring baseDir, Glib::ustring userSettingsDir);
static CameraConstantsStore *getInstance(void); static CameraConstantsStore *getInstance(void);
CameraConst *get(const char make[], const char model[]); CameraConst *get(const char make[], const char model[]);

View File

@ -773,37 +773,38 @@ void Color::hsl2rgb01 (float h, float s, float l, float &r, float &g, float &b)
void Color::rgb2hsv(float r, float g, float b, float &h, float &s, float &v) void Color::rgb2hsv(float r, float g, float b, float &h, float &s, float &v)
{ {
double var_R = r / 65535.0; const double var_R = r / 65535.0;
double var_G = g / 65535.0; const double var_G = g / 65535.0;
double var_B = b / 65535.0; const double var_B = b / 65535.0;
double var_Min = min(var_R, var_G, var_B); const double var_Min = min(var_R, var_G, var_B);
double var_Max = max(var_R, var_G, var_B); const double var_Max = max(var_R, var_G, var_B);
double del_Max = var_Max - var_Min; const double del_Max = var_Max - var_Min;
h = 0.f;
v = var_Max; v = var_Max;
if (del_Max < 0.00001 && del_Max > -0.00001) { // no fabs, slow! if (del_Max < 0.00001 && del_Max > -0.00001) { // no fabs, slow!
h = 0; s = 0.f;
s = 0;
} else { } else {
s = del_Max / var_Max; s = del_Max / var_Max;
if ( var_R == var_Max ) { if (var_R == var_Max) {
h = (var_G - var_B) / del_Max; h = (var_G - var_B) / del_Max;
} else if ( var_G == var_Max ) { } else if (var_G == var_Max) {
h = 2.0 + (var_B - var_R) / del_Max; h = 2.0 + (var_B - var_R) / del_Max;
} else if ( var_B == var_Max ) { } else if (var_B == var_Max) {
h = 4.0 + (var_R - var_G) / del_Max; h = 4.0 + (var_R - var_G) / del_Max;
} }
h /= 6.0; h /= 6.f;
if ( h < 0 ) { if (h < 0.f) {
h += 1; h += 1.f;
} }
if ( h > 1 ) { if (h > 1.f) {
h -= 1; h -= 1.f;
} }
} }
} }

View File

@ -1701,6 +1701,15 @@ DCPStore* DCPStore::getInstance()
return &instance; return &instance;
} }
DCPStore::~DCPStore()
{
for (auto &p : profile_cache) {
delete p.second;
}
}
void DCPStore::init(const Glib::ustring& rt_profile_dir, bool loadAll) void DCPStore::init(const Glib::ustring& rt_profile_dir, bool loadAll)
{ {
MyMutex::MyLock lock(mutex); MyMutex::MyLock lock(mutex);

View File

@ -152,6 +152,7 @@ class DCPStore final :
public NonCopyable public NonCopyable
{ {
public: public:
~DCPStore();
static DCPStore* getInstance(); static DCPStore* getInstance();
void init(const Glib::ustring& rt_profile_dir, bool loadAll = true); void init(const Glib::ustring& rt_profile_dir, bool loadAll = true);

View File

@ -406,12 +406,8 @@ void Crop::update (int todo)
MyTime t1aue, t2aue; MyTime t1aue, t2aue;
t1aue.set(); t1aue.set();
int crW, crH; int crW = 100; // settings->leveldnv == 0
int crH = 100; // settings->leveldnv == 0
if (settings->leveldnv == 0) {
crW = 100;
crH = 100;
}
if (settings->leveldnv == 1) { if (settings->leveldnv == 1) {
crW = 250; crW = 250;
@ -1633,7 +1629,7 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte
parent->ipf.transCoord (parent->fw, parent->fh, bx1, by1, bw, bh, orx, ory, orw, orh); parent->ipf.transCoord (parent->fw, parent->fh, bx1, by1, bw, bh, orx, ory, orw, orh);
if (check_need_larger_crop_for_lcp_distortion (parent->fw, parent->fh, orx, ory, orw, orh, parent->params)) { if (check_need_larger_crop_for_lcp_distortion(parent->fw, parent->fh, orx, ory, orw, orh, parent->params)) {
// TODO - this is an estimate of the max distortion relative to the image size. ATM it is hardcoded to be 15%, which seems enough. If not, need to revise // TODO - this is an estimate of the max distortion relative to the image size. ATM it is hardcoded to be 15%, which seems enough. If not, need to revise
int dW = int (double (parent->fw) * 0.15 / (2 * skip)); int dW = int (double (parent->fw) * 0.15 / (2 * skip));
int dH = int (double (parent->fh) * 0.15 / (2 * skip)); int dH = int (double (parent->fh) * 0.15 / (2 * skip));

View File

@ -276,6 +276,31 @@ public:
} }
} }
~Implementation()
{
for (auto &p : wProfiles) {
if (p.second) {
cmsCloseProfile(p.second);
}
}
for (auto &p : wProfilesGamma) {
if (p.second) {
cmsCloseProfile(p.second);
}
}
for (auto &p : fileProfiles) {
if(p.second) {
cmsCloseProfile(p.second);
}
}
if(srgb) {
cmsCloseProfile(srgb);
}
if(xyz) {
cmsCloseProfile(xyz);
}
}
void init(const Glib::ustring& usrICCDir, const Glib::ustring& rtICCDir, bool loadAll) void init(const Glib::ustring& usrICCDir, const Glib::ustring& rtICCDir, bool loadAll)
{ {
// Reads all profiles from the given profiles dir // Reads all profiles from the given profiles dir

View File

@ -6443,7 +6443,7 @@ void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, float
//Jacques Desmis : always Iterates=5 for compatibility images between preview and output //Jacques Desmis : always Iterates=5 for compatibility images between preview and output
epd.CompressDynamicRange (Qpr, (float)sca / skip, (float)edgest, Compression, DetailBoost, Iterates, rew, Qpr); epd.CompressDynamicRange (Qpr, (float)sca / skip, (float)edgest, Compression, DetailBoost, Iterates, rew);
//Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping.
float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f)); float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f));
@ -6577,7 +6577,7 @@ void ImProcFunctions::EPDToneMaplocal (LabImage *lab, LabImage *tmp1, unsigned i
fwrite(L, N, sizeof(float), f); fwrite(L, N, sizeof(float), f);
fclose(f);*/ fclose(f);*/
epd.CompressDynamicRange (L, sca / float (skip), edgest, Compression, DetailBoost, Iterates, rew, L); epd.CompressDynamicRange (L, sca / float (skip), edgest, Compression, DetailBoost, Iterates, rew);
//Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping.
float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f)); float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f));
@ -6693,7 +6693,7 @@ void ImProcFunctions::EPDToneMap (LabImage *lab, unsigned int Iterates, int skip
fwrite(L, N, sizeof(float), f); fwrite(L, N, sizeof(float), f);
fclose(f);*/ fclose(f);*/
epd.CompressDynamicRange (L, sca / float (skip), edgest, Compression, DetailBoost, Iterates, rew, L); epd.CompressDynamicRange (L, sca / float (skip), edgest, Compression, DetailBoost, Iterates, rew);
//Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping.
float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f)); float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f));

View File

@ -273,8 +273,9 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
} }
} }
float varx = 0.f; float varx = vart;
float limdx, ilimdx; float limdx = limD;
float ilimdx = ilimD;
if (gradvart != 0) { if (gradvart != 0) {
if (gradvart == 1) { if (gradvart == 1) {
@ -294,10 +295,6 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
limdx = limD * (0.4f * it + 0.6f); limdx = limD * (0.4f * it + 0.6f);
ilimdx = 1.f / limdx; ilimdx = 1.f / limdx;
} }
} else {
varx = vart;
limdx = limD;
ilimdx = ilimD;
} }
scal = round (sc); scal = round (sc);

View File

@ -1253,7 +1253,8 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet (LabImage * lab, LabImage * dst, in
delete [] meanN; delete [] meanN;
delete [] sigma; delete [] sigma;
delete [] sigmaN; delete [] sigmaN;
delete [] MaxP;
delete [] MaxN;
} }
#ifdef _RT_NESTED_OPENMP #ifdef _RT_NESTED_OPENMP
omp_set_nested (oldNested); omp_set_nested (oldNested);
@ -1653,7 +1654,7 @@ void ImProcFunctions::EPDToneMapResid (float * WavCoeffs_L0, unsigned int Itera
} }
epd2.CompressDynamicRange (WavCoeffs_L0, (float)sca / skip, edgest, Compression, DetailBoost, Iterates, rew, WavCoeffs_L0); epd2.CompressDynamicRange(WavCoeffs_L0, (float)sca / skip, edgest, Compression, DetailBoost, Iterates, rew);
//Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping.
#ifdef _RT_NESTED_OPENMP #ifdef _RT_NESTED_OPENMP

View File

@ -361,6 +361,11 @@ SSEFUNCTION void LCPMapper::processVignetteLine3Channels(int width, int y, float
LCPProfile::LCPProfile(const Glib::ustring &fname) LCPProfile::LCPProfile(const Glib::ustring &fname)
{ {
for (int i = 0; i < MaxPersModelCount; i++) {
aPersModel[i] = nullptr;
}
pCurPersModel = nullptr;
const int BufferSize = 8192; const int BufferSize = 8192;
char buf[BufferSize]; char buf[BufferSize];
@ -378,10 +383,6 @@ LCPProfile::LCPProfile(const Glib::ustring &fname)
isFisheye = inCamProfiles = firstLIDone = inPerspect = inAlternateLensID = inAlternateLensNames = false; isFisheye = inCamProfiles = firstLIDone = inPerspect = inAlternateLensID = inAlternateLensNames = false;
sensorFormatFactor = 1; sensorFormatFactor = 1;
for (int i = 0; i < MaxPersModelCount; i++) {
aPersModel[i] = nullptr;
}
persModelCount = 0; persModelCount = 0;
*inInvalidTag = 0; *inInvalidTag = 0;
@ -412,6 +413,19 @@ LCPProfile::LCPProfile(const Glib::ustring &fname)
filterBadFrames(1.5, 100); filterBadFrames(1.5, 100);
} }
LCPProfile::~LCPProfile()
{
if (pCurPersModel) {
delete pCurPersModel;
}
for (int i = 0; i < MaxPersModelCount; i++) {
if (aPersModel[i]) {
delete aPersModel[i];
}
}
}
// from all frames not marked as bad already, take average and filter out frames with higher deviation than this if there are enough values // from all frames not marked as bad already, take average and filter out frames with higher deviation than this if there are enough values
int LCPProfile::filterBadFrames(double maxAvgDevFac, int minFramesLeft) int LCPProfile::filterBadFrames(double maxAvgDevFac, int minFramesLeft)
{ {
@ -746,8 +760,6 @@ void XMLCALL LCPProfile::XmlTextHandler(void *pLCPProfile, const XML_Char *s, in
void LCPProfile::handle_text(std::string text) void LCPProfile::handle_text(std::string text)
{ {
const char *raw = text.c_str();
// Check if it contains non-whitespaces (there are several calls to this for one tag unfortunately) // Check if it contains non-whitespaces (there are several calls to this for one tag unfortunately)
bool onlyWhiteSpace = true; bool onlyWhiteSpace = true;
for (size_t i = 0; i < text.size(); ++i) { for (size_t i = 0; i < text.size(); ++i) {
@ -766,6 +778,8 @@ void LCPProfile::handle_text(std::string text)
// convert to null terminated // convert to null terminated
char* tag = pProf->lastTag; char* tag = pProf->lastTag;
const char* raw = text.c_str();
// Common data section // Common data section
if (!pProf->firstLIDone) { if (!pProf->firstLIDone) {
// Generic tags are the same for all // Generic tags are the same for all
@ -886,6 +900,15 @@ LCPStore* LCPStore::getInstance()
return &instance_; return &instance_;
} }
LCPStore::~LCPStore()
{
for (auto &p : profileCache) {
delete p.second;
}
}
LCPProfile* LCPStore::getProfile (Glib::ustring filename) LCPProfile* LCPStore::getProfile (Glib::ustring filename)
{ {
if (filename.length() == 0 || !isValidLCPFileName(filename)) { if (filename.length() == 0 || !isValidLCPFileName(filename)) {

View File

@ -110,6 +110,7 @@ public:
LCPPersModel* aPersModel[MaxPersModelCount]; // Do NOT use std::list or something, it's buggy in GCC! LCPPersModel* aPersModel[MaxPersModelCount]; // Do NOT use std::list or something, it's buggy in GCC!
explicit LCPProfile(const Glib::ustring &fname); explicit LCPProfile(const Glib::ustring &fname);
~LCPProfile();
void calcParams(int mode, float focalLength, float focusDist, float aperture, LCPModelCommon *pCorr1, LCPModelCommon *pCorr2, LCPModelCommon *pCorr3) const; // Interpolates between the persModels frames void calcParams(int mode, float focalLength, float focusDist, float aperture, LCPModelCommon *pCorr1, LCPModelCommon *pCorr2, LCPModelCommon *pCorr3) const; // Interpolates between the persModels frames
@ -124,6 +125,7 @@ class LCPStore
std::map<Glib::ustring, LCPProfile*> profileCache; std::map<Glib::ustring, LCPProfile*> profileCache;
public: public:
~LCPStore();
Glib::ustring getDefaultCommonDirectory() const; Glib::ustring getDefaultCommonDirectory() const;
bool isValidLCPFileName(Glib::ustring filename) const; bool isValidLCPFileName(Glib::ustring filename) const;
LCPProfile* getProfile(Glib::ustring filename); LCPProfile* getProfile(Glib::ustring filename);

View File

@ -9636,20 +9636,25 @@ PartialProfile::PartialProfile (bool createInstance, bool paramsEditedValue)
pparams = nullptr; pparams = nullptr;
pedited = nullptr; pedited = nullptr;
} }
ownsPparams = ownsPedited = true;
} }
PartialProfile::PartialProfile (ProcParams* pp, ParamsEdited* pe, bool fullCopy) PartialProfile::PartialProfile (ProcParams* pp, ParamsEdited* pe, bool fullCopy)
{ {
if (fullCopy && pp) { if (fullCopy && pp) {
pparams = new ProcParams (*pp); pparams = new ProcParams(*pp);
ownsPparams = true;
} else { } else {
pparams = pp; pparams = pp;
ownsPparams = false;
} }
if (fullCopy && pe) { if (fullCopy && pe) {
pedited = new ParamsEdited (*pe); pedited = new ParamsEdited(*pe);
ownsPedited = true;
} else { } else {
pedited = pe; pedited = pe;
ownsPedited = false;
} }
} }
@ -9666,6 +9671,15 @@ PartialProfile::PartialProfile (const ProcParams* pp, const ParamsEdited* pe)
} else { } else {
pedited = nullptr; pedited = nullptr;
} }
ownsPparams = ownsPedited = true;
}
PartialProfile::~PartialProfile()
{
if(ownsPparams)
delete pparams;
if(ownsPedited)
delete pedited;
} }
int PartialProfile::load (const Glib::ustring &fName) int PartialProfile::load (const Glib::ustring &fName)

View File

@ -1538,11 +1538,15 @@ public:
PartialProfile (bool createInstance = false, bool paramsEditedValue = false); PartialProfile (bool createInstance = false, bool paramsEditedValue = false);
PartialProfile (ProcParams* pp, ParamsEdited* pe = nullptr, bool fullCopy = false); PartialProfile (ProcParams* pp, ParamsEdited* pe = nullptr, bool fullCopy = false);
PartialProfile (const ProcParams* pp, const ParamsEdited* pe = nullptr); PartialProfile (const ProcParams* pp, const ParamsEdited* pe = nullptr);
~PartialProfile ();
void deleteInstance (); void deleteInstance ();
void clearGeneral (); void clearGeneral ();
int load (const Glib::ustring &fName); int load (const Glib::ustring &fName);
void set (bool v); void set (bool v);
const void applyTo (ProcParams *destParams) const ; const void applyTo (ProcParams *destParams) const ;
private:
bool ownsPparams;
bool ownsPedited;
}; };
/** /**

View File

@ -248,6 +248,8 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath
if (!fileFound && (level > 0 || displayLevel0)) { if (!fileFound && (level > 0 || displayLevel0)) {
// no files found in this level, we delete the subdirectory entry // no files found in this level, we delete the subdirectory entry
folders.pop_back(); folders.pop_back();
delete entries.back();
entries.pop_back(); entries.pop_back();
} }

View File

@ -279,12 +279,8 @@ private:
if (settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PON") { if (settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PON") {
MyTime t1pone, t2pone; MyTime t1pone, t2pone;
t1pone.set(); t1pone.set();
int crW, crH; int crW = 100; // settings->leveldnv == 0
int crH = 100; // settings->leveldnv == 0
if (settings->leveldnv == 0) {
crW = 100;
crH = 100;
}
if (settings->leveldnv == 1) { if (settings->leveldnv == 1) {
crW = 250; crW = 250;
@ -748,7 +744,7 @@ private:
{ {
procparams::ProcParams& params = job->pparams; procparams::ProcParams& params = job->pparams;
//ImProcFunctions ipf (&params, true); //ImProcFunctions ipf (&params, true);
ImProcFunctions &ipf = * (ipf_p.get()); ImProcFunctions &ipf = *(ipf_p.get());
// perform luma/chroma denoise // perform luma/chroma denoise
// CieImage *cieView; // CieImage *cieView;
@ -813,7 +809,7 @@ private:
{ {
procparams::ProcParams& params = job->pparams; procparams::ProcParams& params = job->pparams;
//ImProcFunctions ipf (&params, true); //ImProcFunctions ipf (&params, true);
ImProcFunctions &ipf = * (ipf_p.get()); ImProcFunctions &ipf = *(ipf_p.get());
imgsrc->convertColorSpace (baseImg, params.icm, currWB); imgsrc->convertColorSpace (baseImg, params.icm, currWB);
@ -836,7 +832,7 @@ private:
{ {
procparams::ProcParams& params = job->pparams; procparams::ProcParams& params = job->pparams;
//ImProcFunctions ipf (&params, true); //ImProcFunctions ipf (&params, true);
ImProcFunctions &ipf = * (ipf_p.get()); ImProcFunctions &ipf = *(ipf_p.get());
if (params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled) { if (params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled) {
const int W = baseImg->getWidth(); const int W = baseImg->getWidth();
@ -2064,7 +2060,7 @@ private:
{ {
procparams::ProcParams& params = job->pparams; procparams::ProcParams& params = job->pparams;
//ImProcFunctions ipf (&params, true); //ImProcFunctions ipf (&params, true);
ImProcFunctions &ipf = * (ipf_p.get()); ImProcFunctions &ipf = *(ipf_p.get());
int imw, imh; int imw, imh;
double scale_factor = ipf.resizeScale (&params, fw, fh, imw, imh); double scale_factor = ipf.resizeScale (&params, fw, fh, imw, imh);
@ -2100,7 +2096,7 @@ private:
tmplab = std::move (resized); tmplab = std::move (resized);
} }
adjust_procparams (scale_factor); adjust_procparams(scale_factor);
fw = imw; fw = imw;
fh = imh; fh = imh;

View File

@ -1026,6 +1026,12 @@ void CropWindow::pointerMoved (int bstate, int x, int y)
cropHandler.cimg.lock (); cropHandler.cimg.lock ();
int vx = x - xpos - imgX; int vx = x - xpos - imgX;
int vy = y - ypos - imgY; int vy = y - ypos - imgY;
if(decorated) {
vx -= sideBorderWidth;
vy -= (titleHeight + upperBorderWidth + sepWidth);
}
// guint8* pix = cropHandler.cropPixbuf->get_pixels() + vy*cropHandler.cropPixbuf->get_rowstride() + vx*3; // guint8* pix = cropHandler.cropPixbuf->get_pixels() + vy*cropHandler.cropPixbuf->get_rowstride() + vx*3;
// if (vx < cropHandler.cropPixbuf->get_width() && vy < cropHandler.cropPixbuf->get_height()) // if (vx < cropHandler.cropPixbuf->get_width() && vy < cropHandler.cropPixbuf->get_height())
// pmlistener->pointerMoved (true, mx, my, pix[0], pix[1], pix[2]); // pmlistener->pointerMoved (true, mx, my, pix[0], pix[1], pix[2]);

View File

@ -451,7 +451,7 @@ public:
}; };
EditorPanel::EditorPanel (FilePanel* filePanel) EditorPanel::EditorPanel (FilePanel* filePanel)
: catalogPane(nullptr), realized(false), iHistoryShow(nullptr), iHistoryHide(nullptr), iTopPanel_1_Show(nullptr), iTopPanel_1_Hide(nullptr), iRightPanel_1_Show(nullptr), iRightPanel_1_Hide(nullptr), iBeforeLockON(nullptr), iBeforeLockOFF(nullptr), beforePreviewHandler(nullptr), beforeIarea(nullptr), beforeBox(nullptr), afterBox(nullptr), afterHeaderBox(nullptr), parent(nullptr), openThm(nullptr), ipc(nullptr), beforeIpc(nullptr), isProcessing(false) : catalogPane(nullptr), realized(false), tbBeforeLock(nullptr), iHistoryShow(nullptr), iHistoryHide(nullptr), iTopPanel_1_Show(nullptr), iTopPanel_1_Hide(nullptr), iRightPanel_1_Show(nullptr), iRightPanel_1_Hide(nullptr), iBeforeLockON(nullptr), iBeforeLockOFF(nullptr), previewHandler(nullptr), beforePreviewHandler(nullptr), beforeIarea(nullptr), beforeBox(nullptr), afterBox(nullptr), beforeLabel(nullptr), afterLabel(nullptr), beforeHeaderBox(nullptr), afterHeaderBox(nullptr), parent(nullptr), openThm(nullptr), isrc(nullptr), ipc(nullptr), beforeIpc(nullptr), err(0), isProcessing(false)
{ {
epih = new EditorPanelIdleHelper; epih = new EditorPanelIdleHelper;
@ -1689,6 +1689,8 @@ bool EditorPanel::idle_saveImage (ProgressConnector<rtengine::IImage16*> *pc, Gl
else if (sf.format == "jpg") else if (sf.format == "jpg")
ld->startFunc (sigc::bind (sigc::mem_fun (img, &rtengine::IImage16::saveAsJPEG), fname, sf.jpegQuality, sf.jpegSubSamp), ld->startFunc (sigc::bind (sigc::mem_fun (img, &rtengine::IImage16::saveAsJPEG), fname, sf.jpegQuality, sf.jpegSubSamp),
sigc::bind (sigc::mem_fun (*this, &EditorPanel::idle_imageSaved), ld, img, fname, sf)); sigc::bind (sigc::mem_fun (*this, &EditorPanel::idle_imageSaved), ld, img, fname, sf));
else
delete ld;
} else { } else {
Glib::ustring msg_ = Glib::ustring ("<b>") + fname + ": Error during image processing\n</b>"; Glib::ustring msg_ = Glib::ustring ("<b>") + fname + ": Error during image processing\n</b>";
Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);

View File

@ -128,11 +128,7 @@ void findOriginalEntries (const std::vector<ThumbBrowserEntryBase*>& entries)
FileBrowser::FileBrowser () FileBrowser::FileBrowser ()
: tbl(nullptr), numFiltered(0) : tbl(nullptr), numFiltered(0)
{ {
session_id_ = 0;
fbih = new FileBrowserIdleHelper;
fbih->fbrowser = this;
fbih->destroyed = false;
fbih->pending = 0;
ProfileStore::getInstance()->addListener(this); ProfileStore::getInstance()->addListener(this);
@ -546,37 +542,27 @@ void FileBrowser::doubleClicked (ThumbBrowserEntryBase* entry)
void FileBrowser::addEntry (FileBrowserEntry* entry) void FileBrowser::addEntry (FileBrowserEntry* entry)
{ {
struct addparams { struct addparams {
FileBrowserIdleHelper* fbih; FileBrowser *browser;
FileBrowserEntry* entry; FileBrowserEntry *entry;
unsigned int session_id;
}; };
fbih->pending++;
entry->setParent (this);
addparams* const ap = new addparams; addparams* const ap = new addparams;
ap->fbih = fbih; entry->setParent (this);
ap->browser = this;
ap->entry = entry; ap->entry = entry;
ap->session_id = session_id();
const auto func = [](gpointer data) -> gboolean { const auto func = [](gpointer data) -> gboolean {
addparams* const ap = static_cast<addparams*>(data); addparams* const ap = static_cast<addparams*>(data);
FileBrowserIdleHelper* fbih = ap->fbih; if (ap->session_id != ap->browser->session_id()) {
if (fbih->destroyed) {
if (fbih->pending == 1) {
delete fbih;
} else {
fbih->pending--;
}
delete ap->entry; delete ap->entry;
delete ap; delete ap;
} else {
return 0; ap->browser->addEntry_(ap->entry);
delete ap;
} }
ap->fbih->fbrowser->addEntry_ (ap->entry);
delete ap;
fbih->pending--;
return FALSE; return FALSE;
}; };
@ -653,16 +639,7 @@ FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname)
void FileBrowser::close () void FileBrowser::close ()
{ {
if (fbih->pending) { ++session_id_;
fbih->destroyed = true;
} else {
delete fbih;
}
fbih = new FileBrowserIdleHelper;
fbih->fbrowser = this;
fbih->destroyed = false;
fbih->pending = 0;
{ {
MYWRITERLOCK(l, entryRW); MYWRITERLOCK(l, entryRW);

View File

@ -53,12 +53,6 @@ public:
} }
}; };
struct FileBrowserIdleHelper {
FileBrowser* fbrowser;
bool destroyed;
int pending;
};
/* /*
* Class handling actions common to all thumbnails of the file browser * Class handling actions common to all thumbnails of the file browser
*/ */
@ -71,6 +65,7 @@ private:
typedef sigc::signal<void> type_trash_changed; typedef sigc::signal<void> type_trash_changed;
IdleRegister idle_register; IdleRegister idle_register;
unsigned int session_id_;
protected: protected:
Gtk::MenuItem* rank[6]; Gtk::MenuItem* rank[6];
@ -129,7 +124,6 @@ protected:
FileBrowserListener* tbl; FileBrowserListener* tbl;
BrowserFilter filter; BrowserFilter filter;
int numFiltered; int numFiltered;
FileBrowserIdleHelper* fbih;
void toTrashRequested (std::vector<FileBrowserEntry*> tbe); void toTrashRequested (std::vector<FileBrowserEntry*> tbe);
void fromTrashRequested (std::vector<FileBrowserEntry*> tbe); void fromTrashRequested (std::vector<FileBrowserEntry*> tbe);
@ -152,6 +146,8 @@ public:
FileBrowserEntry* delEntry (const Glib::ustring& fname); // return the entry if found here return NULL otherwise FileBrowserEntry* delEntry (const Glib::ustring& fname); // return the entry if found here return NULL otherwise
void close (); void close ();
unsigned int session_id() const { return session_id_; }
void setBatchPParamsChangeListener (BatchPParamsChangeListener* l) void setBatchPParamsChangeListener (BatchPParamsChangeListener* l)
{ {
bppcl = l; bppcl = l;

View File

@ -720,6 +720,7 @@ void FileCatalog::previewReady (int dir_id, FileBrowserEntry* fdn)
{ {
if ( dir_id != selectedDirectoryId ) { if ( dir_id != selectedDirectoryId ) {
delete fdn;
return; return;
} }

View File

@ -115,12 +115,12 @@ int main(int argc, char **argv)
// get the path where the rawtherapee executable is stored // get the path where the rawtherapee executable is stored
#ifdef WIN32 #ifdef WIN32
WCHAR exnameU[512] = {0}; WCHAR exnameU[512] = {0};
GetModuleFileNameW (NULL, exnameU, 512); GetModuleFileNameW (NULL, exnameU, 511);
WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 512, 0, 0 ); WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 );
#else #else
if (readlink("/proc/self/exe", exname, 512) < 0) { if (readlink("/proc/self/exe", exname, 511) < 0) {
strncpy(exname, argv[0], 512); strncpy(exname, argv[0], 511);
} }
#endif #endif

View File

@ -137,12 +137,12 @@ int main (int argc, char **argv)
// get the path where the rawtherapee executable is stored // get the path where the rawtherapee executable is stored
#ifdef WIN32 #ifdef WIN32
WCHAR exnameU[512] = {0}; WCHAR exnameU[512] = {0};
GetModuleFileNameW (NULL, exnameU, 512); GetModuleFileNameW (NULL, exnameU, 511);
WideCharToMultiByte (CP_UTF8, 0, exnameU, -1, exname, 512, 0, 0 ); WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 );
#else #else
if (readlink ("/proc/self/exe", exname, 512) < 0) { if (readlink("/proc/self/exe", exname, 511) < 0) {
strncpy (exname, argv[0], 512); strncpy(exname, argv[0], 511);
} }
#endif #endif

View File

@ -584,22 +584,26 @@ void Options::setDefaults ()
0, // ADDSET_DIRPYREQ_THRESHOLD 0, // ADDSET_DIRPYREQ_THRESHOLD
0, // ADDSET_DIRPYREQ_SKINPROTECT 0, // ADDSET_DIRPYREQ_SKINPROTECT
0, // ADDSET_COLORTONING_SPLIT 0, // ADDSET_COLORTONING_SPLIT
0, // ADDSET_COLORTONING_SATTHRESHOLD
0, // ADDSET_COLORTONING_SATOPACITY
0, // ADDSET_COLORTONING_BALANCE
0, // ADDSET_COLORTONING_STRENGTH
0, // ADDSET_DIRPYRDN_PASSES 0, // ADDSET_DIRPYRDN_PASSES
0, // ADDSET_RAWFFCLIPCONTROL 0, // ADDSET_RAWFFCLIPCONTROL
0, // ADDSET_FILMSIMULATION_STRENGTH 0, // ADDSET_FILMSIMULATION_STRENGTH
0, // ADDSET_WA 0, // ADDSET_WA
0, // ADDSET_WA_SKINPROTECT
0, // ADDSET_WA_THRESHOLD2
0, // ADDSET_WA_THRR
0, // ADDSET_WA_THRRH
0, // ADDSET_WA_THRESHOLD 0, // ADDSET_WA_THRESHOLD
0, // ADDSET_WA_THRESHOLD2 0, // ADDSET_WA_THRESHOLD2
0, // ADDSET_WA_THRES
0, // ADDSET_WA_CHRO 0, // ADDSET_WA_CHRO
0, // ADDSET_WA_CHROMA 0, // ADDSET_WA_CHROMA
0, // ADDSET_WA_CONTRAST 0, // ADDSET_WA_CONTRAST
0, // ADDSET_WA_SKINPROTECT
0, // ADDSET_WA_RESCHRO
0, // ADDSET_WA_RESCON 0, // ADDSET_WA_RESCON
0, // ADDSET_WA_RESCONH 0, // ADDSET_WA_RESCONH
0, // ADDSET_WA_THRR 0, // ADDSET_WA_RESCHRO
0, // ADDSET_WA_THRRH
0, // ADDSET_WA_SKYPROTECT 0, // ADDSET_WA_SKYPROTECT
0, // ADDSET_WA_EDGRAD 0, // ADDSET_WA_EDGRAD
0, // ADDSET_WA_EDGVAL 0, // ADDSET_WA_EDGVAL

View File

@ -168,6 +168,11 @@ PreviewLoader::PreviewLoader():
{ {
} }
PreviewLoader::~PreviewLoader()
{
delete impl_;
}
PreviewLoader* PreviewLoader::getInstance() PreviewLoader* PreviewLoader::getInstance()
{ {
static PreviewLoader instance_; static PreviewLoader instance_;

View File

@ -88,6 +88,7 @@ public:
private: private:
PreviewLoader(); PreviewLoader();
~PreviewLoader();
class Impl; class Impl;
Impl* impl_; Impl* impl_;

View File

@ -39,7 +39,7 @@ void ProfilePanel::cleanup ()
delete partialProfileDlg; delete partialProfileDlg;
} }
ProfilePanel::ProfilePanel () : storedPProfile(nullptr), lastFilename(""), imagePath("") ProfilePanel::ProfilePanel () : storedPProfile(nullptr), lastFilename(""), imagePath(""), lastSavedPSE(nullptr), customPSE(nullptr)
{ {
tpc = nullptr; tpc = nullptr;
@ -128,6 +128,8 @@ ProfilePanel::~ProfilePanel ()
delete profileFillModeOnImage; delete profileFillModeOnImage;
delete profileFillModeOffImage; delete profileFillModeOffImage;
delete lastSavedPSE;
delete customPSE;
} }
bool ProfilePanel::isCustomSelected() bool ProfilePanel::isCustomSelected()
@ -164,14 +166,24 @@ Gtk::TreeIter ProfilePanel::getLastSavedRow()
Gtk::TreeIter ProfilePanel::addCustomRow() Gtk::TreeIter ProfilePanel::addCustomRow()
{ {
const ProfileStoreEntry *customPSE = new ProfileStoreEntry(Glib::ustring ("(" + M("PROFILEPANEL_PCUSTOM") + ")"), PSET_FILE, 0, 0); if(customPSE) {
delete customPSE;
customPSE = nullptr;
}
customPSE = new ProfileStoreEntry(Glib::ustring ("(" + M("PROFILEPANEL_PCUSTOM") + ")"), PSET_FILE, 0, 0);
Gtk::TreeIter newEntry = profiles->addRow(customPSE); Gtk::TreeIter newEntry = profiles->addRow(customPSE);
return newEntry; return newEntry;
} }
Gtk::TreeIter ProfilePanel::addLastSavedRow() Gtk::TreeIter ProfilePanel::addLastSavedRow()
{ {
const ProfileStoreEntry *lastSavedPSE = new ProfileStoreEntry(Glib::ustring ("(" + M("PROFILEPANEL_PLASTSAVED") + ")"), PSET_FILE, 0, 0); if(lastSavedPSE) {
delete lastSavedPSE;
lastSavedPSE = nullptr;
}
lastSavedPSE = new ProfileStoreEntry(Glib::ustring ("(" + M("PROFILEPANEL_PLASTSAVED") + ")"), PSET_FILE, 0, 0);
Gtk::TreeIter newEntry = profiles->addRow(lastSavedPSE); Gtk::TreeIter newEntry = profiles->addRow(lastSavedPSE);
return newEntry; return newEntry;
} }

View File

@ -42,6 +42,8 @@ private:
RTImage *profileFillModeOffImage; RTImage *profileFillModeOffImage;
Gtk::ToggleButton* fillMode; Gtk::ToggleButton* fillMode;
Gtk::TreeIter currRow; Gtk::TreeIter currRow;
ProfileStoreEntry *lastSavedPSE;
ProfileStoreEntry *customPSE;
void profileFillModeToggled (); void profileFillModeToggled ();
bool isCustomSelected (); bool isCustomSelected ();

View File

@ -184,6 +184,11 @@ ThumbImageUpdater::ThumbImageUpdater():
{ {
} }
ThumbImageUpdater::~ThumbImageUpdater()
{
delete impl_;
}
void void
ThumbImageUpdater::add(ThumbBrowserEntryBase* tbe, bool* priority, bool upgrade, ThumbImageUpdateListener* l) ThumbImageUpdater::add(ThumbBrowserEntryBase* tbe, bool* priority, bool upgrade, ThumbImageUpdateListener* l)
{ {

View File

@ -93,6 +93,7 @@ public:
private: private:
ThumbImageUpdater(); ThumbImageUpdater();
~ThumbImageUpdater();
class Impl; class Impl;
Impl* impl_; Impl* impl_;