diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d6ee8e68..99805c216 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,7 +108,6 @@ endif() option(USE_EXPERIMENTAL_LANG_VERSIONS "Build with -std=c++0x" OFF) option(BUILD_SHARED "Build with shared libraries" OFF) -option(WITH_BZIP "Build with Bzip2 support" ON) option(WITH_MYFILE_MMAP "Build using memory mapped file" ON) option(WITH_LTO "Build with link-time optimizations" OFF) option(WITH_SAN "Build with run-time sanitizer" OFF) @@ -294,16 +293,6 @@ find_package(PNG REQUIRED) find_package(TIFF REQUIRED) find_package(ZLIB REQUIRED) -# Link with bzip: -if(WITH_BZIP) - find_package(BZip2) - if(BZIP2_FOUND) - add_definitions(-DBZIP_SUPPORT) - set(EXTRA_INCDIR ${BZIP2_INCLUDE_DIR}) - set(EXTRA_LIB ${EXTRA_LIB} ${BZIP2_LIBRARIES}) - endif() -endif() - # Check for libcanberra-gtk3 (sound events on Linux): if(UNIX AND(NOT APPLE)) pkg_check_modules(CANBERRA-GTK REQUIRED libcanberra-gtk3) diff --git a/rtengine/EdgePreservingDecomposition.cc b/rtengine/EdgePreservingDecomposition.cc index 8c1ca56a7..1424af1b3 100644 --- a/rtengine/EdgePreservingDecomposition.cc +++ b/rtengine/EdgePreservingDecomposition.cc @@ -6,7 +6,6 @@ #endif #include "sleef.c" #include "opthelper.h" - #define pow_F(a,b) (xexpf(b*xlogf(a))) #define DIAGONALS 5 @@ -426,7 +425,10 @@ bool MultiDiagonalSymmetricMatrix::CreateIncompleteCholeskyFactorization(int Max //Initialize the decomposition - setup memory, start rows, etc. MultiDiagonalSymmetricMatrix *ic = new MultiDiagonalSymmetricMatrix(n, mic); - ic->CreateDiagonal(0, 0); //There's always a main diagonal in this type of decomposition. + if(!ic->CreateDiagonal(0, 0)) { //There's always a main diagonal in this type of decomposition. + delete ic; + return false; + } mic = 1; for(int ii = 1; ii < m; ii++) { @@ -660,7 +662,7 @@ void MultiDiagonalSymmetricMatrix::CholeskyBackSolve(float* RESTRICT x, float* R } } -EdgePreservingDecomposition::EdgePreservingDecomposition(int width, int height) +EdgePreservingDecomposition::EdgePreservingDecomposition(int width, int height) : a0(nullptr) , a_1(nullptr), a_w(nullptr), a_w_1(nullptr), a_w1(nullptr) { w = width; h = height; @@ -883,7 +885,7 @@ float *EdgePreservingDecomposition::CreateIteratedBlur(float *Source, float Scal 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. Reweightings = 0; @@ -926,12 +928,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). 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. -// float temp = CompressionExponent - 1.0f; float temp; if(DetailBoost > 0.f) { @@ -958,8 +955,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour cev = xexpf(LVFU(Source[i]) + LVFU(u[i]) * (tempv)) - epsv; uev = xexpf(LVFU(u[i])) - epsv; sourcev = xexpf(LVFU(Source[i])) - epsv; - _mm_storeu_ps( &Source[i], sourcev); - _mm_storeu_ps( &Compressed[i], cev + DetailBoostv * (sourcev - uev) ); + _mm_storeu_ps( &Source[i], cev + DetailBoostv * (sourcev - uev) ); } } @@ -967,7 +963,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour float ce = xexpf(Source[i] + u[i] * (temp)) - eps; float ue = xexpf(u[i]) - eps; Source[i] = xexpf(Source[i]) - eps; - Compressed[i] = ce + DetailBoost * (Source[i] - ue); + Source[i] = ce + DetailBoost * (Source[i] - ue); } #else @@ -979,16 +975,11 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour float ce = xexpf(Source[i] + u[i] * (temp)) - eps; float ue = xexpf(u[i]) - eps; Source[i] = xexpf(Source[i]) - eps; - Compressed[i] = ce + DetailBoost * (Source[i] - ue); + Source[i] = ce + DetailBoost * (Source[i] - ue); } #endif - if(Compressed != u) { - delete[] u; - } - - return Compressed; - + delete[] u; } diff --git a/rtengine/EdgePreservingDecomposition.h b/rtengine/EdgePreservingDecomposition.h index bf567f103..1eca7b2c8 100644 --- a/rtengine/EdgePreservingDecomposition.h +++ b/rtengine/EdgePreservingDecomposition.h @@ -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 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. */ - 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: MultiDiagonalSymmetricMatrix *A; //The equations are simple enough to not mandate a matrix class, but fast solution NEEDS a complicated preconditioner. diff --git a/rtengine/LUT.h b/rtengine/LUT.h index df95dde7f..2701c4ffc 100644 --- a/rtengine/LUT.h +++ b/rtengine/LUT.h @@ -169,6 +169,11 @@ public: { data = nullptr; reset(); +#if defined( __SSE2__ ) && defined( __x86_64__ ) + maxsv = ZEROV; + sizev = ZEROV; + sizeiv = _mm_setzero_si128(); +#endif } ~LUT() diff --git a/rtengine/array2D.h b/rtengine/array2D.h index c05c739dc..25d644c85 100644 --- a/rtengine/array2D.h +++ b/rtengine/array2D.h @@ -113,7 +113,7 @@ public: // use as empty declaration, resize before use! // very useful as a member object 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"); } @@ -143,7 +143,7 @@ public: { flags = flgs; //if (lock) { printf("array2D attempt to overwrite data\n");raise(SIGSEGV);} - lock |= flags & ARRAY2D_LOCK_DATA; + lock = flags & ARRAY2D_LOCK_DATA; // when by reference // TODO: improve this code with ar_realloc() owner = (flags & ARRAY2D_BYREFERENCE) ? 0 : 1; @@ -281,34 +281,6 @@ public: return (x > 0 && y > 0); } - array2D & operator=( array2D & rhs) - { - if (this != &rhs) - - { - flags = rhs.flags; - lock = rhs.lock; - if (!owner) { // we can only copy same size data - if ((x != rhs.x) || (y != rhs.y)) { - printf(" assignment error in array2D\n"); - printf(" sizes differ and not owner\n"); - raise( SIGSEGV); - } - - } else { - ar_realloc(rhs.x, rhs.y); - } - - // we could have been created from a different - // array format where each row is created by 'new' - for (int i = 0; i < y; i++) { - memcpy(ptr[i], rhs.ptr[i], x * sizeof(T)); - } - } - - return *this; - } - }; template class multi_array2D diff --git a/rtengine/calc_distort.cc b/rtengine/calc_distort.cc index 80d61d654..7af47adb2 100644 --- a/rtengine/calc_distort.cc +++ b/rtengine/calc_distort.cc @@ -102,6 +102,9 @@ int calcDistortion(unsigned char* img1, unsigned char* img2, int ncols, int nrow if (n < 5) { printf ("Not sufficient features.\n"); distortion = 0.0; + KLTFreeFeatureTable(ft); + KLTFreeFeatureList(fl); + KLTFreeTrackingContext(tc); return -1; } @@ -154,6 +157,9 @@ int calcDistortion(unsigned char* img1, unsigned char* img2, int ncols, int nrow if (new_n < 5) { printf ("Not sufficient features.\n"); distortion = 0.0; + KLTFreeFeatureTable(ft); + KLTFreeFeatureList(fl); + KLTFreeTrackingContext(tc); return -1; } @@ -252,17 +258,27 @@ int calcDistortion(unsigned char* img1, unsigned char* img2, int ncols, int nrow if (total_delta / new_n > DELTA_2) { printf ("Deviation is too big.\n"); distortion = 0.0; + KLTFreeFeatureTable(ft); + KLTFreeFeatureList(fl); + KLTFreeTrackingContext(tc); return -2; } if (rxy < RXY_LIMIT) { printf ("Not linear enough\n"); distortion = 0.0; + KLTFreeFeatureTable(ft); + KLTFreeFeatureList(fl); + KLTFreeTrackingContext(tc); return -3; } printf ("distortion amount=%lf scale=%lf deviation=%lf, rxy=%lf\n", a, b, total_delta / n, rxy); distortion = a; + + KLTFreeFeatureTable(ft); + KLTFreeFeatureList(fl); + KLTFreeTrackingContext(tc); return 1; } diff --git a/rtengine/camconst.cc b/rtengine/camconst.cc index 2449a1cd1..6b4a36c4b 100644 --- a/rtengine/camconst.cc +++ b/rtengine/camconst.cc @@ -27,9 +27,6 @@ CameraConst::CameraConst() white_max = 0; } -CameraConst::~CameraConst() -{ -} bool CameraConst::parseApertureScaling(CameraConst *cc, void *ji_) @@ -183,11 +180,10 @@ CameraConst::parseLevels(CameraConst *cc, int bw, void *ji_) CameraConst * CameraConst::parseEntry(void *cJSON_, const char *make_model) { - CameraConst *cc = nullptr; cJSON *js, *ji, *jranges; js = (cJSON *)cJSON_; - cc = new CameraConst; + CameraConst *cc = new CameraConst; cc->make_model = Glib::ustring(make_model); ji = cJSON_GetObjectItem(js, "dcraw_matrix"); @@ -317,6 +313,7 @@ CameraConst::parseEntry(void *cJSON_, const char *make_model) return cc; parse_error: + delete cc; return nullptr; } @@ -709,6 +706,14 @@ CameraConstantsStore::CameraConstantsStore() { } + +CameraConstantsStore::~CameraConstantsStore() +{ + for (auto &p : mCameraConstants) { + delete p.second; + } +} + void CameraConstantsStore::init(Glib::ustring baseDir, Glib::ustring userSettingsDir) { parse_camera_constants_file(Glib::build_filename(baseDir, "camconst.json")); diff --git a/rtengine/camconst.h b/rtengine/camconst.h index 713936bf8..31b65f3e8 100644 --- a/rtengine/camconst.h +++ b/rtengine/camconst.h @@ -26,7 +26,6 @@ private: std::map mApertureScaling; CameraConst(); - ~CameraConst(); static bool parseLevels(CameraConst *cc, int bw, void *ji); static bool parseApertureScaling(CameraConst *cc, void *ji); 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); public: + ~CameraConstantsStore(); void init(Glib::ustring baseDir, Glib::ustring userSettingsDir); static CameraConstantsStore *getInstance(void); CameraConst *get(const char make[], const char model[]); diff --git a/rtengine/color.cc b/rtengine/color.cc index f045a84d9..0957ac71e 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -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) { - double var_R = r / 65535.0; - double var_G = g / 65535.0; - double var_B = b / 65535.0; + const double var_R = r / 65535.0; + const double var_G = g / 65535.0; + const double var_B = b / 65535.0; - double var_Min = min(var_R, var_G, var_B); - double var_Max = max(var_R, var_G, var_B); - double del_Max = var_Max - var_Min; + const double var_Min = min(var_R, var_G, var_B); + const double var_Max = max(var_R, var_G, var_B); + const double del_Max = var_Max - var_Min; + + h = 0.f; v = var_Max; if (del_Max < 0.00001 && del_Max > -0.00001) { // no fabs, slow! - h = 0; - s = 0; + s = 0.f; } else { s = del_Max / var_Max; - if ( var_R == var_Max ) { + if (var_R == var_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; - } else if ( var_B == var_Max ) { + } else if (var_B == var_Max) { h = 4.0 + (var_R - var_G) / del_Max; } - h /= 6.0; + h /= 6.f; - if ( h < 0 ) { - h += 1; + if (h < 0.f) { + h += 1.f; } - if ( h > 1 ) { - h -= 1; + if (h > 1.f) { + h -= 1.f; } } } @@ -1530,7 +1531,7 @@ void Color::interpolateRGBColor (float realL, float iplow, float iphigh, int alg int toDo, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo) { float X1, Y1, Z1, X2, Y2, Z2, X, Y, Z, XL, YL, ZL; - float L1 = 0.f, L2, LL, a_1 = 0.f, b_1 = 0.f, a_2, b_2, a_L, b_L; + float L1 = 0.f, L2, LL, a_1 = 0.f, b_1 = 0.f, a_2 = 0.f, b_2 = 0.f, a_L, b_L; // converting color 1 to Lab (image) Color::rgbxyz(r1, g1, b1, X1, Y1, Z1, xyz_rgb); diff --git a/rtengine/colortemp.cc b/rtengine/colortemp.cc index 5cf880b41..ea90f2735 100644 --- a/rtengine/colortemp.cc +++ b/rtengine/colortemp.cc @@ -1141,11 +1141,9 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double x, y, z; double Xchk[50], Ychk[50], Zchk[50]; //50 : I think it's a good limit for number of color : for CRI and Palette double Xcam02[50], Ycam02[50], Zcam02[50]; - double Xcam02pal[50], Ycam02pal[50], Zcam02pal[50]; double XchkLamp[50], YchkLamp[50], ZchkLamp[50]; double Xcam02Lamp[50], Ycam02Lamp[50], Zcam02Lamp[50]; - double Xpal[50], Ypal[50], Zpal[50]; const double epsilon = 0.008856; //Lab const double whiteD50[3] = {0.9646019585, 1.0, 0.8244507152}; //calculate with this tool : spect 5nm double CAM02BB00, CAM02BB01, CAM02BB02, CAM02BB10, CAM02BB11, CAM02BB12, CAM02BB20, CAM02BB21, CAM02BB22; //for CIECAT02 @@ -1153,105 +1151,74 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double xr[50], yr[50], zr[50]; double fx[50], fy[50], fz[50]; - int palet = -1; - bool palette = false; +// bool palette = false; // double tempalet; // correlated temperature // We first test for specially handled methods if (method == "Daylight" ) { spectrum_to_xyz_preset(Daylight5300_spect, x, y, z); - palet = 0; /*tempalet=5300;*/ } else if(method == "Cloudy" ) { spectrum_to_xyz_preset(Cloudy6200_spect, x, y, z); - palet = 1; /*tempalet=6200;*/ } else if(method == "Shade" ) { spectrum_to_xyz_preset(Shade7600_spect, x, y, z); - palet = 2; /*tempalet=7600;*/ } else if(method == "Tungsten" ) { spectrum_to_xyz_preset(A2856_spect, x, y, z); - palet = 3; /*tempalet=2856;*/ } else if(method == "Fluo F1" ) { spectrum_to_xyz_preset(FluoF1_spect, x, y, z); - palet = 4; /*tempalet=6430;*/ } else if(method == "Fluo F2" ) { spectrum_to_xyz_preset(FluoF2_spect, x, y, z); - palet = 5; /*tempalet=4230;*/ } else if(method == "Fluo F3" ) { spectrum_to_xyz_preset(FluoF3_spect, x, y, z); - palet = 6; /*tempalet=3450;*/ } else if(method == "Fluo F4" ) { spectrum_to_xyz_preset(FluoF4_spect, x, y, z); - palet = 7; /*tempalet=2940;*/ } else if(method == "Fluo F5" ) { spectrum_to_xyz_preset(FluoF5_spect, x, y, z); - palet = 8; /*tempalet=6350;*/ } else if(method == "Fluo F6" ) { spectrum_to_xyz_preset(FluoF6_spect, x, y, z); - palet = 9; /*tempalet=4150;*/ } else if(method == "Fluo F7" ) { spectrum_to_xyz_preset(FluoF7_spect, x, y, z); - palet = 10; /*tempalet=6500;*/ } else if(method == "Fluo F8" ) { spectrum_to_xyz_preset(FluoF8_spect, x, y, z); - palet = 11; /*tempalet=5020;*/ } else if(method == "Fluo F9" ) { spectrum_to_xyz_preset(FluoF9_spect, x, y, z); - palet = 12; /*tempalet=4330;*/ } else if(method == "Fluo F10" ) { spectrum_to_xyz_preset(FluoF10_spect, x, y, z); - palet = 13; /*tempalet=5300;*/ } else if(method == "Fluo F11" ) { spectrum_to_xyz_preset(FluoF11_spect, x, y, z); - palet = 14; /*tempalet=4000;*/ } else if(method == "Fluo F12" ) { spectrum_to_xyz_preset(FluoF12_spect, x, y, z); - palet = 15; /*tempalet=3000;*/ } else if(method == "HMI Lamp" ) { spectrum_to_xyz_preset(HMI_spect, x, y, z); - palet = 16; /*tempalet=4760;*/ } else if(method == "GTI Lamp" ) { spectrum_to_xyz_preset(GTI_spect, x, y, z); - palet = 17; /*tempalet=5000;*/ } else if(method == "JudgeIII Lamp" ) { spectrum_to_xyz_preset(JudgeIII_spect, x, y, z); - palet = 18; /*tempalet=5100;*/ } else if(method == "Solux Lamp 3500K" ) { spectrum_to_xyz_preset(Solux3500_spect, x, y, z); - palet = 19; /*tempalet=3480;*/ } else if(method == "Solux Lamp 4100K" ) { spectrum_to_xyz_preset(Solux4100_spect, x, y, z); - palet = 20; /*tempalet=3930;*/ } else if(method == "Solux Lamp 4700K" ) { spectrum_to_xyz_preset(Solux4700_spect, x, y, z); - palet = 21; /*tempalet=4700;*/ } else if(method == "NG Solux Lamp 4700K" ) { spectrum_to_xyz_preset(NG_Solux4700_spect, x, y, z); - palet = 22; /*tempalet=4480;*/ } else if(method == "LED LSI Lumelex 2040") { spectrum_to_xyz_preset(NG_LEDLSI2040_spect, x, y, z); - palet = 23; /*tempalet=2970;*/ } else if(method == "LED CRS SP12 WWMR16" ) { spectrum_to_xyz_preset(NG_CRSSP12WWMR16_spect, x, y, z); - palet = 24; /*tempalet=3050;*/ } else if(method == "Flash 5500K" ) { spectrum_to_xyz_preset(Flash5500_spect, x, y, z); - palet = 25; /*tempalet=5500;*/ } else if(method == "Flash 6000K" ) { spectrum_to_xyz_preset(Flash6000_spect, x, y, z); - palet = 26; /*tempalet=6000;*/ } else if(method == "Flash 6500K" ) { spectrum_to_xyz_preset(Flash6500_spect, x, y, z); - palet = 27; /*tempalet=6500;*/ } else { // otherwise we use the Temp+Green generic solution if (temp <= INITIALBLACKBODY) { // if temperature is between 2000K and 4000K we use blackbody, because there will be no Daylight reference below 4000K... // of course, the previous version of RT used the "magical" but wrong formula of U.Fuchs (Ufraw). spectrum_to_xyz_blackbody(temp, x, y, z); - palet = 28; } else { // from 4000K up to 25000K: using the D illuminant (daylight) which is standard - palet = 29; if (temp <= 7000) { x_D = -4.6070e9 / (temp * temp * temp) + 2.9678e6 / (temp * temp) + 0.09911e3 / temp + 0.244063; @@ -1321,129 +1288,6 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, gmul /= max; bmul /= max; - if(palette) // palette of color : 32 skin, 4 grey, 4 blue sky - //calculate L a b in function of color and illuminant - //J.Desmis january 2012 - { - double x_x, y_y, z_z; - // illuminants - // color - const double* spec_colorpalet[] = { - ColabSkin98_m2_10_spect, ColabSkin95_0_4_spect, ColabSkin91_4_14_spect, ColabSkin90_m1_20_spect, - ColorchechSGSkiK285_11_17_spect, ColabSkin87_8_8_spect, ColabSkin87_3_10_spect, ColabSkin89_8_21_spect, - ColabSkin70_7_32_spect, ColabSkin77_12_21_spect, ColabSkin75_8_4_spect, ColabSkin75_10_33_spect, - ColorchechSkiB166_18_18_spect, ColabSkin65_7_24_spect, ColorchechSGSkiF763_14_26_spect, ColabSkin65_33_11_spect, - ColabSkin57_19_6_spect, ColabSkin57_4_19_spect, ColabSkin57_10_28_spect, ColabSkin57_22_18_spect, - ColabSkin40_17_17_spect, ColabSkin40_7_19_spect, ColabSkin40_4_11_spect, ColabSkin40_17_6_spect, - ColorchechSkiA138_13_14_spect, ColabSkin33_6_15_spect, ColabSkin35_15_17_spect, ColabSkin33_15_5_spect, - ColabSkin26_18_18_spect, ColabSkin24_7_5_spect, ColabSkin24_5_6_spect, ColabSkin20_4_2_spect, - ColabSky42_0_m24_spect, ColorchechBluC150_m5_m22_spect, ColorchechWhiA496_spect, ColorchechSGBlaN3_6_spect, - JDC468_GraK14_44_spect, ColorchechGraC4_67_spect, ColabSky60_0_m31_spect, ColorchechDCBluN881_m7_m14_spect - //ColabSkin33_10_15_spect, - //ColabSkin81_2_14_spect, - }; - - int N_col = sizeof(spec_colorpalet) / sizeof(spec_colorpalet[0]); //number of color - - if(palet < 28) { - const double* spect_illummax[] = { - Daylight5300_spect, Cloudy6200_spect, Shade7600_spect, A2856_spect, FluoF1_spect, FluoF2_spect, FluoF3_spect, FluoF4_spect, FluoF5_spect, FluoF6_spect, FluoF7_spect, - FluoF8_spect, FluoF9_spect, FluoF10_spect, FluoF11_spect, FluoF12_spect, HMI_spect, GTI_spect, JudgeIII_spect, Solux3500_spect, Solux4100_spect, Solux4700_spect, NG_Solux4700_spect, NG_CRSSP12WWMR16_spect, NG_CRSSP12WWMR16_spect, - Flash5500_spect, Flash6000_spect, Flash6500_spect - }; - for(int i = 0; i < N_col; i++) { - spectrum_to_color_xyz_preset(spec_colorpalet[i], spect_illummax[palet], x_x, y_y, z_z); - Xpal[i] = x_x; - Ypal[i] = y_y; - Zpal[i] = z_z; - } - } else /*if(palet >= 28)*/ { - if(temp < INITIALBLACKBODY) { - for(int i = 0; i < N_col; i++) { - spectrum_to_color_xyz_blackbody(spec_colorpalet[i], temp, x_x, y_y, z_z); - Xpal[i] = x_x; - Ypal[i] = y_y; - Zpal[i] = z_z; - } - } else { - double m11p, m22p; - m11p = m1; - m22p = m2; - - for(int i = 0; i < N_col; i++) { // calculate XYZ palette for illuminant and color - spectrum_to_color_xyz_daylight(spec_colorpalet[i], m11p, m22p, x_x, y_y, z_z); - Xpal[i] = x_x; - Ypal[i] = y_y; - Zpal[i] = z_z; - } - } - } - - double xp = xD; - double yp = yD; - double Xwbpal = xp / yp; //white balance - double Ywbpal = 1.0; - double Zwbpal = (1.0 - xp - yp) / yp; - //chromatic adaptation CIECAT02 at temp - double adap = 1.0; - cieCAT02(Xwbpal, Ywbpal, Zwbpal, CAM02BB00, CAM02BB01, CAM02BB02, CAM02BB10, CAM02BB11, CAM02BB12, CAM02BB20, CAM02BB21, CAM02BB22, adap); - - //here new value of X,Y,Z with chromatic CAM02 adaptation - for(int i = 0; i < N_col; i++) { - Xcam02pal[i] = CAM02BB00 * Xpal[i] + CAM02BB01 * Ypal[i] + CAM02BB02 * Zpal[i] ; - Ycam02pal[i] = CAM02BB10 * Xpal[i] + CAM02BB11 * Ypal[i] + CAM02BB12 * Zpal[i] ; - Zcam02pal[i] = CAM02BB20 * Xpal[i] + CAM02BB21 * Ypal[i] + CAM02BB22 * Zpal[i] ; - //printf("CoulXYZ %i X %f Y %f Z %f\n", i, Xpal[i],Ypal[i],Zpal[i]); - //printf("CoulCAM %i X %f Y %f Z %f\n", i, Xcam02pal[i],Ycam02pal[i],Zcam02pal[i]); - } - - //Calculate Lab - for(int i = 0; i < N_col; i++) { - xr[i] = Xcam02pal[i] / whiteD50[0]; - yr[i] = Ycam02pal[i] / whiteD50[1]; - zr[i] = Zcam02pal[i] / whiteD50[2]; - - // xr, yr , zr > epsilon - if(xr[i] > epsilon) { - fx[i] = std::cbrt(xr[i]); - } else { - fx[i] = (903.3 * xr[i] + 16.0) / 116.0; - } - - if(yr[i] > epsilon) { - fy[i] = std::cbrt(yr[i]); - } else { - fy[i] = (903.3 * yr[i] + 16.0) / 116.0; - } - - if(zr[i] > epsilon) { - fz[i] = std::cbrt(zr[i]); - } else { - fz[i] = (903.3 * zr[i] + 16.0) / 116.0; - } - } - - //Lab values in function of color and illuminant - //these values can be compared to preview values when using white-balance (skin / sky / BW) - double Lpal[50], apal[50], bpal[50]; - - for(int i = 0; i < N_col; i++) { - Lpal[i] = 116.0 * fy[i] - 16.0; - apal[i] = 500.0 * (fx[i] - fy[i]); - bpal[i] = 200.0 * (fy[i] - fz[i]); - } - - // uncomment to display Lab values - //for(int i=0;iCRI_color != 0) { - printf("Lpal=%2.2f apal=%2.2f bpal=%2.2f\n", Lpal[0], apal[0], bpal[0]); //sample - } - - //} - - } //end palette - // begin CRI_RT : color rendering index RT - adaptation of CRI by J.Desmis // CRI = 100 for Blackbody and Daylight // calculate from spectral data values X, Y, Z , for color of colorchecker24 , SG, DC, JDC_468 diff --git a/rtengine/coord2d.h b/rtengine/coord2d.h index f896cd0d0..bc030f22e 100644 --- a/rtengine/coord2d.h +++ b/rtengine/coord2d.h @@ -28,7 +28,7 @@ class Coord2D public: double x, y; Coord2D (double x_, double y_) : x(x_), y(y_) {} - Coord2D () {} + Coord2D () : x(0), y(0) {} void set (double x_, double y_) { x = x_; diff --git a/rtengine/dcp.cc b/rtengine/dcp.cc index ad0621ce0..43aa98480 100644 --- a/rtengine/dcp.cc +++ b/rtengine/dcp.cc @@ -407,6 +407,7 @@ DCPProfile::DCPProfile(const Glib::ustring& filename) : valid(false), baseline_exposure_offset(0.0) { + delta_info.hue_step = delta_info.val_step = look_info.hue_step = look_info.val_step = 0; constexpr int tiff_float_size = 4; enum class TagKey : int { @@ -1701,6 +1702,15 @@ DCPStore* DCPStore::getInstance() return &instance; } + +DCPStore::~DCPStore() +{ + for (auto &p : profile_cache) { + delete p.second; + } +} + + void DCPStore::init(const Glib::ustring& rt_profile_dir, bool loadAll) { MyMutex::MyLock lock(mutex); diff --git a/rtengine/dcp.h b/rtengine/dcp.h index 5a6858099..10bbf8f7e 100644 --- a/rtengine/dcp.h +++ b/rtengine/dcp.h @@ -152,6 +152,7 @@ class DCPStore final : public NonCopyable { public: + ~DCPStore(); static DCPStore* getInstance(); void init(const Glib::ustring& rt_profile_dir, bool loadAll = true); diff --git a/rtengine/dcraw.h b/rtengine/dcraw.h index 6a1a83391..c467ad5c0 100644 --- a/rtengine/dcraw.h +++ b/rtengine/dcraw.h @@ -345,7 +345,7 @@ void nokia_load_raw(); // pana_bits(int nbits); class pana_bits_t{ public: - pana_bits_t(IMFILE *&i,unsigned &u):ifp(i),load_flags(u){} + pana_bits_t(IMFILE *&i,unsigned &u):ifp(i),load_flags(u),vbits(0){} unsigned operator()(int nbits); private: IMFILE *&ifp; diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 351ce1f08..4b725ea8f 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -397,12 +397,8 @@ void Crop::update (int todo) MyTime t1aue, t2aue; t1aue.set(); - int crW, crH; - - if(settings->leveldnv == 0) { - crW = 100; - crH = 100; - } + int crW = 100; // settings->leveldnv == 0 + int crH = 100; // settings->leveldnv == 0 if(settings->leveldnv == 1) { crW = 250; @@ -1143,7 +1139,7 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte ProcParams& params = parent->params; 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)) { // 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)); @@ -1173,7 +1169,7 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte orw = min(x2 - x1, parent->fw - orx); orh = min(y2 - y1, parent->fh - ory); } - + PreviewProps cp (orx, ory, orw, orh, skip); int orW, orH; diff --git a/rtengine/dfmanager.cc b/rtengine/dfmanager.cc index c71d7f98b..bc35b3c71 100644 --- a/rtengine/dfmanager.cc +++ b/rtengine/dfmanager.cc @@ -211,9 +211,12 @@ void dfInfo::updateRawImage() void dfInfo::updateBadPixelList( RawImage *df ) { + if(!df) { + return; + } const float threshold = 10.f / 8.f; - if( ri->getSensorType() == ST_BAYER || ri->getSensorType() == ST_FUJI_XTRANS ) { + if( df->getSensorType() == ST_BAYER || df->getSensorType() == ST_FUJI_XTRANS ) { std::vector badPixelsTemp; #pragma omp parallel diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index 3bcc8515e..4e206e3bb 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -216,15 +216,19 @@ rtengine::ProfileContent::ProfileContent(const Glib::ustring& fileName) } fseek(f, 0, SEEK_END); - const long length = ftell(f); - fseek(f, 0, SEEK_SET); - char* d = new char[length + 1]; - fread(d, length, 1, f); - d[length] = 0; + long length = ftell(f); + if(length > 0) { + char* d = new char[length + 1]; + fseek(f, 0, SEEK_SET); + length = fread(d, length, 1, f); + d[length] = 0; + data.assign(d, length); + delete[] d; + } else { + data.clear(); + } fclose(f); - data.assign(d, length); - delete[] d; } rtengine::ProfileContent::ProfileContent(cmsHPROFILE hProfile) @@ -276,6 +280,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) { // Reads all profiles from the given profiles dir @@ -1200,8 +1229,7 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams: } // Calculate output profile's rTRC gTRC bTRC - cmsToneCurve* GammaTRC = nullptr; - GammaTRC = cmsBuildParametricToneCurve(nullptr, 5, Parameters); + cmsToneCurve* GammaTRC = cmsBuildParametricToneCurve(nullptr, 5, Parameters); cmsWriteTag(outputProfile, cmsSigRedTRCTag,(void*)GammaTRC ); cmsWriteTag(outputProfile, cmsSigGreenTRCTag,(void*)GammaTRC ); cmsWriteTag(outputProfile, cmsSigBlueTRCTag,(void*)GammaTRC ); diff --git a/rtengine/imagedata.cc b/rtengine/imagedata.cc index 829a0b286..369be2f9a 100644 --- a/rtengine/imagedata.cc +++ b/rtengine/imagedata.cc @@ -362,7 +362,7 @@ void ImageData::extractInfo () if (!lensOk && mnote->getTag ("Lens")) { std::string ldata = mnote->getTag ("Lens")->valueToString (); size_t i = 0, j = 0; - double n[4]; + double n[4] = {0.0}; for (int m = 0; m < 4; m++) { while (i < ldata.size() && ldata[i] != '/') { @@ -380,7 +380,7 @@ void ImageData::extractInfo () int den = atoi(ldata.substr(j, i).c_str()); j = i + 2; i += 2; - n[m] = (double) nom / den; + n[m] = (double) nom / std::max(den,1); } std::ostringstream str; diff --git a/rtengine/imageio.cc b/rtengine/imageio.cc index 8bc5362fd..d252b501f 100644 --- a/rtengine/imageio.cc +++ b/rtengine/imageio.cc @@ -52,7 +52,6 @@ namespace // Opens a file for binary writing and request exclusive lock (cases were you need "wb" mode plus locking) FILE* g_fopen_withBinaryAndLock(const Glib::ustring& fname) { - FILE* f = nullptr; #ifdef WIN32 @@ -61,6 +60,7 @@ FILE* g_fopen_withBinaryAndLock(const Glib::ustring& fname) std::unique_ptr wfname (reinterpret_cast(g_utf8_to_utf16 (fname.c_str (), -1, NULL, NULL, NULL)), g_free); HANDLE hFile = CreateFileW ( wfname.get (), GENERIC_READ | GENERIC_WRITE, 0 /* no sharing allowed */, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + FILE* f = nullptr; if (hFile != INVALID_HANDLE_VALUE) { f = _fdopen (_open_osfhandle ((intptr_t)hFile, 0), "wb"); @@ -68,7 +68,7 @@ FILE* g_fopen_withBinaryAndLock(const Glib::ustring& fname) #else - f = ::g_fopen (fname.c_str (), "wb"); + FILE* f = ::g_fopen (fname.c_str (), "wb"); #endif diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index d6d0a618f..0eec1325a 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -69,9 +69,9 @@ public: virtual int load (const Glib::ustring &fname, int imageNum = 0, bool batch = false) = 0; virtual void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse, bool prepareDenoise = true) {}; virtual void demosaic (const RAWParams &raw) {}; - virtual void retinex (ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, 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) {}; - virtual void retinexPrepareCurves (RetinexParams retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, RetinexgaintransmissionCurve &retinexgaintransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI) {}; - virtual void retinexPrepareBuffers (ColorManagementParams cmp, RetinexParams retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI) {}; + virtual void retinex (ColorManagementParams cmp, const RetinexParams &deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, 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) {}; + virtual void retinexPrepareCurves (const RetinexParams &retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, RetinexgaintransmissionCurve &retinexgaintransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI) {}; + virtual void retinexPrepareBuffers (ColorManagementParams cmp, const RetinexParams &retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI) {}; virtual void flushRawData () {}; virtual void flushRGB () {}; virtual void HLRecovery_Global (ToneCurveParams hrp) {}; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 5c96aa6fd..fcbde90e4 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -5471,7 +5471,6 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu editID = pipetteBuffer->getEditID(); if (editID != EUID_None) { - editPipette = true; switch (pipetteBuffer->getDataProvider()->getCurrSubscriber()->getPipetteBufferType()) { case (BT_IMAGEFLOAT): @@ -5481,6 +5480,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu break; case (BT_SINGLEPLANE_FLOAT): + editPipette = true; editWhatever = pipetteBuffer->getSinglePlaneBuffer(); break; } @@ -6438,7 +6438,7 @@ void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, float //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. float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f)); @@ -6585,7 +6585,7 @@ void ImProcFunctions::EPDToneMap (LabImage *lab, unsigned int Iterates, int skip fwrite(L, N, sizeof(float), 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. float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f)); diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 028e55a33..d7d807a4b 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -89,7 +89,7 @@ class ImProcFunctions } double rd, gd, bd; - double yr[4], yg[4], yb[4]; + double yr[4] = {0.0}, yg[4] = {0.0}, yb[4] = {0.0}; for (int k = ys, kx = 0; k < ys + 4; k++, kx++) { rd = gd = bd = 0.0; @@ -150,7 +150,7 @@ class ImProcFunctions } double rd; - double yr[4]; + double yr[4] = {0.0}; for (int k = ys, kx = 0; k < ys + 4; k++, kx++) { rd = 0.0; diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index 321298349..e851cf56c 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -136,7 +136,7 @@ namespace rtengine extern const Settings* settings; -void RawImageSource::MSR(float** luminance, float** originalLuminance, float **exLuminance, LUTf & mapcurve, bool &mapcontlutili, int width, int height, RetinexParams deh, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) +void RawImageSource::MSR(float** luminance, float** originalLuminance, float **exLuminance, LUTf & mapcurve, bool &mapcontlutili, int width, int height, const RetinexParams &deh, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) { if (deh.enabled) {//enabled @@ -273,8 +273,9 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } - float varx = 0.f; - float limdx, ilimdx; + float varx = vart; + float limdx = limD; + float ilimdx = ilimD; if(gradvart != 0) { if(gradvart == 1) { @@ -294,10 +295,6 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e limdx = limD * (0.4f * it + 0.6f); ilimdx = 1.f / limdx; } - } else { - varx = vart; - limdx = limD; - ilimdx = ilimD; } scal = round(sc); diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index d01049774..c4d9a0a01 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -690,7 +690,7 @@ void ImProcFunctions::transformLuminanceOnly (Imagefloat* original, Imagefloat* #pragma omp parallel for schedule(dynamic,16) if (multiThread) for (int y = 0; y < transformed->getHeight(); y++) { - double vig_y_d = (double) (y + cy) - vig_h2 ; + double vig_y_d = applyVignetting ? (double) (y + cy) - vig_h2 : 0.0; for (int x = 0; x < transformed->getWidth(); x++) { double factor = 1.0; diff --git a/rtengine/ipvibrance.cc b/rtengine/ipvibrance.cc index 49f956602..68efd1aea 100644 --- a/rtengine/ipvibrance.cc +++ b/rtengine/ipvibrance.cc @@ -78,8 +78,7 @@ void ImProcFunctions::vibrance (LabImage* lab) // int skip=1; //scale==1 ? 1 : 16; bool skinCurveIsSet = false; - DiagonalCurve* dcurve = nullptr; - dcurve = new DiagonalCurve (params->vibrance.skintonescurve, CURVES_MIN_POLY_POINTS); + DiagonalCurve* dcurve = new DiagonalCurve (params->vibrance.skintonescurve, CURVES_MIN_POLY_POINTS); if (dcurve) { if (!dcurve->isIdentity()) { diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index 5d899617b..a5c9b6d7a 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -923,9 +923,8 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int ind = 1; //Flat curve for Contrast=f(H) in levels - FlatCurve* ChCurve = nullptr;//curve C=f(H) + FlatCurve* ChCurve = new FlatCurve(params->wavelet.Chcurve); //curve C=f(H) bool Chutili = false; - ChCurve = new FlatCurve(params->wavelet.Chcurve); if (!ChCurve || ChCurve->isIdentity()) { if (ChCurve) { @@ -953,9 +952,8 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int } //Flat curve for H=f(H) in residual image - FlatCurve* hhCurve = nullptr;//curve H=f(H) + FlatCurve* hhCurve = new FlatCurve(params->wavelet.hhcurve); //curve H=f(H) bool hhutili = false; - hhCurve = new FlatCurve(params->wavelet.hhcurve); if (!hhCurve || hhCurve->isIdentity()) { if (hhCurve) { @@ -1253,17 +1251,22 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int delete [] meanN; delete [] sigma; delete [] sigmaN; - + delete [] MaxP; + delete [] MaxN; } #ifdef _RT_NESTED_OPENMP omp_set_nested(oldNested); #endif - if(numtiles > 1) { + if(numtiles != 1) { dst->CopyFrom(dsttmp); delete dsttmp; } +#ifdef _DEBUG + delete MunsDebugInfo; +#endif + } #undef TS @@ -1653,7 +1656,7 @@ void ImProcFunctions::EPDToneMapResid(float * WavCoeffs_L0, unsigned int Iterat } - 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. #ifdef _RT_NESTED_OPENMP @@ -3399,14 +3402,18 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, } bool useOpacity; - float mulOpacity; + float mulOpacity = 0.f; if(useChannelA) { useOpacity = cp.opaRG; - mulOpacity = cp.mulopaRG[level]; + if(level < 9) { + mulOpacity = cp.mulopaRG[level]; + } } else { useOpacity = cp.opaBY; - mulOpacity = cp.mulopaBY[level]; + if(level < 9) { + mulOpacity = cp.mulopaBY[level]; + } } if((useOpacity && level < 9 && mulOpacity != 0.f) && cp.toningena) { //toning diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index 821194afe..ca1ab8405 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -172,7 +172,7 @@ void LCPPersModel::print() const // if !vignette then geometric and CA LCPMapper::LCPMapper(LCPProfile* pProf, float focalLength, float focalLength35mm, float focusDist, float aperture, bool vignette, bool useCADistP, - int fullWidth, int fullHeight, const CoarseTransformParams& coarse, int rawRotationDeg) + int fullWidth, int fullHeight, const CoarseTransformParams& coarse, int rawRotationDeg) :useCADist(false), swapXY(false), isFisheye(false), enableCA(false) { if (pProf == nullptr) { return; @@ -361,6 +361,11 @@ SSEFUNCTION void LCPMapper::processVignetteLine3Channels(int width, int y, float LCPProfile::LCPProfile(const Glib::ustring &fname) { + for (int i = 0; i < MaxPersModelCount; i++) { + aPersModel[i] = nullptr; + } + pCurPersModel = nullptr; + const int BufferSize = 8192; char buf[BufferSize]; @@ -378,27 +383,25 @@ LCPProfile::LCPProfile(const Glib::ustring &fname) isFisheye = inCamProfiles = firstLIDone = inPerspect = inAlternateLensID = inAlternateLensNames = false; sensorFormatFactor = 1; - for (int i = 0; i < MaxPersModelCount; i++) { - aPersModel[i] = nullptr; - } - persModelCount = 0; *inInvalidTag = 0; FILE *pFile = g_fopen(fname.c_str (), "rb"); - bool done; + if(pFile) { + bool done; - do { - int bytesRead = (int)fread(buf, 1, BufferSize, pFile); - done = feof(pFile); + do { + int bytesRead = (int)fread(buf, 1, BufferSize, pFile); + done = feof(pFile); - if (XML_Parse(parser, buf, bytesRead, done) == XML_STATUS_ERROR) { - throw "Invalid XML in LCP file"; - } - } while (!done); + if (XML_Parse(parser, buf, bytesRead, done) == XML_STATUS_ERROR) { + throw "Invalid XML in LCP file"; + } + } while (!done); - fclose(pFile); + fclose(pFile); + } XML_ParserFree(parser); @@ -412,6 +415,19 @@ LCPProfile::LCPProfile(const Glib::ustring &fname) 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 int LCPProfile::filterBadFrames(double maxAvgDevFac, int minFramesLeft) { @@ -722,7 +738,7 @@ void XMLCALL LCPProfile::XmlStartHandler(void *pLCPProfile, const char *el, cons nameStart++; } - strcpy(pProf->lastTag, nameStart); + strncpy(pProf->lastTag, nameStart, 255); pProf->handle_text(attr[i+1]); //XmlTextHandler(pLCPProfile, attr[i + 1], strlen(attr[i + 1])); @@ -737,7 +753,7 @@ void XMLCALL LCPProfile::XmlTextHandler(void *pLCPProfile, const XML_Char *s, in if (!pProf->inCamProfiles || pProf->inAlternateLensID || pProf->inAlternateLensNames || *pProf->inInvalidTag) { return; } - + for (int i = 0; i < len; ++i) { pProf->textbuf << s[i]; } @@ -746,8 +762,6 @@ void XMLCALL LCPProfile::XmlTextHandler(void *pLCPProfile, const XML_Char *s, in 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) bool onlyWhiteSpace = true; for (size_t i = 0; i < text.size(); ++i) { @@ -766,6 +780,8 @@ void LCPProfile::handle_text(std::string text) // convert to null terminated char* tag = pProf->lastTag; + const char* raw = text.c_str(); + // Common data section if (!pProf->firstLIDone) { // Generic tags are the same for all @@ -886,6 +902,15 @@ LCPStore* LCPStore::getInstance() return &instance_; } + +LCPStore::~LCPStore() +{ + for (auto &p : profileCache) { + delete p.second; + } +} + + LCPProfile* LCPStore::getProfile (Glib::ustring filename) { if (filename.length() == 0 || !isValidLCPFileName(filename)) { diff --git a/rtengine/lcp.h b/rtengine/lcp.h index 8cfcd5694..f7164117f 100644 --- a/rtengine/lcp.h +++ b/rtengine/lcp.h @@ -110,6 +110,7 @@ public: LCPPersModel* aPersModel[MaxPersModelCount]; // Do NOT use std::list or something, it's buggy in GCC! 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 @@ -124,6 +125,7 @@ class LCPStore std::map profileCache; public: + ~LCPStore(); Glib::ustring getDefaultCommonDirectory() const; bool isValidLCPFileName(Glib::ustring filename) const; LCPProfile* getProfile(Glib::ustring filename); diff --git a/rtengine/myfile.cc b/rtengine/myfile.cc index 09d9cd48f..903fd8354 100644 --- a/rtengine/myfile.cc +++ b/rtengine/myfile.cc @@ -19,9 +19,6 @@ #include "myfile.h" #include #include -#ifdef BZIP_SUPPORT -#include -#endif // get mmap() sorted out #ifdef MYFILE_MMAP @@ -116,85 +113,6 @@ IMFILE* fopen (const char* fname) mf->data = (char*)data; mf->eof = false; -#ifdef BZIP_SUPPORT - { - bool bzip = false; - Glib::ustring bname = Glib::path_get_basename(fname); - size_t lastdot = bname.find_last_of ('.'); - - if (lastdot != bname.npos) { - bzip = bname.substr (lastdot).casefold() == Glib::ustring(".bz2").casefold(); - } - - if (bzip) { - int ret; - - // initialize bzip stream structure - bz_stream stream; - stream.bzalloc = nullptr; - stream.bzfree = nullptr; - stream.opaque = nullptr; - ret = BZ2_bzDecompressInit(&stream, 0, 0); - - if (ret != BZ_OK) { - printf("bzip initialization failed with error %d\n", ret); - } else { - // allocate initial buffer for decompressed data - unsigned int buffer_out_count = 0; // bytes of decompressed data - unsigned int buffer_size = 10 * 1024 * 1024; // 10 MB, extended dynamically if needed - char* buffer = nullptr; - - stream.next_in = mf->data; // input data address - stream.avail_in = mf->size; - - while (ret == BZ_OK) { - buffer = static_cast( realloc(buffer, buffer_size)); // allocate/resize buffer - - if (!buffer) { - free(buffer); - } - - stream.next_out = buffer + buffer_out_count; // output data adress - stream.avail_out = buffer_size - buffer_out_count; - - ret = BZ2_bzDecompress(&stream); - - buffer_size *= 2; // increase buffer size for next iteration - buffer_out_count = stream.total_out_lo32; - - if (stream.total_out_hi32 > 0) { - printf("bzip decompressed data byte count high byte is nonzero: %d\n", stream.total_out_hi32); - } - } - - if (ret == BZ_STREAM_END) { - //delete [] mf->data; - // close memory mapping, setting fd -1 will ensure deletion of mf->data upon fclose() - mf->fd = -1; - munmap((void*)mf->data, mf->size); - close(mf->fd); - - char* realData = new char [buffer_out_count]; - memcpy(realData, buffer, buffer_out_count); - - mf->data = realData; - mf->size = buffer_out_count; - } else { - printf("bzip decompression failed with error %d\n", ret); - } - - // cleanup - free(buffer); - ret = BZ2_bzDecompressEnd(&stream); - - if (ret != BZ_OK) { - printf("bzip cleanup failed with error %d\n", ret); - } - } - } - } -#endif // BZIP_SUPPORT - return mf; } @@ -247,79 +165,6 @@ IMFILE* gfopen (const char* fname) mf->pos = 0; mf->eof = false; -#ifdef BZIP_SUPPORT - { - bool bzip = false; - Glib::ustring bname = Glib::path_get_basename(fname); - size_t lastdot = bname.find_last_of ('.'); - - if (lastdot != bname.npos) { - bzip = bname.substr (lastdot).casefold() == Glib::ustring(".bz2").casefold(); - } - - if (bzip) { - int ret; - - // initialize bzip stream structure - bz_stream stream; - stream.bzalloc = 0; - stream.bzfree = 0; - stream.opaque = 0; - ret = BZ2_bzDecompressInit(&stream, 0, 0); - - if (ret != BZ_OK) { - printf("bzip initialization failed with error %d\n", ret); - } else { - // allocate initial buffer for decompressed data - unsigned int buffer_out_count = 0; // bytes of decompressed data - unsigned int buffer_size = 10 * 1024 * 1024; // 10 MB, extended dynamically if needed - char* buffer = 0; - - stream.next_in = mf->data; // input data address - stream.avail_in = mf->size; - - while (ret == BZ_OK) { - buffer = static_cast( realloc(buffer, buffer_size)); // allocate/resize buffer - - if (!buffer) { - free(buffer); - } - - stream.next_out = buffer + buffer_out_count; // output data adress - stream.avail_out = buffer_size - buffer_out_count; - - ret = BZ2_bzDecompress(&stream); - - buffer_size *= 2; // increase buffer size for next iteration - buffer_out_count = stream.total_out_lo32; - - if (stream.total_out_hi32 > 0) { - printf("bzip decompressed data byte count high byte is nonzero: %d\n", stream.total_out_hi32); - } - } - - if (ret == BZ_STREAM_END) { - delete [] mf->data; - char* realData = new char [buffer_out_count]; - memcpy(realData, buffer, buffer_out_count); - - mf->data = realData; - mf->size = buffer_out_count; - } else { - printf("bzip decompression failed with error %d\n", ret); - } - - // cleanup - free(buffer); - ret = BZ2_bzDecompressEnd(&stream); - - if (ret != BZ_OK) { - printf("bzip cleanup failed with error %d\n", ret); - } - } - } - } -#endif // BZIP_SUPPORT return mf; } #endif //MYFILE_MMAP @@ -361,10 +206,10 @@ int fscanf (IMFILE* f, const char* s ...) // of file data and vsscanf() won't tell us how many characters that // were parsed. However, only dcraw.cc code use it and only for "%f" and // "%d", so we make a dummy fscanf here just to support dcraw case. - char buf[50], *endptr = nullptr; + char buf[51], *endptr = nullptr; int copy_sz = f->size - f->pos; - if (copy_sz > static_cast(sizeof(buf))) { + if (copy_sz >= static_cast(sizeof(buf))) { copy_sz = sizeof(buf) - 1; } diff --git a/rtengine/pixelshift.cc b/rtengine/pixelshift.cc index e7d6b86c7..5a7e88f1c 100644 --- a/rtengine/pixelshift.cc +++ b/rtengine/pixelshift.cc @@ -369,12 +369,6 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA } } } - } else if(bayerParams.pixelShiftMotionCorrectionMethod != RAWParams::BayerSensor::Off) { - if(bayerParams.pixelShiftLmmse) { - lmmse_interpolate_omp(winw, winh, rawData, red, green, blue, bayerParams.lmmse_iterations); - } else { - amaze_demosaic_RT(winx, winy, winw, winh, rawData, red, green, blue); - } } const bool adaptive = bayerParams.pixelShiftAutomatic; @@ -561,89 +555,107 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA float blueBrightness[4] = {1.f, 1.f, 1.f, 1.f}; if(equalBrightness) { - LUT *histogreen[4]; - LUT *histored[4]; - LUT *histoblue[4]; - - for(int i = 0; i < 4; ++i) { - histogreen[i] = new LUT(65536); - histogreen[i]->clear(); - histored[i] = new LUT(65536); - histored[i]->clear(); - histoblue[i] = new LUT(65536); - histoblue[i]->clear(); - } - -#ifdef _OPENMP - #pragma omp parallel -#endif - { - LUT *histogreenThr[4]; - LUT *historedThr[4]; - LUT *histoblueThr[4]; + if(rawDirty) { + LUT *histogreen[4]; + LUT *histored[4]; + LUT *histoblue[4]; for(int i = 0; i < 4; ++i) { - histogreenThr[i] = new LUT(65536); - histogreenThr[i]->clear(); - historedThr[i] = new LUT(65536); - historedThr[i]->clear(); - histoblueThr[i] = new LUT(65536); - histoblueThr[i]->clear(); + histogreen[i] = new LUT(65536); + histogreen[i]->clear(); + histored[i] = new LUT(65536); + histored[i]->clear(); + histoblue[i] = new LUT(65536); + histoblue[i]->clear(); } #ifdef _OPENMP - #pragma omp for schedule(dynamic,16) nowait + #pragma omp parallel +#endif + { + LUT *histogreenThr[4]; + LUT *historedThr[4]; + LUT *histoblueThr[4]; + + for(int i = 0; i < 4; ++i) { + histogreenThr[i] = new LUT(65536); + histogreenThr[i]->clear(); + historedThr[i] = new LUT(65536); + historedThr[i]->clear(); + histoblueThr[i] = new LUT(65536); + histoblueThr[i]->clear(); + } + +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) nowait #endif - for(int i = winy + 1; i < winh - 1; ++i) { - int j = winx + 1; - int c = FC(i, j); + for(int i = winy + 1; i < winh - 1; ++i) { + int j = winx + 1; + int c = FC(i, j); - bool bluerow = (c + FC(i, j + 1)) == 3; + bool bluerow = (c + FC(i, j + 1)) == 3; - for(int j = winx + 1, offset = FC(i, j) & 1; j < winw - 1; ++j, offset ^= 1) { - (*histogreenThr[1 - offset])[(*rawDataFrames[1 - offset])[i - offset + 1][j]]++; - (*histogreenThr[3 - offset])[(*rawDataFrames[3 - offset])[i + offset][j + 1]]++; + for(int j = winx + 1, offset = FC(i, j) & 1; j < winw - 1; ++j, offset ^= 1) { + (*histogreenThr[1 - offset])[(*rawDataFrames[1 - offset])[i - offset + 1][j]]++; + (*histogreenThr[3 - offset])[(*rawDataFrames[3 - offset])[i + offset][j + 1]]++; - if(bluerow) { - (*historedThr[2 - offset])[(*rawDataFrames[2 - offset])[i + 1][j - offset + 1]]++; - (*histoblueThr[(offset << 1) + offset])[(*rawDataFrames[(offset << 1) + offset])[i][j + offset]]++; - } else { - (*historedThr[(offset << 1) + offset])[(*rawDataFrames[(offset << 1) + offset])[i][j + offset]]++; - (*histoblueThr[2 - offset])[(*rawDataFrames[2 - offset])[i + 1][j - offset + 1]]++; + if(bluerow) { + (*historedThr[2 - offset])[(*rawDataFrames[2 - offset])[i + 1][j - offset + 1]]++; + (*histoblueThr[(offset << 1) + offset])[(*rawDataFrames[(offset << 1) + offset])[i][j + offset]]++; + } else { + (*historedThr[(offset << 1) + offset])[(*rawDataFrames[(offset << 1) + offset])[i][j + offset]]++; + (*histoblueThr[2 - offset])[(*rawDataFrames[2 - offset])[i + 1][j - offset + 1]]++; + } + } + } + +#ifdef _OPENMP + #pragma omp critical +#endif + { + for(int i = 0; i < 4; ++i) { + (*histogreen[i]) += (*histogreenThr[i]); + delete histogreenThr[i]; + (*histored[i]) += (*historedThr[i]); + delete historedThr[i]; + (*histoblue[i]) += (*histoblueThr[i]); + delete histoblueThr[i]; } } } -#ifdef _OPENMP - #pragma omp critical -#endif - { - for(int i = 0; i < 4; ++i) { - (*histogreen[i]) += (*histogreenThr[i]); - delete histogreenThr[i]; - (*histored[i]) += (*historedThr[i]); - delete historedThr[i]; - (*histoblue[i]) += (*histoblueThr[i]); - delete histoblueThr[i]; - } + calcFrameBrightnessFactor(frame, (winh - 2) * (winw - 2) / 4, histored, redBrightness); + calcFrameBrightnessFactor(frame, (winh - 2) * (winw - 2) / 4, histoblue, blueBrightness); + calcFrameBrightnessFactor(frame, (winh - 2) * (winw - 2) / 2, histogreen, greenBrightness); + + for(int i = 0; i < 4; ++i) { + psRedBrightness[i] = redBrightness[i]; + psGreenBrightness[i] = greenBrightness[i]; + psBlueBrightness[i] = blueBrightness[i]; + } + rawDirty = false; + + for(int i = 0; i < 4; ++i) { + delete histored[i]; + delete histoblue[i]; + delete histogreen[i]; + } + if(plistener) { + plistener->setProgress(0.15); + } + + } else { + for(int i = 0; i < 4; ++i) { + redBrightness[i] = psRedBrightness[i]; + greenBrightness[i] = psGreenBrightness[i]; + blueBrightness[i] = psBlueBrightness[i]; } } - - calcFrameBrightnessFactor(frame, (winh - 2) * (winw - 2) / 4, histored, redBrightness); - calcFrameBrightnessFactor(frame, (winh - 2) * (winw - 2) / 4, histoblue, blueBrightness); - calcFrameBrightnessFactor(frame, (winh - 2) * (winw - 2) / 2, histogreen, greenBrightness); - - for(int i = 0; i < 4; ++i) { - delete histored[i]; - delete histoblue[i]; - delete histogreen[i]; - } - } - - if(!equalChannel) { - for(int i = 0; i < 4; ++i) { - redBrightness[i] = blueBrightness[i] = greenBrightness[i]; + if(!equalChannel) { + for(int i = 0; i < 4; ++i) { + redBrightness[i] = blueBrightness[i] = greenBrightness[i]; + } } } @@ -684,6 +696,10 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA } } + if(plistener) { + plistener->setProgress(0.3); + } + // now that the temporary planes are filled for easy access we do the motion detection array2D psMask(winw, winh); @@ -758,13 +774,13 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA continue; } } - - if(showOnlyMask) { // we want only motion mask => paint areas without motion in pure black - red[i + offsY][j + offsX] = green[i + offsY][j + offsX] = blue[i + offsY][j + offsX] = 0.f; - } } } + if(plistener) { + plistener->setProgress(0.45); + } + if(blurMap) { #ifdef _OPENMP #pragma omp parallel @@ -772,6 +788,10 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA { gaussianBlur(psMask, psMask, winw, winh, sigma); } + if(plistener) { + plistener->setProgress(0.6); + } + } array2D mask(winw, winh, ARRAY2D_CLEAR_DATA); @@ -805,6 +825,10 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA } } + if(plistener) { + plistener->setProgress(0.75); + } + if(holeFill) { array2D maskInv(winw, winh); invertMask(winx + border - offsX, winw - (border + offsX), winy + border - offsY, winh - (border + offsY), mask, maskInv); @@ -812,6 +836,10 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA xorMasks(winx + border - offsX, winw - (border + offsX), winy + border - offsY, winh - (border + offsY), maskInv, mask); } + if(plistener) { + plistener->setProgress(0.9); + } + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif diff --git a/rtengine/previewimage.cc b/rtengine/previewimage.cc index 29b319d2c..aba43ace5 100644 --- a/rtengine/previewimage.cc +++ b/rtengine/previewimage.cc @@ -99,7 +99,6 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext int error = rawImage.load(fname, true); if (!error) { - rtengine::Image8 *output = nullptr; const unsigned char *data = nullptr; int fw, fh; @@ -114,27 +113,27 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext params.raw.xtranssensor.method = RAWParams::XTransSensor::methodstring[RAWParams::XTransSensor::fast]; rawImage.preprocess(params.raw, params.lensProf, params.coarse); rawImage.demosaic(params.raw); - Imagefloat* image = new rtengine::Imagefloat (fw, fh); - rawImage.getImage (wb, TR_NONE, image, pp, params.toneCurve, params.icm, params.raw); - output = new Image8(fw, fh); - rawImage.convertColorSpace(image, params.icm, wb); + Imagefloat image(fw, fh); + rawImage.getImage (wb, TR_NONE, &image, pp, params.toneCurve, params.icm, params.raw); + rtengine::Image8 output(fw, fh); + rawImage.convertColorSpace(&image, params.icm, wb); #pragma omp parallel for schedule(dynamic, 10) for (int i = 0; i < fh; ++i) for (int j = 0; j < fw; ++j) { - image->r(i, j) = Color::gamma2curve[image->r(i, j)]; - image->g(i, j) = Color::gamma2curve[image->g(i, j)]; - image->b(i, j) = Color::gamma2curve[image->b(i, j)]; + image.r(i, j) = Color::gamma2curve[image.r(i, j)]; + image.g(i, j) = Color::gamma2curve[image.g(i, j)]; + image.b(i, j) = Color::gamma2curve[image.b(i, j)]; } - image->resizeImgTo(fw, fh, TI_Nearest, output); - data = output->getData(); + image.resizeImgTo(fw, fh, TI_Nearest, &output); + data = output.getData(); if (data) { int w, h; - w = output->getWidth(); - h = output->getHeight(); + w = output.getWidth(); + h = output.getHeight(); previewImage = Cairo::ImageSurface::create(Cairo::FORMAT_RGB24, w, h); previewImage->flush(); @@ -152,10 +151,6 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext } } - if (output) { - delete output; - } - previewImage->mark_dirty(); } } diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index d64288c21..2619ec15d 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -31,6 +31,16 @@ using namespace std; extern Options options; +namespace { + +void avoidEmptyCurve(std::vector &curve) { + if(curve.empty()) { + curve.push_back(FCT_Linear); + } +} + +} + namespace rtengine { namespace procparams @@ -768,6 +778,8 @@ void WaveletParams::setDefaults() for(int i = 0; i < 9; i ++) { ch[i] = 0; } + greenlow = greenmed = greenhigh = 0.0; + bluelow = bluemed = bluehigh = 0.0; } @@ -817,6 +829,7 @@ void DirPyrDenoiseParams::setDefaults() enhance = false; median = false; autochroma = false; + perform = false; luma = 0; passes = 1; dmethod = "Lab"; @@ -832,6 +845,7 @@ void DirPyrDenoiseParams::setDefaults() redchro = 0; bluechro = 0; gamma = 1.7; + perform = false; } void DirPyrDenoiseParams::getCurves(NoiseCurve &lCurve, NoiseCurve &cCurve) const @@ -3823,7 +3837,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (ppVersion > 200) { if (keyFile.has_key ("Exposure", "Curve")) { toneCurve.curve = keyFile.get_double_list ("Exposure", "Curve"); - + avoidEmptyCurve(toneCurve.curve); if (pedited) { pedited->toneCurve.curve = true; } @@ -3831,7 +3845,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Exposure", "Curve2")) { toneCurve.curve2 = keyFile.get_double_list ("Exposure", "Curve2"); - + avoidEmptyCurve(toneCurve.curve2); if (pedited) { pedited->toneCurve.curve2 = true; } @@ -3860,18 +3874,20 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) // load channel mixer curve if (keyFile.has_group ("Channel Mixer")) { if (keyFile.has_key ("Channel Mixer", "Red") && keyFile.has_key ("Channel Mixer", "Green") && keyFile.has_key ("Channel Mixer", "Blue")) { + const std::vector rmix = keyFile.get_integer_list ("Channel Mixer", "Red"); + const std::vector gmix = keyFile.get_integer_list ("Channel Mixer", "Green"); + const std::vector bmix = keyFile.get_integer_list ("Channel Mixer", "Blue"); + if(rmix.size() == 3 && gmix.size() == 3 && bmix.size() == 3) { + memcpy (chmixer.red, rmix.data(), 3 * sizeof(int)); + memcpy (chmixer.green, gmix.data(), 3 * sizeof(int)); + memcpy (chmixer.blue, bmix.data(), 3 * sizeof(int)); + } + if (pedited) { pedited->chmixer.red[0] = pedited->chmixer.red[1] = pedited->chmixer.red[2] = true; pedited->chmixer.green[0] = pedited->chmixer.green[1] = pedited->chmixer.green[2] = true; pedited->chmixer.blue[0] = pedited->chmixer.blue[1] = pedited->chmixer.blue[2] = true; } - - Glib::ArrayHandle rmix = keyFile.get_integer_list ("Channel Mixer", "Red"); - Glib::ArrayHandle gmix = keyFile.get_integer_list ("Channel Mixer", "Green"); - Glib::ArrayHandle bmix = keyFile.get_integer_list ("Channel Mixer", "Blue"); - memcpy (chmixer.red, rmix.data(), 3 * sizeof(int)); - memcpy (chmixer.green, gmix.data(), 3 * sizeof(int)); - memcpy (chmixer.blue, bmix.data(), 3 * sizeof(int)); } } @@ -4015,7 +4031,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Black & White", "LuminanceCurve")) { blackwhite.luminanceCurve = keyFile.get_double_list ("Black & White", "LuminanceCurve"); - + avoidEmptyCurve(blackwhite.luminanceCurve); if (pedited) { pedited->blackwhite.luminanceCurve = true; } @@ -4023,7 +4039,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Black & White", "BeforeCurve")) { blackwhite.beforeCurve = keyFile.get_double_list ("Black & White", "BeforeCurve"); - + avoidEmptyCurve(blackwhite.beforeCurve); if (pedited) { pedited->blackwhite.beforeCurve = true; } @@ -4057,7 +4073,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Black & White", "AfterCurve")) { blackwhite.afterCurve = keyFile.get_double_list ("Black & White", "AfterCurve"); - + avoidEmptyCurve(blackwhite.afterCurve); if (pedited) { pedited->blackwhite.afterCurve = true; } @@ -4260,7 +4276,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Retinex", "CDCurve")) { retinex.cdcurve = keyFile.get_double_list ("Retinex", "CDCurve"); - + avoidEmptyCurve(retinex.cdcurve); if (pedited) { pedited->retinex.cdcurve = true; } @@ -4268,7 +4284,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Retinex", "MAPCurve")) { retinex.mapcurve = keyFile.get_double_list ("Retinex", "MAPCurve"); - + avoidEmptyCurve(retinex.mapcurve); if (pedited) { pedited->retinex.mapcurve = true; } @@ -4276,7 +4292,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Retinex", "CDHCurve")) { retinex.cdHcurve = keyFile.get_double_list ("Retinex", "CDHCurve"); - + avoidEmptyCurve(retinex.cdHcurve); if (pedited) { pedited->retinex.cdHcurve = true; } @@ -4284,7 +4300,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Retinex", "LHCurve")) { retinex.lhcurve = keyFile.get_double_list ("Retinex", "LHCurve"); - + avoidEmptyCurve(retinex.lhcurve); if (pedited) { pedited->retinex.lhcurve = true; } @@ -4334,7 +4350,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Retinex", "TransmissionCurve")) { retinex.transmissionCurve = keyFile.get_double_list ("Retinex", "TransmissionCurve"); - + avoidEmptyCurve(retinex.transmissionCurve); if (pedited) { pedited->retinex.transmissionCurve = true; } @@ -4343,7 +4359,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Retinex", "GainTransmissionCurve")) { retinex.gaintransmissionCurve = keyFile.get_double_list ("Retinex", "GainTransmissionCurve"); - + avoidEmptyCurve(retinex.gaintransmissionCurve); if (pedited) { pedited->retinex.gaintransmissionCurve = true; } @@ -4443,7 +4459,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Luminance Curve", "LCurve")) { labCurve.lcurve = keyFile.get_double_list ("Luminance Curve", "LCurve"); - + avoidEmptyCurve(labCurve.lcurve); if (pedited) { pedited->labCurve.lcurve = true; } @@ -4451,7 +4467,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Luminance Curve", "aCurve")) { labCurve.acurve = keyFile.get_double_list ("Luminance Curve", "aCurve"); - + avoidEmptyCurve(labCurve.acurve); if (pedited) { pedited->labCurve.acurve = true; } @@ -4459,7 +4475,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Luminance Curve", "bCurve")) { labCurve.bcurve = keyFile.get_double_list ("Luminance Curve", "bCurve"); - + avoidEmptyCurve(labCurve.bcurve); if (pedited) { pedited->labCurve.bcurve = true; } @@ -4467,7 +4483,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Luminance Curve", "ccCurve")) { labCurve.cccurve = keyFile.get_double_list ("Luminance Curve", "ccCurve"); - + avoidEmptyCurve(labCurve.cccurve); if (pedited) { pedited->labCurve.cccurve = true; } @@ -4475,7 +4491,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Luminance Curve", "chCurve")) { labCurve.chcurve = keyFile.get_double_list ("Luminance Curve", "chCurve"); - + avoidEmptyCurve(labCurve.chcurve); if (pedited) { pedited->labCurve.chcurve = true; } @@ -4483,7 +4499,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Luminance Curve", "lhCurve")) { labCurve.lhcurve = keyFile.get_double_list ("Luminance Curve", "lhCurve"); - + avoidEmptyCurve(labCurve.lhcurve); if (pedited) { pedited->labCurve.lhcurve = true; } @@ -4491,7 +4507,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Luminance Curve", "hhCurve")) { labCurve.hhcurve = keyFile.get_double_list ("Luminance Curve", "hhCurve"); - + avoidEmptyCurve(labCurve.hhcurve); if (pedited) { pedited->labCurve.hhcurve = true; } @@ -4499,7 +4515,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Luminance Curve", "LcCurve")) { labCurve.lccurve = keyFile.get_double_list ("Luminance Curve", "LcCurve"); - + avoidEmptyCurve(labCurve.lccurve); if (pedited) { pedited->labCurve.lccurve = true; } @@ -4507,7 +4523,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Luminance Curve", "ClCurve")) { labCurve.clcurve = keyFile.get_double_list ("Luminance Curve", "ClCurve"); - + avoidEmptyCurve(labCurve.clcurve); if (pedited) { pedited->labCurve.clcurve = true; } @@ -4546,8 +4562,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) int thresh = min(keyFile.get_integer ("Sharpening", "Threshold"), 2000); sharpening.threshold.setValues(thresh, thresh, 2000, 2000); // TODO: 2000 is the maximum value and is taken of rtgui/sharpening.cc ; should be changed by the tool modularization } else { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("Sharpening", "Threshold"); - sharpening.threshold.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 2000), min(thresh.data()[3], 2000)); + const std::vector thresh = keyFile.get_integer_list ("Sharpening", "Threshold"); + if(thresh.size() >= 4) { + sharpening.threshold.setValues(thresh[0], thresh[1], min(thresh[2], 2000), min(thresh[3], 2000)); + } } if (pedited) { @@ -4737,8 +4755,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) int thresh = keyFile.get_integer ("Vibrance", "PSThreshold"); vibrance.psthreshold.setValues(thresh, thresh); } else { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("Vibrance", "PSThreshold"); - vibrance.psthreshold.setValues(thresh.data()[0], thresh.data()[1]); + const std::vector thresh = keyFile.get_integer_list ("Vibrance", "PSThreshold"); + if(thresh.size() >= 2 ) { + vibrance.psthreshold.setValues(thresh[0], thresh[1]); + } } if (pedited) { @@ -4772,7 +4792,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Vibrance", "SkinTonesCurve")) { vibrance.skintonescurve = keyFile.get_double_list ("Vibrance", "SkinTonesCurve"); - + avoidEmptyCurve(vibrance.skintonescurve); if (pedited) { pedited->vibrance.skintonescurve = true; } @@ -4875,7 +4895,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Defringing", "HueCurve")) { defringe.huecurve = keyFile.get_double_list ("Defringing", "HueCurve"); - + avoidEmptyCurve(defringe.huecurve); if (pedited) { pedited->defringe.huecurve = true; } @@ -5118,7 +5138,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (ppVersion > 200) { if (keyFile.has_key ("Color appearance", "Curve")) { colorappearance.curve = keyFile.get_double_list ("Color appearance", "Curve"); - + avoidEmptyCurve(colorappearance.curve); if (pedited) { pedited->colorappearance.curve = true; } @@ -5126,7 +5146,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Color appearance", "Curve2")) { colorappearance.curve2 = keyFile.get_double_list ("Color appearance", "Curve2"); - + avoidEmptyCurve(colorappearance.curve2); if (pedited) { pedited->colorappearance.curve2 = true; } @@ -5134,7 +5154,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Color appearance", "Curve3")) { colorappearance.curve3 = keyFile.get_double_list ("Color appearance", "Curve3"); - + avoidEmptyCurve(colorappearance.curve3); if (pedited) { pedited->colorappearance.curve3 = true; } @@ -5296,7 +5316,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Directional Pyramid Denoising", "LCurve")) { dirpyrDenoise.lcurve = keyFile.get_double_list ("Directional Pyramid Denoising", "LCurve"); - + avoidEmptyCurve(dirpyrDenoise.lcurve); if (pedited) { pedited->dirpyrDenoise.lcurve = true; } @@ -5304,7 +5324,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Directional Pyramid Denoising", "CCCurve")) { dirpyrDenoise.cccurve = keyFile.get_double_list ("Directional Pyramid Denoising", "CCCurve"); - + avoidEmptyCurve(dirpyrDenoise.cccurve); if (pedited) { pedited->dirpyrDenoise.cccurve = true; } @@ -5915,8 +5935,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) int thresh = min(keyFile.get_integer ("PostResizeSharpening", "Threshold"), 2000); prsharpening.threshold.setValues(thresh, thresh, 2000, 2000); // TODO: 2000 is the maximum value and is taken of rtgui/sharpening.cc ; should be changed by the tool modularization } else { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("PostResizeSharpening", "Threshold"); - prsharpening.threshold.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 2000), min(thresh.data()[3], 2000)); + const std::vector thresh = keyFile.get_integer_list ("PostResizeSharpening", "Threshold"); + if(thresh.size() >= 4) { + prsharpening.threshold.setValues(thresh[0], thresh[1], min(thresh[2], 2000), min(thresh[3], 2000)); + } } if (pedited) { @@ -6576,7 +6598,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "ContrastCurve")) { wavelet.ccwcurve = keyFile.get_double_list ("Wavelet", "ContrastCurve"); - + avoidEmptyCurve(wavelet.ccwcurve); if (pedited) { pedited->wavelet.ccwcurve = true; } @@ -6584,7 +6606,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "OpacityCurveRG")) { wavelet.opacityCurveRG = keyFile.get_double_list ("Wavelet", "OpacityCurveRG"); - + avoidEmptyCurve(wavelet.opacityCurveRG); if (pedited) { pedited->wavelet.opacityCurveRG = true; } @@ -6592,7 +6614,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "OpacityCurveBY")) { wavelet.opacityCurveBY = keyFile.get_double_list ("Wavelet", "OpacityCurveBY"); - + avoidEmptyCurve(wavelet.opacityCurveBY); if (pedited) { pedited->wavelet.opacityCurveBY = true; } @@ -6600,7 +6622,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "OpacityCurveW")) { wavelet.opacityCurveW = keyFile.get_double_list ("Wavelet", "OpacityCurveW"); - + avoidEmptyCurve(wavelet.opacityCurveW); if (pedited) { pedited->wavelet.opacityCurveW = true; } @@ -6608,7 +6630,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "OpacityCurveWL")) { wavelet.opacityCurveWL = keyFile.get_double_list ("Wavelet", "OpacityCurveWL"); - + avoidEmptyCurve(wavelet.opacityCurveWL); if (pedited) { pedited->wavelet.opacityCurveWL = true; } @@ -6616,7 +6638,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "HHcurve")) { wavelet.hhcurve = keyFile.get_double_list ("Wavelet", "HHcurve"); - + avoidEmptyCurve(wavelet.hhcurve); if (pedited) { pedited->wavelet.hhcurve = true; } @@ -6624,7 +6646,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "CHcurve")) { wavelet.Chcurve = keyFile.get_double_list ("Wavelet", "CHcurve"); - + avoidEmptyCurve(wavelet.Chcurve); if (pedited) { pedited->wavelet.Chcurve = true; } @@ -6632,15 +6654,17 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "WavclCurve")) { wavelet.wavclCurve = keyFile.get_double_list ("Wavelet", "WavclCurve"); - + avoidEmptyCurve(wavelet.wavclCurve); if (pedited) { pedited->wavelet.wavclCurve = true; } } if (keyFile.has_key ("Wavelet", "Hueskin")) { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "Hueskin"); - wavelet.hueskin.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + const std::vector thresh = keyFile.get_integer_list ("Wavelet", "Hueskin"); + if(thresh.size() >= 4) { + wavelet.hueskin.setValues(thresh[0], thresh[1], min(thresh[2], 300), min(thresh[3], 300)); + } if (pedited) { pedited->wavelet.hueskin = true; @@ -6648,8 +6672,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("Wavelet", "HueRange")) { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "HueRange"); - wavelet.hueskin2.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + const std::vector thresh = keyFile.get_integer_list ("Wavelet", "HueRange"); + if(thresh.size() >= 4) { + wavelet.hueskin2.setValues(thresh[0], thresh[1], min(thresh[2], 300), min(thresh[3], 300)); + } if (pedited) { pedited->wavelet.hueskin2 = true; @@ -6657,8 +6683,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("Wavelet", "HLRange")) { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "HLRange"); - wavelet.hllev.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + const std::vector thresh = keyFile.get_integer_list ("Wavelet", "HLRange"); + if(thresh.size() >= 4) { + wavelet.hllev.setValues(thresh[0], thresh[1], min(thresh[2], 300), min(thresh[3], 300)); + } if (pedited) { pedited->wavelet.hllev = true; @@ -6666,8 +6694,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("Wavelet", "SHRange")) { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "SHRange"); - wavelet.bllev.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + const std::vector thresh = keyFile.get_integer_list ("Wavelet", "SHRange"); + if(thresh.size() >= 4) { + wavelet.bllev.setValues(thresh[0], thresh[1], min(thresh[2], 300), min(thresh[3], 300)); + } if (pedited) { pedited->wavelet.bllev = true; @@ -6675,8 +6705,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("Wavelet", "Edgcont")) { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "Edgcont"); - wavelet.edgcont.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + const std::vector thresh = keyFile.get_integer_list ("Wavelet", "Edgcont"); + if(thresh.size() >= 4) { + wavelet.edgcont.setValues(thresh[0], thresh[1], min(thresh[2], 300), min(thresh[3], 300)); + } if (pedited) { pedited->wavelet.edgcont = true; @@ -6684,8 +6716,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("Wavelet", "Level0noise")) { - Glib::ArrayHandle thresh = keyFile.get_double_list ("Wavelet", "Level0noise"); - wavelet.level0noise.setValues(thresh.data()[0], thresh.data()[1]); + const std::vector thresh = keyFile.get_double_list ("Wavelet", "Level0noise"); + if(thresh.size() >= 2) { + wavelet.level0noise.setValues(thresh[0], thresh[1]); + } if (pedited) { pedited->wavelet.level0noise = true; @@ -6693,8 +6727,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("Wavelet", "Level1noise")) { - Glib::ArrayHandle thresh = keyFile.get_double_list ("Wavelet", "Level1noise"); - wavelet.level1noise.setValues(thresh.data()[0], thresh.data()[1]); + const std::vector thresh = keyFile.get_double_list ("Wavelet", "Level1noise"); + if(thresh.size() >= 2) { + wavelet.level1noise.setValues(thresh[0], thresh[1]); + } if (pedited) { pedited->wavelet.level1noise = true; @@ -6702,8 +6738,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("Wavelet", "Level2noise")) { - Glib::ArrayHandle thresh = keyFile.get_double_list ("Wavelet", "Level2noise"); - wavelet.level2noise.setValues(thresh.data()[0], thresh.data()[1]); + const std::vector thresh = keyFile.get_double_list ("Wavelet", "Level2noise"); + if(thresh.size() >= 2) { + wavelet.level2noise.setValues(thresh[0], thresh[1]); + } if (pedited) { pedited->wavelet.level2noise = true; @@ -6711,8 +6749,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("Wavelet", "Level3noise")) { - Glib::ArrayHandle thresh = keyFile.get_double_list ("Wavelet", "Level3noise"); - wavelet.level3noise.setValues(thresh.data()[0], thresh.data()[1]); + const std::vector thresh = keyFile.get_double_list ("Wavelet", "Level3noise"); + if(thresh.size() >= 2) { + wavelet.level3noise.setValues(thresh[0], thresh[1]); + } if (pedited) { pedited->wavelet.level3noise = true; @@ -6721,8 +6761,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "Pastlev")) { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "Pastlev"); - wavelet.pastlev.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + const std::vector thresh = keyFile.get_integer_list ("Wavelet", "Pastlev"); + if(thresh.size() >= 4) { + wavelet.pastlev.setValues(thresh[0], thresh[1], min(thresh[2], 300), min(thresh[3], 300)); + } if (pedited) { pedited->wavelet.pastlev = true; @@ -6730,8 +6772,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("Wavelet", "Satlev")) { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "Satlev"); - wavelet.satlev.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + const std::vector thresh = keyFile.get_integer_list ("Wavelet", "Satlev"); + if(thresh.size() >= 4) { + wavelet.satlev.setValues(thresh[0], thresh[1], min(thresh[2], 300), min(thresh[3], 300)); + } if (pedited) { pedited->wavelet.satlev = true; @@ -6862,8 +6906,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) // if (keyFile.has_key ("Directional Pyramid Equalizer", "Algorithm")) { dirpyrequalizer.algo = keyFile.get_string ("Directional Pyramid Equalizer", "Algorithm"); if (pedited) pedited->dirpyrequalizer.algo = true; } if (keyFile.has_key ("Directional Pyramid Equalizer", "Hueskin")) { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("Directional Pyramid Equalizer", "Hueskin"); - dirpyrequalizer.hueskin.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + const std::vector thresh = keyFile.get_integer_list ("Directional Pyramid Equalizer", "Hueskin"); + if(thresh.size() >= 4) { + dirpyrequalizer.hueskin.setValues(thresh[0], thresh[1], min(thresh[2], 300), min(thresh[3], 300)); + } if (pedited) { pedited->dirpyrequalizer.hueskin = true; @@ -6962,7 +7008,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (ppVersion >= 300) { if (keyFile.has_key ("HSV Equalizer", "HCurve")) { hsvequalizer.hcurve = keyFile.get_double_list ("HSV Equalizer", "HCurve"); - + avoidEmptyCurve(hsvequalizer.hcurve); if (pedited) { pedited->hsvequalizer.hcurve = true; } @@ -6970,7 +7016,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("HSV Equalizer", "SCurve")) { hsvequalizer.scurve = keyFile.get_double_list ("HSV Equalizer", "SCurve"); - + avoidEmptyCurve(hsvequalizer.scurve); if (pedited) { pedited->hsvequalizer.scurve = true; } @@ -6978,7 +7024,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("HSV Equalizer", "VCurve")) { hsvequalizer.vcurve = keyFile.get_double_list ("HSV Equalizer", "VCurve"); - + avoidEmptyCurve(hsvequalizer.vcurve); if (pedited) { pedited->hsvequalizer.vcurve = true; } @@ -6998,7 +7044,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("RGB Curves", "rCurve")) { rgbCurves.rcurve = keyFile.get_double_list ("RGB Curves", "rCurve"); - + avoidEmptyCurve(rgbCurves.rcurve); if (pedited) { pedited->rgbCurves.rcurve = true; } @@ -7006,7 +7052,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("RGB Curves", "gCurve")) { rgbCurves.gcurve = keyFile.get_double_list ("RGB Curves", "gCurve"); - + avoidEmptyCurve(rgbCurves.gcurve); if (pedited) { pedited->rgbCurves.gcurve = true; } @@ -7014,7 +7060,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("RGB Curves", "bCurve")) { rgbCurves.bcurve = keyFile.get_double_list ("RGB Curves", "bCurve"); - + avoidEmptyCurve(rgbCurves.bcurve); if (pedited) { pedited->rgbCurves.bcurve = true; } @@ -7057,7 +7103,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("ColorToning", "OpacityCurve")) { colorToning.opacityCurve = keyFile.get_double_list ("ColorToning", "OpacityCurve"); - + avoidEmptyCurve(colorToning.opacityCurve); if (pedited) { pedited->colorToning.opacityCurve = true; } @@ -7065,7 +7111,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("ColorToning", "ColorCurve")) { colorToning.colorCurve = keyFile.get_double_list ("ColorToning", "ColorCurve"); - + avoidEmptyCurve(colorToning.colorCurve); if (pedited) { pedited->colorToning.colorCurve = true; } @@ -7104,8 +7150,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("ColorToning", "HighlightsColorSaturation")) { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("ColorToning", "HighlightsColorSaturation"); - colorToning.hlColSat.setValues(thresh.data()[0], thresh.data()[1]); + const std::vector thresh = keyFile.get_integer_list ("ColorToning", "HighlightsColorSaturation"); + if(thresh.size() >= 2) { + colorToning.hlColSat.setValues(thresh[0], thresh[1]); + } if (pedited) { pedited->colorToning.hlColSat = true; @@ -7113,8 +7161,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("ColorToning", "ShadowsColorSaturation")) { - Glib::ArrayHandle thresh = keyFile.get_integer_list ("ColorToning", "ShadowsColorSaturation"); - colorToning.shadowsColSat.setValues(thresh.data()[0], thresh.data()[1]); + const std::vector thresh = keyFile.get_integer_list ("ColorToning", "ShadowsColorSaturation"); + if(thresh.size() >= 2) { + colorToning.shadowsColSat.setValues(thresh[0], thresh[1]); + } if (pedited) { pedited->colorToning.shadowsColSat = true; @@ -7123,7 +7173,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("ColorToning", "ClCurve")) { colorToning.clcurve = keyFile.get_double_list ("ColorToning", "ClCurve"); - + avoidEmptyCurve(colorToning.clcurve); if (pedited) { pedited->colorToning.clcurve = true; } @@ -7131,7 +7181,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("ColorToning", "Cl2Curve")) { colorToning.cl2curve = keyFile.get_double_list ("ColorToning", "Cl2Curve"); - + avoidEmptyCurve(colorToning.cl2curve); if (pedited) { pedited->colorToning.cl2curve = true; } diff --git a/rtengine/profilestore.cc b/rtengine/profilestore.cc index 12c1cca5c..c713d6b5c 100644 --- a/rtengine/profilestore.cc +++ b/rtengine/profilestore.cc @@ -190,8 +190,7 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath } // walking through the directory - Glib::Dir* dir = nullptr; - dir = new Glib::Dir (realPath); + Glib::Dir* dir = new Glib::Dir (realPath); for (Glib::DirIterator i = dir->begin(); i != dir->end(); ++i) { currDir = *i; @@ -248,6 +247,8 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath if (!fileFound && (level > 0 || displayLevel0)) { // no files found in this level, we delete the subdirectory entry folders.pop_back(); + + delete entries.back(); entries.pop_back(); } diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index f54d744c4..3c16163e5 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -462,10 +462,14 @@ RawImageSource::RawImageSource () , green(0, 0) , red(0, 0) , blue(0, 0) + , rawDirty(true) { camProfile = nullptr; embProfile = nullptr; rgbSourceModified = false; + for(int i = 0; i < 4; ++i) { + psRedBrightness[i] = psGreenBrightness[i] = psBlueBrightness[i] = 1.f; + } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -2031,6 +2035,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le delete bitmapBads; } + rawDirty = true; return; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -2103,7 +2108,7 @@ void RawImageSource::demosaic(const RAWParams &raw) //void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexParams retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI) -void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexParams retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI) +void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, const RetinexParams &retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI) { bool useHsl = (retinexParams.retinexcolorspace == "HSLLOG" || retinexParams.retinexcolorspace == "HSLLIN"); conversionBuffer[0] (W - 2 * border, H - 2 * border); @@ -2205,7 +2210,7 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar } } */ - if(retinexParams.gammaretinex != "none" && retinexParams.str != 0) {//gamma + if(retinexParams.gammaretinex != "none" && retinexParams.str != 0 && retinexgamtab) {//gamma #ifdef _OPENMP #pragma omp parallel for @@ -2357,7 +2362,7 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar } -void RawImageSource::retinexPrepareCurves(RetinexParams retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, RetinexgaintransmissionCurve &retinexgaintransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI) +void RawImageSource::retinexPrepareCurves(const RetinexParams &retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, RetinexgaintransmissionCurve &retinexgaintransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI) { useHsl = (retinexParams.retinexcolorspace == "HSLLOG" || retinexParams.retinexcolorspace == "HSLLIN"); @@ -2372,7 +2377,7 @@ void RawImageSource::retinexPrepareCurves(RetinexParams retinexParams, LUTf &cdc retinexParams.getCurves(retinextransmissionCurve, retinexgaintransmissionCurve); } -void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, 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) +void RawImageSource::retinex(ColorManagementParams cmp, const RetinexParams &deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, 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) { MyTime t4, t5; t4.set(); @@ -5000,14 +5005,14 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm) } if( settings->verbose ) { - printf ("AVG: %g %g %g\n", avg_r / rn, avg_g / gn, avg_b / bn); + printf ("AVG: %g %g %g\n", avg_r / std::max(1, rn), avg_g / std::max(1, gn), avg_b / std::max(1, bn)); } // return ColorTemp (pow(avg_r/rn, 1.0/6.0)*img_r, pow(avg_g/gn, 1.0/6.0)*img_g, pow(avg_b/bn, 1.0/6.0)*img_b); - double reds = avg_r / rn * refwb_red; - double greens = avg_g / gn * refwb_green; - double blues = avg_b / bn * refwb_blue; + double reds = avg_r / std::max(1, rn) * refwb_red; + double greens = avg_g / std::max(1, gn) * refwb_green; + double blues = avg_b / std::max(1, bn) * refwb_blue; redAWBMul = rm = imatrices.rgb_cam[0][0] * reds + imatrices.rgb_cam[0][1] * greens + imatrices.rgb_cam[0][2] * blues; greenAWBMul = gm = imatrices.rgb_cam[1][0] * reds + imatrices.rgb_cam[1][1] * greens + imatrices.rgb_cam[1][2] * blues; @@ -5129,9 +5134,9 @@ ColorTemp RawImageSource::getSpotWB (std::vector &red, std::vector &red, std::vector &red, std::vector &red, std::vector red; // the interpolated blue plane: array2D blue; + bool rawDirty; + float psRedBrightness[4]; + float psGreenBrightness[4]; + float psBlueBrightness[4]; void hphd_vertical (float** hpmap, int col_from, int col_to); @@ -115,9 +119,9 @@ public: int load (const Glib::ustring &fname, int imageNum = 0, bool batch = false); void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse, bool prepareDenoise = true); void demosaic (const RAWParams &raw); - void retinex (ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, 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); - void retinexPrepareCurves (RetinexParams retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, RetinexgaintransmissionCurve &retinexgaintransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI); - void retinexPrepareBuffers (ColorManagementParams cmp, RetinexParams retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI); + void retinex (ColorManagementParams cmp, const RetinexParams &deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, 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); + void retinexPrepareCurves (const RetinexParams &retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, RetinexgaintransmissionCurve &retinexgaintransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI); + void retinexPrepareBuffers (ColorManagementParams cmp, const RetinexParams &retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI); void flushRawData (); void flushRGB (); void HLRecovery_Global (ToneCurveParams hrp); @@ -193,7 +197,7 @@ public: void boxblur2(float** src, float** dst, float** temp, int H, int W, int box ); void boxblur_resamp(float **src, float **dst, float** temp, int H, int W, int box, int samp ); - void MSR(float** luminance, float **originalLuminance, float **exLuminance, LUTf & mapcurve, bool &mapcontlutili, int width, int height, RetinexParams deh, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax); + void MSR(float** luminance, float **originalLuminance, float **exLuminance, LUTf & mapcurve, bool &mapcontlutili, int width, int height, const RetinexParams &deh, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax); void HLRecovery_inpaint (float** red, float** green, float** blue); static void HLRecovery_Luminance (float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, int width, float maxval); static void HLRecovery_CIELab (float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, int width, float maxval, double cam[3][3], double icam[3][3]); diff --git a/rtengine/rawimagesource_i.h b/rtengine/rawimagesource_i.h index 1cd25d6fc..689ab03db 100644 --- a/rtengine/rawimagesource_i.h +++ b/rtengine/rawimagesource_i.h @@ -184,7 +184,7 @@ inline void RawImageSource::interpolate_row_rb (float* ar, float* ab, float* pg, n++; } - b = cg[j] + b / n; + b = cg[j] + b / std::max(1, n); ab[j] = b; } else { // linear R-G interp. horizontally @@ -243,7 +243,7 @@ inline void RawImageSource::interpolate_row_rb (float* ar, float* ab, float* pg, n++; } - r = cg[j] + r / n; + r = cg[j] + r / std::max(n, 1); ar[j] = r; } else { @@ -309,7 +309,7 @@ inline void RawImageSource::interpolate_row_rb_mul_pp (float* ar, float* ab, flo n++; } - b = g_mul * cg[j] + b / n; + b = g_mul * cg[j] + b / std::max(1, n); ab[jx] = b; } else { // linear R-G interp. horizontally @@ -368,7 +368,7 @@ inline void RawImageSource::interpolate_row_rb_mul_pp (float* ar, float* ab, flo n++; } - r = g_mul * cg[j] + r / n; + r = g_mul * cg[j] + r / std::max(n, 1); ar[jx] = r; } else { diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 2854df91a..742e667cb 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -1988,21 +1988,25 @@ bool Thumbnail::writeData (const Glib::ustring& fname) bool Thumbnail::readEmbProfile (const Glib::ustring& fname) { - FILE* f = g_fopen (fname.c_str (), "rb"); + embProfileData = nullptr; + embProfile = nullptr; + embProfileLength = 0; - if (!f) { - embProfileData = nullptr; - embProfile = nullptr; - embProfileLength = 0; - } else { - fseek (f, 0, SEEK_END); - embProfileLength = ftell (f); - fseek (f, 0, SEEK_SET); - embProfileData = new unsigned char[embProfileLength]; - fread (embProfileData, 1, embProfileLength, f); + FILE* f = g_fopen (fname.c_str (), "rb"); + if (f) { + if(!fseek (f, 0, SEEK_END)) { + int profileLength = ftell (f); + if(profileLength > 0) { + embProfileLength = profileLength; + if(!fseek (f, 0, SEEK_SET)) { + embProfileData = new unsigned char[embProfileLength]; + fread (embProfileData, 1, embProfileLength, f); + embProfile = cmsOpenProfileFromMem (embProfileData, embProfileLength); + } + } + } fclose (f); - embProfile = cmsOpenProfileFromMem (embProfileData, embProfileLength); - return true; + return embProfile != nullptr; } return false; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index efbba78d1..2e1c60ff8 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -43,7 +43,7 @@ void adjust_radius(const T &default_param, double scale_factor, T ¶m) const double delta = (param - default_param) * scale_factor; param = default_param + delta; } - + class ImageProcessor { public: @@ -91,7 +91,7 @@ private: } pl = nullptr; - + if (!stage_init()) { return nullptr; } @@ -267,12 +267,8 @@ private: if(settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PON") { MyTime t1pone, t2pone; t1pone.set(); - int crW, crH; - - if(settings->leveldnv == 0) { - crW = 100; - crH = 100; - } + int crW = 100; // settings->leveldnv == 0 + int crH = 100; // settings->leveldnv == 0 if(settings->leveldnv == 1) { crW = 250; @@ -540,7 +536,7 @@ private: PreviewProps ppP (coordW[wcr] , coordH[hcr], crW, crH, 1); imgsrc->getImage (currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw); //baseImg->getStdImage(currWB, tr, origCropPart, ppP, true, params.toneCurve); - + // we only need image reduced to 1/4 here for(int ii = 0; ii < crH; ii += 2) { @@ -713,7 +709,7 @@ private: hlcompr = params.toneCurve.hlcompr; hlcomprthresh = params.toneCurve.hlcomprthresh; - + if (params.toneCurve.autoexp) { LUTu aehist; int aehistcompr; @@ -737,7 +733,7 @@ private: procparams::ProcParams& params = job->pparams; //ImProcFunctions ipf (¶ms, true); ImProcFunctions &ipf = *(ipf_p.get()); - + // perform luma/chroma denoise // CieImage *cieView; // NoisCurve noiseLCurve; @@ -801,7 +797,7 @@ private: { procparams::ProcParams& params = job->pparams; //ImProcFunctions ipf (¶ms, true); - ImProcFunctions &ipf = *(ipf_p.get()); + ImProcFunctions &ipf = *(ipf_p.get()); imgsrc->convertColorSpace(baseImg, params.icm, currWB); @@ -809,7 +805,7 @@ private: hist16 (65536); ipf.firstAnalysis (baseImg, params, hist16); - + // perform transform (excepted resizing) if (ipf.needsTransform()) { Imagefloat* trImg = new Imagefloat (fw, fh); @@ -824,7 +820,7 @@ private: { procparams::ProcParams& params = job->pparams; //ImProcFunctions ipf (¶ms, true); - ImProcFunctions &ipf = *(ipf_p.get()); + ImProcFunctions &ipf = *(ipf_p.get()); if (params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled) { const int W = baseImg->getWidth(); @@ -1350,8 +1346,8 @@ private: { procparams::ProcParams& params = job->pparams; //ImProcFunctions ipf (¶ms, true); - ImProcFunctions &ipf = *(ipf_p.get()); - + ImProcFunctions &ipf = *(ipf_p.get()); + int imw, imh; double scale_factor = ipf.resizeScale(¶ms, fw, fh, imw, imh); @@ -1387,7 +1383,7 @@ private: } adjust_procparams(scale_factor); - + fw = imw; fh = imh; @@ -1437,7 +1433,7 @@ private: } } } - + params.epd.scale *= scale_factor; //params.epd.edgeStopping *= scale_factor; @@ -1528,7 +1524,7 @@ private: LUTf gCurve; LUTf bCurve; LUTu dummy; - + ToneCurve customToneCurve1, customToneCurve2; ColorGradientCurve ctColorCurve; OpacityCurve ctOpacityCurve; diff --git a/rtengine/utils.cc b/rtengine/utils.cc index c9bce803d..4ab5bc1b8 100644 --- a/rtengine/utils.cc +++ b/rtengine/utils.cc @@ -189,34 +189,38 @@ void rotate(unsigned char* img, int& w, int& h, int deg) void hflip(unsigned char* img, int w, int h) { - unsigned char* flipped = new unsigned char[3 * w * h]; - int ix = 0; + if(w > 0 && h > 0) { + unsigned char* flipped = new unsigned char[3 * w * h]; + int ix = 0; - for (int i = 0; i < h; i++) - for (int j = 0; j < w; j++) { - flipped[3 * (w * i + w - 1 - j) + 0] = img[ix++]; - flipped[3 * (w * i + w - 1 - j) + 1] = img[ix++]; - flipped[3 * (w * i + w - 1 - j) + 2] = img[ix++]; - } + for (int i = 0; i < h; i++) + for (int j = 0; j < w; j++) { + flipped[3 * (w * i + w - 1 - j) + 0] = img[ix++]; + flipped[3 * (w * i + w - 1 - j) + 1] = img[ix++]; + flipped[3 * (w * i + w - 1 - j) + 2] = img[ix++]; + } - memcpy(img, flipped, 3 * w * h); - delete[] flipped; + memcpy(img, flipped, 3 * w * h); + delete[] flipped; + } } void vflip(unsigned char* img, int w, int h) { - unsigned char* flipped = new unsigned char[3 * w * h]; - int ix = 0; + if(w > 0 && h > 0) { + unsigned char* flipped = new unsigned char[3 * w * h]; + int ix = 0; - for (int i = 0; i < h; i++) - for (int j = 0; j < w; j++) { - flipped[3 * (w * (h - 1 - i) + j) + 0] = img[ix++]; - flipped[3 * (w * (h - 1 - i) + j) + 1] = img[ix++]; - flipped[3 * (w * (h - 1 - i) + j) + 2] = img[ix++]; - } + for (int i = 0; i < h; i++) + for (int j = 0; j < w; j++) { + flipped[3 * (w * (h - 1 - i) + j) + 0] = img[ix++]; + flipped[3 * (w * (h - 1 - i) + j) + 1] = img[ix++]; + flipped[3 * (w * (h - 1 - i) + j) + 2] = img[ix++]; + } - memcpy(img, flipped, 3 * w * h); - delete[] flipped; + memcpy(img, flipped, 3 * w * h); + delete[] flipped; + } } Glib::ustring getFileExtension(const Glib::ustring& filename) diff --git a/rtexif/CMakeLists.txt b/rtexif/CMakeLists.txt index 312400cf5..820f682a4 100644 --- a/rtexif/CMakeLists.txt +++ b/rtexif/CMakeLists.txt @@ -2,12 +2,10 @@ add_library(rtexif rtexif.cc stdattribs.cc nikonattribs.cc canonattribs.cc penta add_dependencies(rtexif UpdateInfo) if(WIN32) - set_target_properties(rtexif PROPERTIES COMPILE_FLAGS " -ffast-math -fexpensive-optimizations") include_directories(${EXTRA_INCDIR} ${GLIB2_INCLUDE_DIRS} ${GLIBMM_INCLUDE_DIRS} ${GTK_INCLUDE_DIRS} ${GTKMM_INCLUDE_DIRS}) link_directories(. "${PROJECT_SOURCE_DIR}/rtexif" ${EXTRA_LIBDIR} ${GLIB2_LIBRARY_DIRS} ${GLIBMM_LIBRARY_DIRS} ${GTK_LIBRARY_DIRS} ${GTKMM_LIBRARY_DIRS}) - #set_target_properties (rth PROPERTIES LINK_FLAGS "-mwindows") else() - set_target_properties(rtexif PROPERTIES COMPILE_FLAGS " -ffast-math -fexpensive-optimizations -fPIC") + set_target_properties(rtexif PROPERTIES COMPILE_FLAGS " -fPIC") include_directories(${EXTRA_INCDIR} ${GLIB2_INCLUDE_DIRS} ${GLIBMM_INCLUDE_DIRS} ${GTK_INCLUDE_DIRS} ${GTKMM_INCLUDE_DIRS}) link_directories(${EXTRA_LIBDIR} ${GLIB2_LIBRARY_DIRS} ${GLIBMM_LIBRARY_DIRS} ${GTK_LIBRARY_DIRS} ${GTKMM_LIBRARY_DIRS}) endif() diff --git a/rtexif/pentaxattribs.cc b/rtexif/pentaxattribs.cc index b57de067c..2c52a0c88 100644 --- a/rtexif/pentaxattribs.cc +++ b/rtexif/pentaxattribs.cc @@ -1290,10 +1290,10 @@ public: buffer[0] = 0; // return buffer; // TODO: how to get the string content!? - // normal path below (copy the content of the string), but has to be bug fixed - memcpy (buffer, t->getValue(), 30); - buffer[30] = 0; - return buffer; +// // normal path below (copy the content of the string), but has to be bug fixed +// memcpy (buffer, t->getValue(), 30); +// buffer[30] = 0; +// return buffer; } }; PALensModelQInterpreter paLensModelQInterpreter; @@ -1308,10 +1308,10 @@ public: buffer[0] = 0; return buffer; // TODO: how to get the string content!? - // normal path below (copy the content of the string), but has to be bug fixed - memcpy (buffer, t->getValue(), 20); - buffer[20] = 0; - return buffer; +// // normal path below (copy the content of the string), but has to be bug fixed +// memcpy (buffer, t->getValue(), 20); +// buffer[20] = 0; +// return buffer; } }; PALensInfoQInterpreter paLensInfoQInterpreter; diff --git a/rtexif/rtexif.cc b/rtexif/rtexif.cc index dcfc60d0b..4ff687502 100644 --- a/rtexif/rtexif.cc +++ b/rtexif/rtexif.cc @@ -780,6 +780,7 @@ Tag::Tag (TagDirectory* p, FILE* f, int base) // (only a small part of it will actually be parsed though) if ((int)type < 1 || (int)type > 14 || count > 10 * 1024 * 1024) { type = INVALID; + valuesize = 0; return; } @@ -1346,7 +1347,9 @@ void Tag::fromString (const char* v, int size) value = new unsigned char [valuesize]; } - memcpy ((char*)value, v, valuesize); + if(value) { + memcpy ((char*)value, v, valuesize); + } } int Tag::toInt (int ofs, TagType astype) @@ -1450,7 +1453,6 @@ double Tag::toDouble (int ofs) return 0.; // Quick fix for missing cases (INVALID, DOUBLE, OLYUNDEF, SUBDIR) } - return 0.; } /** @@ -1606,10 +1608,10 @@ void Tag::toString (char* buffer, int ofs) std::string Tag::nameToString (int i) { - char buffer[1024]; + char buffer[1025]; if (attrib) { - strcpy (buffer, attrib->name); + strncpy (buffer, attrib->name, 1024); } else { sprintf (buffer, "0x%x", tag); } @@ -1655,17 +1657,15 @@ int Tag::calculateSize () if (j > 1) { size += 4 * j; } + if (makerNoteKind != NOMK) { + count = directory[0]->calculateSize () / getTypeSize (type); + } } else if (valuesize > 4) { size += valuesize + (valuesize % 2); // we align tags to even byte positions } - if (makerNoteKind != NOMK) { - count = directory[0]->calculateSize () / getTypeSize (type); - } - if (makerNoteKind == NIKON3 || makerNoteKind == OLYMPUS2 || makerNoteKind == FUJI) { - size += valuesize; - } else if (makerNoteKind == HEADERIFD) { + if (makerNoteKind == NIKON3 || makerNoteKind == OLYMPUS2 || makerNoteKind == FUJI || makerNoteKind == HEADERIFD) { size += valuesize; } @@ -1913,14 +1913,19 @@ TagDirectory* ExifManager::parseCIFF (FILE* f, int base, int length) Tag* ExifManager::saveCIFFMNTag (FILE* f, TagDirectory* root, int len, const char* name) { int s = ftell (f); - char* data = new char [len]; - fread (data, len, 1, f); - TagDirectory* mn = root->getTag ("Exif")->getDirectory()->getTag ("MakerNote")->getDirectory(); - Tag* cs = new Tag (mn, lookupAttrib (canonAttribs, name)); - cs->initUndefArray (data, len); - mn->addTag (cs); - fseek (f, s, SEEK_SET); - return cs; + if(s >= 0) { + char* data = new char [len]; + fread (data, len, 1, f); + TagDirectory* mn = root->getTag ("Exif")->getDirectory()->getTag ("MakerNote")->getDirectory(); + Tag* cs = new Tag (mn, lookupAttrib (canonAttribs, name)); + cs->initUndefArray (data, len); + mn->addTag (cs); + fseek (f, s, SEEK_SET); + delete [] data; + return cs; + } else { + return nullptr; + } } void ExifManager::parseCIFF (FILE* f, int base, int length, TagDirectory* root) @@ -2500,6 +2505,8 @@ parse_leafdata (TagDirectory* root, ByteOrder order) if (*p1 != '\0') { t->initInt (atoi (p1), LONG); exif->getDirectory()->addTagFront (t); + } else { + delete t; } } else if (strcmp (tag, "DateTimeOriginal") == 0 && sscanf (val, "%d-%d-%dT%d:%d:%dZ", @@ -3108,8 +3115,8 @@ bool extractLensInfo (std::string &fullname, double &minFocal, double &maxFocal, maxFocal = 0.0; maxApertureAtMinFocal = 0.0; maxApertureAtMaxFocal = 0.0; - char buffer[1024]; - strcpy (buffer, fullname.c_str()); + char buffer[1025]; + strncpy (buffer, fullname.c_str(), 1024); char *pF = strstr (buffer, "f/" ); if ( pF ) { diff --git a/rtgui/CMakeLists.txt b/rtgui/CMakeLists.txt index c317f8525..7b5140212 100644 --- a/rtgui/CMakeLists.txt +++ b/rtgui/CMakeLists.txt @@ -179,7 +179,6 @@ if(WIN32) ${GTKMM_LIBRARY_DIRS} ${GTK_LIBRARY_DIRS} ) - #set_target_properties(rth PROPERTIES LINK_FLAGS "-mwindows") else() include_directories(${EXTRA_INCDIR} ${CANBERRA-GTK_INCLUDE_DIRS} @@ -225,6 +224,9 @@ add_dependencies(rth UpdateInfo) add_dependencies(rth-cli UpdateInfo) # Set executables targets properties, i.e. output filename and compile flags +if(WIN32) +set_target_properties(rth PROPERTIES LINK_FLAGS "-mwindows") +endif() set_target_properties(rth PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" OUTPUT_NAME rawtherapee) set_target_properties(rth-cli PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" OUTPUT_NAME rawtherapee-cli) diff --git a/rtgui/adjuster.cc b/rtgui/adjuster.cc index 2e08e3129..a4f57499d 100644 --- a/rtgui/adjuster.cc +++ b/rtgui/adjuster.cc @@ -588,38 +588,23 @@ void Adjuster::editedToggled () eventPending = false; } -double Adjuster::trimValue (double val) +void Adjuster::trimValue (double &val) { - if (val > vMax) { - val = vMax; // shapeValue(vMax) ? - } else if (val < vMin) { - val = vMin; // shapeValue(vMin) ? - } + val = rtengine::LIM(val, vMin, vMax); - return val; } -int Adjuster::trimValue (int val) +void Adjuster::trimValue (int &val) { - if (val > (int)vMax) { - val = (int)vMax; // shapeValue(vMax) ? - } else if (val < (int)vMin) { - val = (int)vMin; // shapeValue(vMin) ? - } + val = rtengine::LIM(val, static_cast(vMin), static_cast(vMax)); - return val; } -float Adjuster::trimValue (float val) +void Adjuster::trimValue (float &val) { - if (val > (float)vMax) { - val = (float)vMax; // shapeValue(vMax) ? - } else if (val < (float)vMin) { - val = (float)vMin; // shapeValue(vMin) ? - } + val = rtengine::LIM(val, static_cast(vMin), static_cast(vMax)); - return val; } diff --git a/rtgui/adjuster.h b/rtgui/adjuster.h index 9f413a142..768406a33 100644 --- a/rtgui/adjuster.h +++ b/rtgui/adjuster.h @@ -56,13 +56,11 @@ protected: sigc::connection autoChange; sigc::connection buttonReleaseSlider; sigc::connection buttonReleaseSpin; - bool listenerReady; double defaultVal; // current default value (it can change when switching from ADD or SET mode) double ctorDefaultVal; // default value at construction time EditedState editedState; EditedState defEditedState; EditedState autoState; - EditedState defAutoState; int digits; Gtk::CheckButton* editedCheckBox; bool afterReset; @@ -172,9 +170,9 @@ public: void resetValue (bool toInitial); void resetPressed (GdkEventButton* event); void editedToggled (); - double trimValue (double val); - float trimValue (float val); - int trimValue (int val); + void trimValue (double &val); + void trimValue (float &val); + void trimValue (int &val); }; #endif diff --git a/rtgui/batchqueuepanel.cc b/rtgui/batchqueuepanel.cc index 3a37996a0..fcccdf08a 100644 --- a/rtgui/batchqueuepanel.cc +++ b/rtgui/batchqueuepanel.cc @@ -41,7 +41,7 @@ static Glib::ustring makeFolderLabel(Glib::ustring path) return path; } -BatchQueuePanel::BatchQueuePanel (FileCatalog* aFileCatalog) +BatchQueuePanel::BatchQueuePanel (FileCatalog* aFileCatalog) : parent(nullptr) { batchQueue = Gtk::manage( new BatchQueue(aFileCatalog) ); diff --git a/rtgui/blackwhite.cc b/rtgui/blackwhite.cc index 67dd9f64a..efa960a81 100644 --- a/rtgui/blackwhite.cc +++ b/rtgui/blackwhite.cc @@ -886,7 +886,9 @@ void BlackWhite::neutral_pressed () updateRGBLabel(); - listener->panelChanged (EvNeutralBW, M("ADJUSTER_RESET_TO_DEFAULT")); + if(listener) { + listener->panelChanged (EvNeutralBW, M("ADJUSTER_RESET_TO_DEFAULT")); + } } void BlackWhite::enabledcc_toggled () diff --git a/rtgui/coarsepanel.cc b/rtgui/coarsepanel.cc index 63a9251fb..a201b1f7f 100644 --- a/rtgui/coarsepanel.cc +++ b/rtgui/coarsepanel.cc @@ -22,7 +22,7 @@ using namespace rtengine; using namespace rtengine::procparams; -CoarsePanel::CoarsePanel () : ToolPanel () +CoarsePanel::CoarsePanel () : ToolPanel (), oldhflip(false), oldvflip(false) { degree = 0; diff --git a/rtgui/coordinateadjuster.cc b/rtgui/coordinateadjuster.cc index 3664902e9..ac8e5ea4e 100644 --- a/rtgui/coordinateadjuster.cc +++ b/rtgui/coordinateadjuster.cc @@ -40,7 +40,7 @@ void Axis::setValues(Glib::ustring label, unsigned int decimal, double increment this->rangeUpperBound = valMax; } -CoordinateAdjuster::AxisAdjuster::AxisAdjuster(CoordinateAdjuster *parent, const Axis *axis, char index) : idx(index), parent(parent) +CoordinateAdjuster::AxisAdjuster::AxisAdjuster(CoordinateAdjuster *parent, const Axis *axis, char index) : idx(index), parent(parent), rangeLowerBound(0.f), rangeUpperBound(0.f) { label = Gtk::manage( new Gtk::Label(axis->label) ); spinButton = Gtk::manage( new Gtk::SpinButton() ); @@ -123,10 +123,9 @@ void CoordinateAdjuster::createWidgets(const std::vector &axis) axisAdjusters.resize(axis.size()); for (unsigned int i = 0; i < count; ++i) { - AxisAdjuster *currAdjuster = nullptr; const Axis *currAxis = &(axis.at(i)); axisAdjusters.at(i) = new AxisAdjuster(this, currAxis, i); - currAdjuster = axisAdjusters.at(i); + AxisAdjuster *currAdjuster = axisAdjusters.at(i); currAdjuster->rangeLowerBound = currAxis->rangeLowerBound; currAdjuster->rangeUpperBound = currAxis->rangeUpperBound; diff --git a/rtgui/crop.cc b/rtgui/crop.cc index a2a0e36ed..4b9e22fd2 100644 --- a/rtgui/crop.cc +++ b/rtgui/crop.cc @@ -54,7 +54,7 @@ int notifyListenerUI (void* data) } -Crop::Crop (): FoldableToolPanel(this, "crop", M("TP_CROP_LABEL"), false, true) +Crop::Crop (): FoldableToolPanel(this, "crop", M("TP_CROP_LABEL"), false, true), opt(0), wDirty(true), hDirty(true), xDirty(true), yDirty(true), lastFixRatio(true) { clistener = nullptr; @@ -1219,10 +1219,6 @@ void Crop::cropResized (int &x, int &y, int& x2, int& y2) W = maxw; } - if (H > maxh) { - H = maxh; - } - if (fixr->get_active()) { double r = getRatio (); diff --git a/rtgui/crophandler.cc b/rtgui/crophandler.cc index 6d6e9c42f..f6ff83a7d 100644 --- a/rtgui/crophandler.cc +++ b/rtgui/crophandler.cc @@ -545,6 +545,7 @@ void CropHandler::colorPick (const rtengine::Coord &pickerPos, float &r, float & } } + count = std::max(1u, count); // Averaging r = (float)r2 / (float)count / 255.f; g = (float)g2 / (float)count / 255.f; @@ -569,6 +570,8 @@ void CropHandler::colorPick (const rtengine::Coord &pickerPos, float &r, float & } } } + + count = std::max(1u, count); // Averaging rpreview = (float)r2 / (float)count / 255.f; gpreview = (float)g2 / (float)count / 255.f; diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index 25311b97b..8af0541fe 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -36,7 +36,7 @@ using namespace rtengine; CropWindow::CropWindow (ImageArea* parent, bool isLowUpdatePriority_, bool isDetailWindow) : ObjectMOBuffer(parent), state(SNormal), press_x(0), press_y(0), action_x(0), action_y(0), pickedObject(-1), pickModifierKey(0), rot_deg(0), onResizeArea(false), deleted(false), - fitZoomEnabled(true), fitZoom(false), /*isLowUpdatePriority(isLowUpdatePriority_),*/ hoveredPicker(nullptr), cropLabel(Glib::ustring("100%")), + fitZoomEnabled(true), fitZoom(false), cursor_type(CSArrow), /*isLowUpdatePriority(isLowUpdatePriority_),*/ hoveredPicker(nullptr), cropLabel(Glib::ustring("100%")), backColor(options.bgcolor), decorated(true), isFlawnOver(false), titleHeight(30), sideBorderWidth(3), lowerBorderWidth(3), upperBorderWidth(1), sepWidth(2), xpos(30), ypos(30), width(0), height(0), imgAreaX(0), imgAreaY(0), imgAreaW(0), imgAreaH(0), imgX(-1), imgY(-1), imgW(1), imgH(1), iarea(parent), cropZoom(0), zoomVersion(0), exposeVersion(0), cropgl(nullptr), @@ -895,7 +895,7 @@ void CropWindow::pointerMoved (int bstate, int x, int y) } else if (state == SDragPicker) { Coord imgPos; action_x = x - press_x; - action_x = y - press_y; + action_y = y - press_y; screenCoordToImage (x, y, imgPos.x, imgPos.y); if (imgPos.x < 0) { imgPos.x = 0; @@ -1026,6 +1026,12 @@ void CropWindow::pointerMoved (int bstate, int x, int y) cropHandler.cimg.lock (); int vx = x - xpos - imgX; 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; // if (vx < cropHandler.cropPixbuf->get_width() && vy < cropHandler.cropPixbuf->get_height()) // pmlistener->pointerMoved (true, mx, my, pix[0], pix[1], pix[2]); @@ -1613,8 +1619,8 @@ void CropWindow::expose (Cairo::RefPtr cr) const int hlThreshold = options.highlightThreshold; const int shThreshold = options.shadowThreshold; - const float ShawdowFac = 64 / (options.shadowThreshold + 1); - const float HighlightFac = 64 / (256 - options.highlightThreshold); + const float ShawdowFac = 64.f / (options.shadowThreshold + 1); + const float HighlightFac = 64.f / (256 - options.highlightThreshold); const bool showclippedAny = (!showR && !showG && !showB && !showL); // will show clipping if any of RGB chanels is clipped #ifdef _OPENMP diff --git a/rtgui/curveeditor.cc b/rtgui/curveeditor.cc index 117051b2a..f8beff547 100644 --- a/rtgui/curveeditor.cc +++ b/rtgui/curveeditor.cc @@ -197,8 +197,11 @@ CurveEditor::CurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup, CurveEd remoteDrag = false; selected = DCT_Linear; bottomBarCP = nullptr; + bottomBarCId = 0; leftBarCP = nullptr; + leftBarCId = 0; curveCP = nullptr; + curveCId = 0; relatedWidget = nullptr; expandRelatedWidget = true; diff --git a/rtgui/curveeditorgroup.cc b/rtgui/curveeditorgroup.cc index 8c2efdadd..29c8f5f84 100644 --- a/rtgui/curveeditorgroup.cc +++ b/rtgui/curveeditorgroup.cc @@ -395,7 +395,7 @@ void CurveEditorGroup::setUnChanged (bool uc, CurveEditor* ce) } } -CurveEditorSubGroup::CurveEditorSubGroup(Glib::ustring& curveDir) : curveDir(curveDir), lastFilename("") +CurveEditorSubGroup::CurveEditorSubGroup(Glib::ustring& curveDir) : curveDir(curveDir), lastFilename(""), valLinear(0), valUnchanged(0), parent(nullptr) { leftBar = nullptr; bottomBar = nullptr; diff --git a/rtgui/darkframe.cc b/rtgui/darkframe.cc index d13f8e652..83bad565a 100644 --- a/rtgui/darkframe.cc +++ b/rtgui/darkframe.cc @@ -25,7 +25,7 @@ using namespace rtengine; using namespace rtengine::procparams; -DarkFrame::DarkFrame () : FoldableToolPanel(this, "darkframe", M("TP_DARKFRAME_LABEL")) +DarkFrame::DarkFrame () : FoldableToolPanel(this, "darkframe", M("TP_DARKFRAME_LABEL")), dfChanged(false), lastDFauto(false), dfp(nullptr), israw(true) { hbdf = Gtk::manage(new Gtk::HBox()); hbdf->set_spacing(4); diff --git a/rtgui/diagonalcurveeditorsubgroup.cc b/rtgui/diagonalcurveeditorsubgroup.cc index 936bf0d64..b64034b96 100644 --- a/rtgui/diagonalcurveeditorsubgroup.cc +++ b/rtgui/diagonalcurveeditorsubgroup.cc @@ -525,7 +525,8 @@ void DiagonalCurveEditorSubGroup::pipetteDrag(EditDataProvider *provider, int mo case (DCT_Parametric): if (editedAdjuster) { - int trimmedValue = editedAdjuster->trimValue(editedAdjusterValue - (provider->deltaScreen.y / 2)); + int trimmedValue = editedAdjusterValue - (provider->deltaScreen.y / 2); + editedAdjuster->trimValue(trimmedValue); if (trimmedValue != editedAdjuster->getIntValue()) { editedAdjuster->setValue(trimmedValue); diff --git a/rtgui/edit.cc b/rtgui/edit.cc index 476cd3602..9ee0d63ba 100644 --- a/rtgui/edit.cc +++ b/rtgui/edit.cc @@ -822,7 +822,7 @@ OPIcon::OPIcon(const Cairo::RefPtr &normal, } if (dragged) { - draggedImg = active; + draggedImg = dragged; } if (insensitive) { diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 097ef2806..e10afa686 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -212,10 +212,12 @@ private: spGamutCheck.show (); } +#if !defined(__APPLE__) void profileBoxChanged () { updateParameters (); } +#endif void intentBoxChanged (int) { @@ -451,7 +453,7 @@ public: }; 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; @@ -1697,6 +1699,8 @@ bool EditorPanel::idle_saveImage (ProgressConnector *pc, Gl else if (sf.format == "jpg") 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)); + else + delete ld; } else { Glib::ustring msg_ = Glib::ustring ("") + fname + ": Error during image processing\n"; Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); diff --git a/rtgui/exportpanel.h b/rtgui/exportpanel.h index db4431ca5..be6c9b4e3 100644 --- a/rtgui/exportpanel.h +++ b/rtgui/exportpanel.h @@ -76,8 +76,6 @@ protected: MyComboBoxText* raw_xtrans_method; Gtk::Button* btnFastExport; - Gtk::Button* btnExportLoadSettings; - Gtk::Button* btnExportSaveSettings; MySpinButton* MaxWidth; MySpinButton* MaxHeight; diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index dd37a740b..c026b63a8 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -125,14 +125,23 @@ void findOriginalEntries (const std::vector& entries) } -FileBrowser::FileBrowser () - : tbl(nullptr), numFiltered(0) +FileBrowser::FileBrowser () : + menuLabel(nullptr), + selectDF(nullptr), + thisIsDF(nullptr), + autoDF(nullptr), + selectFF(nullptr), + thisIsFF(nullptr), + autoFF(nullptr), + clearFromCache(nullptr), + clearFromCacheFull(nullptr), + colorLabel_actionData(nullptr), + bppcl(nullptr), + tbl(nullptr), + numFiltered(0), + exportPanel(nullptr) { - - fbih = new FileBrowserIdleHelper; - fbih->fbrowser = this; - fbih->destroyed = false; - fbih->pending = 0; + session_id_ = 0; ProfileStore::getInstance()->addListener(this); @@ -546,37 +555,27 @@ void FileBrowser::doubleClicked (ThumbBrowserEntryBase* entry) void FileBrowser::addEntry (FileBrowserEntry* entry) { struct addparams { - FileBrowserIdleHelper* fbih; - FileBrowserEntry* entry; + FileBrowser *browser; + FileBrowserEntry *entry; + unsigned int session_id; }; - fbih->pending++; - entry->setParent (this); addparams* const ap = new addparams; - ap->fbih = fbih; + entry->setParent (this); + ap->browser = this; ap->entry = entry; + ap->session_id = session_id(); const auto func = [](gpointer data) -> gboolean { addparams* const ap = static_cast(data); - FileBrowserIdleHelper* fbih = ap->fbih; - - if (fbih->destroyed) { - if (fbih->pending == 1) { - delete fbih; - } else { - fbih->pending--; - } - + if (ap->session_id != ap->browser->session_id()) { delete ap->entry; delete ap; - - return 0; + } else { + ap->browser->addEntry_(ap->entry); + delete ap; } - ap->fbih->fbrowser->addEntry_ (ap->entry); - delete ap; - fbih->pending--; - return FALSE; }; @@ -653,16 +652,7 @@ FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) void FileBrowser::close () { - if (fbih->pending) { - fbih->destroyed = true; - } else { - delete fbih; - } - - fbih = new FileBrowserIdleHelper; - fbih->fbrowser = this; - fbih->destroyed = false; - fbih->pending = 0; + ++session_id_; { MYWRITERLOCK(l, entryRW); diff --git a/rtgui/filebrowser.h b/rtgui/filebrowser.h index 4bad832eb..4efdb7219 100644 --- a/rtgui/filebrowser.h +++ b/rtgui/filebrowser.h @@ -53,12 +53,6 @@ public: } }; -struct FileBrowserIdleHelper { - FileBrowser* fbrowser; - bool destroyed; - int pending; -}; - /* * Class handling actions common to all thumbnails of the file browser */ @@ -71,6 +65,7 @@ private: typedef sigc::signal type_trash_changed; IdleRegister idle_register; + unsigned int session_id_; protected: Gtk::MenuItem* rank[6]; @@ -129,7 +124,6 @@ protected: FileBrowserListener* tbl; BrowserFilter filter; int numFiltered; - FileBrowserIdleHelper* fbih; void toTrashRequested (std::vector tbe); void fromTrashRequested (std::vector tbe); @@ -152,6 +146,8 @@ public: FileBrowserEntry* delEntry (const Glib::ustring& fname); // return the entry if found here return NULL otherwise void close (); + unsigned int session_id() const { return session_id_; } + void setBatchPParamsChangeListener (BatchPParamsChangeListener* l) { bppcl = l; diff --git a/rtgui/filebrowserentry.cc b/rtgui/filebrowserentry.cc index ceab1c1d3..9bce8575a 100644 --- a/rtgui/filebrowserentry.cc +++ b/rtgui/filebrowserentry.cc @@ -38,7 +38,7 @@ Glib::RefPtr FileBrowserEntry::recentlySavedIcon; Glib::RefPtr FileBrowserEntry::enqueuedIcon; FileBrowserEntry::FileBrowserEntry (Thumbnail* thm, const Glib::ustring& fname) - : ThumbBrowserEntryBase (fname), wasInside(false), iatlistener(nullptr), cropgl(nullptr), state(SNormal), crop_custom_ratio(0.f) + : ThumbBrowserEntryBase (fname), wasInside(false), iatlistener(nullptr), press_x(0), press_y(0), action_x(0), action_y(0), rot_deg(0.0), landscape(true), cropgl(nullptr), state(SNormal), crop_custom_ratio(0.f) { thumbnail = thm; @@ -60,9 +60,7 @@ FileBrowserEntry::FileBrowserEntry (Thumbnail* thm, const Glib::ustring& fname) iconsLoaded = true; } - if (thm) { - thm->addThumbnailListener (this); - } + thumbnail->addThumbnailListener (this); } FileBrowserEntry::~FileBrowserEntry () diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index 4ac1e0a3d..0d10ba125 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -44,12 +44,16 @@ using namespace std; FileCatalog::FileCatalog (CoarsePanel* cp, ToolBar* tb, FilePanel* filepanel) : filepanel(filepanel), selectedDirectoryId(1), + actionNextPrevious(NAV_NONE), listener(nullptr), fslistener(nullptr), + iatlistener(nullptr), hasValidCurrentEFS(false), filterPanel(nullptr), + exportPanel(nullptr), previewsToLoad(0), previewsLoaded(0), + modifierKey(0), coarsePanel(cp), toolBar(tb) { @@ -720,6 +724,7 @@ void FileCatalog::previewReady (int dir_id, FileBrowserEntry* fdn) { if ( dir_id != selectedDirectoryId ) { + delete fdn; return; } diff --git a/rtgui/filepanel.cc b/rtgui/filepanel.cc index 1ac4046b6..316beb791 100644 --- a/rtgui/filepanel.cc +++ b/rtgui/filepanel.cc @@ -22,7 +22,7 @@ #include "inspector.h" #include "placesbrowser.h" -FilePanel::FilePanel () : parent(nullptr) +FilePanel::FilePanel () : parent(nullptr), error(0) { // Contains everything except for the batch Tool Panel and tabs (Fast Export, Inspect, etc) diff --git a/rtgui/filmsimulation.cc b/rtgui/filmsimulation.cc index e21857ec9..a1471f970 100644 --- a/rtgui/filmsimulation.cc +++ b/rtgui/filmsimulation.cc @@ -191,7 +191,7 @@ void FilmSimulation::setAdjusterBehavior( bool strength ) void FilmSimulation::trimValues( rtengine::procparams::ProcParams* pp ) { - pp->filmSimulation.strength = m_strength->trimValue( pp->filmSimulation.strength ); + m_strength->trimValue( pp->filmSimulation.strength ); } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/rtgui/guiutils.cc b/rtgui/guiutils.cc index 91284e983..91348e52f 100644 --- a/rtgui/guiutils.cc +++ b/rtgui/guiutils.cc @@ -1281,6 +1281,8 @@ MyImageMenuItem::MyImageMenuItem(Glib::ustring label, Glib::ustring imageFileNam if (!imageFileName.empty()) { image = Gtk::manage( new RTImage(imageFileName) ); box->attach_next_to(*image, Gtk::POS_LEFT, 1, 1); + } else { + image = nullptr; } box->attach_next_to(*this->label, Gtk::POS_RIGHT, 1, 1); diff --git a/rtgui/histogrampanel.cc b/rtgui/histogrampanel.cc index 45076208b..002c4608b 100644 --- a/rtgui/histogrampanel.cc +++ b/rtgui/histogrampanel.cc @@ -1179,6 +1179,7 @@ void HistogramArea::drawCurve(Cairo::RefPtr &cr, LUTu & data, double scale, int hsize, int vsize) { cr->move_to (0, vsize - 1); + scale = scale <= 0.f ? 0.001f : scale; // avoid division by zero and negative values for (int i = 0; i < 256; i++) { double val = data[i] * (double)(vsize - 2) / scale; diff --git a/rtgui/history.cc b/rtgui/history.cc index 11f8c63a0..8e7adfab7 100644 --- a/rtgui/history.cc +++ b/rtgui/history.cc @@ -26,7 +26,7 @@ using namespace rtengine::procparams; Glib::ustring eventDescrArray[NUMOFEVENTS]; -History::History (bool bookmarkSupport) : blistener(nullptr), tpc (nullptr), bmnum (1) +History::History (bool bookmarkSupport) : historyVPaned(nullptr), blistener(nullptr), tpc (nullptr), bmnum (1) { blistenerLock = false; // sets default that the Before preview will not be locked diff --git a/rtgui/imagearea.cc b/rtgui/imagearea.cc index 0842f4fb1..c0d334482 100644 --- a/rtgui/imagearea.cc +++ b/rtgui/imagearea.cc @@ -25,7 +25,7 @@ #include "../rtengine/refreshmap.h" #include "options.h" -ImageArea::ImageArea (ImageAreaPanel* p) : parent(p), firstOpen(true) +ImageArea::ImageArea (ImageAreaPanel* p) : parent(p), firstOpen(true), fullImageWidth(0), fullImageHeight(0) { infotext = ""; diff --git a/rtgui/inspector.cc b/rtgui/inspector.cc index 79839b5f9..8af99b2ab 100644 --- a/rtgui/inspector.cc +++ b/rtgui/inspector.cc @@ -259,6 +259,7 @@ void Inspector::switchImage (const Glib::ustring &fullPath) images.push_back(iBuffer); currImage = images.at(images.size() - 1); } else { + delete iBuffer; currImage = nullptr; } } diff --git a/rtgui/lensgeom.cc b/rtgui/lensgeom.cc index fc1b0a1bd..7cae75d87 100644 --- a/rtgui/lensgeom.cc +++ b/rtgui/lensgeom.cc @@ -23,7 +23,7 @@ using namespace rtengine; using namespace rtengine::procparams; -LensGeometry::LensGeometry () : FoldableToolPanel(this, "lensgeom", M("TP_LENSGEOM_LABEL")), rlistener(nullptr) +LensGeometry::LensGeometry () : FoldableToolPanel(this, "lensgeom", M("TP_LENSGEOM_LABEL")), rlistener(nullptr), lastFill(false) { fill = Gtk::manage (new Gtk::CheckButton (M("TP_LENSGEOM_FILL"))); diff --git a/rtgui/lensprofile.cc b/rtgui/lensprofile.cc index 79a0dc19f..0855ef03f 100644 --- a/rtgui/lensprofile.cc +++ b/rtgui/lensprofile.cc @@ -26,7 +26,7 @@ using namespace rtengine; using namespace rtengine::procparams; -LensProfilePanel::LensProfilePanel () : FoldableToolPanel(this, "lensprof", M("TP_LENSPROFILE_LABEL")), isRaw(true) +LensProfilePanel::LensProfilePanel () : FoldableToolPanel(this, "lensprof", M("TP_LENSPROFILE_LABEL")), lcpFileChanged(false), useDistChanged(false), useVignChanged(false), useCAChanged(false), isRaw(true), lensgeomLcpFill(nullptr) { hbLCPFile = Gtk::manage(new Gtk::HBox()); diff --git a/rtgui/main-cli.cc b/rtgui/main-cli.cc index 2a2afca63..f6df47119 100644 --- a/rtgui/main-cli.cc +++ b/rtgui/main-cli.cc @@ -115,12 +115,12 @@ int main(int argc, char **argv) // get the path where the rawtherapee executable is stored #ifdef WIN32 WCHAR exnameU[512] = {0}; - GetModuleFileNameW (NULL, exnameU, 512); - WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 512, 0, 0 ); + GetModuleFileNameW (NULL, exnameU, 511); + WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 ); #else - if (readlink("/proc/self/exe", exname, 512) < 0) { - strncpy(exname, argv[0], 512); + if (readlink("/proc/self/exe", exname, 511) < 0) { + strncpy(exname, argv[0], 511); } #endif diff --git a/rtgui/main.cc b/rtgui/main.cc index 41891b995..a0938e4c0 100644 --- a/rtgui/main.cc +++ b/rtgui/main.cc @@ -139,12 +139,12 @@ int main(int argc, char **argv) // get the path where the rawtherapee executable is stored #ifdef WIN32 WCHAR exnameU[512] = {0}; - GetModuleFileNameW (NULL, exnameU, 512); - WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 512, 0, 0 ); + GetModuleFileNameW (NULL, exnameU, 511); + WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 ); #else - if (readlink("/proc/self/exe", exname, 512) < 0) { - strncpy(exname, argv[0], 512); + if (readlink("/proc/self/exe", exname, 511) < 0) { + strncpy(exname, argv[0], 511); } #endif @@ -437,7 +437,6 @@ void deleteProcParams(std::vector &pparam int processLineParams( int argc, char **argv ) { - unsigned errors = 0; for( int iArg = 1; iArg < argc; iArg++) { Glib::ustring currParam(argv[iArg]); @@ -512,5 +511,5 @@ int processLineParams( int argc, char **argv ) return 1; } - return errors > 0 ? -2 : 0; + return 0; } diff --git a/rtgui/mycurve.cc b/rtgui/mycurve.cc index dbb3eef5b..215eac429 100644 --- a/rtgui/mycurve.cc +++ b/rtgui/mycurve.cc @@ -21,7 +21,7 @@ #include #include -MyCurve::MyCurve () : pipetteR(-1.f), pipetteG(-1.f), pipetteB(-1.f), pipetteVal(-1.f), listener(nullptr), cursor_type( CSArrow) +MyCurve::MyCurve () : pipetteR(-1.f), pipetteG(-1.f), pipetteB(-1.f), pipetteVal(-1.f), listener(nullptr), cursor_type(CSArrow), graphW(0), graphH(0), mod_type(Gdk::MODIFIER_MASK), cursorX(0), cursorY(0), snapToMinDistX(0.0), snapToMinDistY(0.0), snapToValX(0.0), snapToValY(0.0) { graphX = get_allocation().get_width() - RADIUS * 2; diff --git a/rtgui/mydiagonalcurve.cc b/rtgui/mydiagonalcurve.cc index bf146b03d..d249d4439 100644 --- a/rtgui/mydiagonalcurve.cc +++ b/rtgui/mydiagonalcurve.cc @@ -21,7 +21,7 @@ #include #include -MyDiagonalCurve::MyDiagonalCurve () : activeParam(-1), bghistvalid(false) +MyDiagonalCurve::MyDiagonalCurve () : closest_point(0), clampedX(0.0), clampedY(0.0), deltaX(0.0), deltaY(0.0), distanceX(0.0), distanceY(0.0), ugpX(0.0), ugpY(0.0), activeParam(-1), bghistvalid(false) { graphW = get_allocation().get_width() - RADIUS * 2; @@ -1111,8 +1111,10 @@ bool MyDiagonalCurve::pipetteButton1Pressed(EditDataProvider *provider, int modi curve.y.insert (ity, 0); // the graph is refreshed only if a new point is created (snapped to a pixel) - curve.x.at(lit_point) = clampedX; - curve.y.at(lit_point) = clampedY; + if (lit_point >= 0) { + curve.x.at(lit_point) = clampedX; + curve.y.at(lit_point) = clampedY; + } if (lit_point > -1 && grab_point == -1 && coordinateAdjuster->is_visible()) { std::vector position; diff --git a/rtgui/myflatcurve.cc b/rtgui/myflatcurve.cc index 210fb42f2..4da683b0c 100644 --- a/rtgui/myflatcurve.cc +++ b/rtgui/myflatcurve.cc @@ -21,7 +21,25 @@ #include #include -MyFlatCurve::MyFlatCurve () +MyFlatCurve::MyFlatCurve () : + clampedX(0.0), + clampedY(0.0), + deltaX(0.0), + deltaY(0.0), + distanceX(0.0), + distanceY(0.0), + ugpX(0.0), + ugpY(0.0), + leftTanX(0.0), + rightTanX(0.0), + preciseCursorX(0.0), + preciseCursorY(0.0), + minDistanceX(0.0), + minDistanceY(0.0), + deletedPointX(0.0), + leftTanHandle({0.0, 0.0}), + rightTanHandle({0.0, 0.0}), + draggingElement(false) { graphW = get_allocation().get_width() - RADIUS * 2; diff --git a/rtgui/options.cc b/rtgui/options.cc index df68d0ac9..1f29264b8 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -576,22 +576,26 @@ void Options::setDefaults () 0, // ADDSET_DIRPYREQ_THRESHOLD 0, // ADDSET_DIRPYREQ_SKINPROTECT 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_RAWFFCLIPCONTROL 0, // ADDSET_FILMSIMULATION_STRENGTH 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_THRESHOLD2 - 0, // ADDSET_WA_THRES 0, // ADDSET_WA_CHRO 0, // ADDSET_WA_CHROMA 0, // ADDSET_WA_CONTRAST - 0, // ADDSET_WA_SKINPROTECT - 0, // ADDSET_WA_RESCHRO 0, // ADDSET_WA_RESCON 0, // ADDSET_WA_RESCONH - 0, // ADDSET_WA_THRR - 0, // ADDSET_WA_THRRH + 0, // ADDSET_WA_RESCHRO 0, // ADDSET_WA_SKYPROTECT 0, // ADDSET_WA_EDGRAD 0, // ADDSET_WA_EDGVAL diff --git a/rtgui/partialpastedlg.h b/rtgui/partialpastedlg.h index 438744863..8c0d4db5d 100644 --- a/rtgui/partialpastedlg.h +++ b/rtgui/partialpastedlg.h @@ -101,8 +101,6 @@ public: Gtk::CheckButton* raw_black; Gtk::CheckButton* raw_ca_autocorrect; Gtk::CheckButton* raw_caredblue; - Gtk::CheckButton* raw_cablue; - Gtk::CheckButton* raw_caautostrength; Gtk::CheckButton* raw_hotpix_filt; Gtk::CheckButton* raw_deadpix_filt; Gtk::CheckButton* raw_linenoise; diff --git a/rtgui/previewmodepanel.cc b/rtgui/previewmodepanel.cc index 7993be2e3..50beb8b66 100644 --- a/rtgui/previewmodepanel.cc +++ b/rtgui/previewmodepanel.cc @@ -226,7 +226,7 @@ void PreviewModePanel::buttonToggled (Gtk::ToggleButton* tbpreview) int PreviewModePanel::GetbackColor() { - int backColor; + int backColor = 0; if (backColor0->get_active ()) { backColor = 0; diff --git a/rtgui/previewwindow.cc b/rtgui/previewwindow.cc index 0a0fd6b2a..66f49f61e 100644 --- a/rtgui/previewwindow.cc +++ b/rtgui/previewwindow.cc @@ -22,7 +22,7 @@ #include "cursormanager.h" PreviewWindow::PreviewWindow () : previewHandler(nullptr), mainCropWin(nullptr), imageArea(nullptr), imgX(0), imgY(0), imgW(0), imgH(0), - zoom(0.0), isMoving(false), needsUpdate(false), cursor_type(CSUndefined) + zoom(0.0), press_x(0), press_y(0), isMoving(false), needsUpdate(false), cursor_type(CSUndefined) { set_name("PreviewWindow"); diff --git a/rtgui/profilepanel.cc b/rtgui/profilepanel.cc index 06768cf56..6d317f5a4 100644 --- a/rtgui/profilepanel.cc +++ b/rtgui/profilepanel.cc @@ -39,7 +39,7 @@ void ProfilePanel::cleanup () delete partialProfileDlg; } -ProfilePanel::ProfilePanel () : storedPProfile(nullptr), lastFilename(""), imagePath("") +ProfilePanel::ProfilePanel () : storedPProfile(nullptr), lastFilename(""), imagePath(""), lastSavedPSE(nullptr), customPSE(nullptr) { tpc = nullptr; @@ -128,6 +128,8 @@ ProfilePanel::~ProfilePanel () delete profileFillModeOnImage; delete profileFillModeOffImage; + delete lastSavedPSE; + delete customPSE; } bool ProfilePanel::isCustomSelected() @@ -164,14 +166,24 @@ Gtk::TreeIter ProfilePanel::getLastSavedRow() 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); return newEntry; } 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); return newEntry; } @@ -741,7 +753,6 @@ void ProfilePanel::initProfile (const Glib::ustring& profileFullPath, ProcParams // adding the Last Saved combobox entry, if needed if (lastsaved) { - defprofile = lastsaved; lasSavedEntry = getLastSavedRow(); } diff --git a/rtgui/profilepanel.h b/rtgui/profilepanel.h index 72c9db36b..ddd7133ca 100644 --- a/rtgui/profilepanel.h +++ b/rtgui/profilepanel.h @@ -42,6 +42,8 @@ private: RTImage *profileFillModeOffImage; Gtk::ToggleButton* fillMode; Gtk::TreeIter currRow; + ProfileStoreEntry *lastSavedPSE; + ProfileStoreEntry *customPSE; void profileFillModeToggled (); bool isCustomSelected (); diff --git a/rtgui/resize.cc b/rtgui/resize.cc index bf2d4ce67..1a87bbe8c 100644 --- a/rtgui/resize.cc +++ b/rtgui/resize.cc @@ -29,14 +29,13 @@ Resize::Resize () : FoldableToolPanel(this, "resize", M("TP_RESIZE_LABEL"), fals croph = 0; Gtk::Table* combos = Gtk::manage (new Gtk::Table (2, 2)); - Gtk::Label *label = nullptr; appliesTo = Gtk::manage (new MyComboBoxText ()); appliesTo->append (M("TP_RESIZE_CROPPEDAREA")); appliesTo->append (M("TP_RESIZE_FULLIMAGE")); appliesTo->set_active (0); - label = Gtk::manage (new Gtk::Label (M("TP_RESIZE_APPLIESTO"))); + Gtk::Label *label = Gtk::manage (new Gtk::Label (M("TP_RESIZE_APPLIESTO"))); label->set_alignment(0., 0.); combos->attach (*label, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 2, 2); combos->attach (*appliesTo, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK, 2, 2); diff --git a/rtgui/splash.cc b/rtgui/splash.cc index 0c1c56397..576692690 100644 --- a/rtgui/splash.cc +++ b/rtgui/splash.cc @@ -255,29 +255,6 @@ Splash::Splash (Gtk::Window& parent) : Gtk::Dialog(M("GENERAL_ABOUT"), parent, t set_keep_above (true); } -Splash::Splash (Gtk::Window& parent, int maxtime) : Gtk::Dialog(M("GENERAL_ABOUT"), parent, true) -{ - - splashImage = Gtk::manage(new SplashImage ()); - get_content_area()->pack_start (*splashImage); - splashImage->show (); - - if (maxtime > 0) { - Glib::signal_timeout().connect (sigc::mem_fun(*this, &Splash::on_timer), maxtime); - } - - set_position (Gtk::WIN_POS_CENTER); - - if (maxtime > 0) { - set_decorated (false); - } - - add_events(Gdk::BUTTON_RELEASE_MASK); - set_resizable (false); - - set_keep_above (true); -} - bool Splash::on_timer () { diff --git a/rtgui/splash.h b/rtgui/splash.h index 3fea9fdd1..4769700f6 100644 --- a/rtgui/splash.h +++ b/rtgui/splash.h @@ -48,7 +48,6 @@ private: Gtk::ScrolledWindow* releaseNotesSW; public: - Splash (Gtk::Window& parent, int maxtime); explicit Splash (Gtk::Window& parent); bool hasReleaseNotes() diff --git a/rtgui/thresholdadjuster.h b/rtgui/thresholdadjuster.h index 9c22eede4..200fe2175 100644 --- a/rtgui/thresholdadjuster.h +++ b/rtgui/thresholdadjuster.h @@ -60,7 +60,6 @@ protected: //sigc::connection spinChange; sigc::connection selectorChange; sigc::connection editedChange; - bool listenerReady; double initialDefaultVal[4]; // default value at construction time EditedState editedState; EditedState defEditedState; diff --git a/rtgui/thumbbrowserbase.cc b/rtgui/thumbbrowserbase.cc index deb423569..d6c2acd9d 100644 --- a/rtgui/thumbbrowserbase.cc +++ b/rtgui/thumbbrowserbase.cc @@ -25,7 +25,7 @@ using namespace std; ThumbBrowserBase::ThumbBrowserBase () - : location(THLOC_FILEBROWSER), inspector(nullptr), isInspectorActive(false), lastClicked(nullptr), previewHeight(options.thumbSize), numOfCols(1) + : location(THLOC_FILEBROWSER), inspector(nullptr), isInspectorActive(false), eventTime(0), lastClicked(nullptr), previewHeight(options.thumbSize), numOfCols(1), arrangement(TB_Horizontal) { inW = -1; inH = -1; diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index 54527a5d5..18bedf7b8 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -822,7 +822,7 @@ void Thumbnail::_loadThumbnail(bool firstTrial) tpp->init (); } - if (!initial_ && tpp) { + if (!initial_) { tw = tpp->getImageWidth (getProcParamsU(), th, imgRatio); // this might return 0 if image was just building } } diff --git a/rtgui/toolbar.cc b/rtgui/toolbar.cc index e070a9162..6c44abe57 100644 --- a/rtgui/toolbar.cc +++ b/rtgui/toolbar.cc @@ -21,7 +21,7 @@ #include "multilangmgr.h" #include "guiutils.h" -ToolBar::ToolBar () : showColPickers(true), listener (nullptr) +ToolBar::ToolBar () : showColPickers(true), listener (nullptr), pickerListener(nullptr) { editingMode = false; diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 7920b7a9b..2f37f8c2e 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -28,7 +28,7 @@ using namespace rtengine::procparams; -ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), editDataProvider(nullptr) +ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), hasChanged(false), editDataProvider(nullptr) { exposurePanel = Gtk::manage (new ToolVBox ()); @@ -509,11 +509,11 @@ void ToolPanelCoordinator::initImage (rtengine::StagedImageProcessor* ipc_, bool toneCurve->enableAll (); toneCurve->enableListener (); - const rtengine::ImageMetaData* pMetaData = ipc->getInitialImage()->getMetaData(); - exifpanel->setImageData (pMetaData); - iptcpanel->setImageData (pMetaData); - if (ipc) { + const rtengine::ImageMetaData* pMetaData = ipc->getInitialImage()->getMetaData(); + exifpanel->setImageData (pMetaData); + iptcpanel->setImageData (pMetaData); + ipc->setAutoExpListener (toneCurve); ipc->setAutoCamListener (colorappearance); ipc->setAutoBWListener (blackwhite); @@ -526,12 +526,12 @@ void ToolPanelCoordinator::initImage (rtengine::StagedImageProcessor* ipc_, bool ipc->setSizeListener (crop); ipc->setSizeListener (resize); ipc->setImageTypeListener (this); + flatfield->setShortcutPath(Glib::path_get_dirname(ipc->getInitialImage()->getFileName())); + + icm->setRawMeta (raw, (const rtengine::ImageData*)pMetaData); + lensProf->setRawMeta (raw, pMetaData); } - flatfield->setShortcutPath(Glib::path_get_dirname(ipc->getInitialImage()->getFileName())); - - icm->setRawMeta (raw, (const rtengine::ImageData*)pMetaData); - lensProf->setRawMeta (raw, pMetaData); toneCurve->setRaw (raw); hasChanged = true; diff --git a/rtgui/toolpanelcoord.h b/rtgui/toolpanelcoord.h index 4dedf7dad..cfb85e372 100644 --- a/rtgui/toolpanelcoord.h +++ b/rtgui/toolpanelcoord.h @@ -170,19 +170,6 @@ protected: TextOrIcon* toiM; TextOrIcon* toiW; - Gtk::Label* labelE; - Gtk::Label* labelD; - Gtk::Label* labelC; - Gtk::Label* labelT; - Gtk::Label* labelR; - Gtk::Label* labelM; - - Gtk::Image* imgIconE; - Gtk::Image* imgIconD; - Gtk::Image* imgIconC; - Gtk::Image* imgIconT; - Gtk::Image* imgIconR; - Gtk::Image* imgIconM; Gtk::Image* imgPanelEnd[6]; Gtk::VBox* vbPanelEnd[6]; diff --git a/rtgui/whitebalance.cc b/rtgui/whitebalance.cc index 135d30655..d16dafa08 100644 --- a/rtgui/whitebalance.cc +++ b/rtgui/whitebalance.cc @@ -428,7 +428,7 @@ void WhiteBalance::optChanged () equal->setEditedState (UnEdited); tempBias->setEditedState (UnEdited); } else { - int methodId = findWBEntryId (row[methodColumns.colLabel], WBLT_GUI); + unsigned int methodId = findWBEntryId (row[methodColumns.colLabel], WBLT_GUI); WBEntry* currMethod = WBParams::wbEntries[methodId]; tempBias->set_sensitive(currMethod->type == WBT_AUTO); @@ -792,7 +792,7 @@ void WhiteBalance::cache_customWB(int temp, double green) cache_customGreen (green); } -int WhiteBalance::findWBEntryId (Glib::ustring label, enum WB_LabelType lblType) +unsigned int WhiteBalance::findWBEntryId (const Glib::ustring &label, enum WB_LabelType lblType) { for (unsigned int i = 0; i < WBParams::wbEntries.size(); i++) { if (label == (lblType == WBLT_GUI ? WBParams::wbEntries[i]->GUILabel : WBParams::wbEntries[i]->ppLabel)) { @@ -800,7 +800,7 @@ int WhiteBalance::findWBEntryId (Glib::ustring label, enum WB_LabelType lblType) } } - return -1; + return 0; // default to camera wb } WBEntry* WhiteBalance::findWBEntry (Glib::ustring label, enum WB_LabelType lblType) diff --git a/rtgui/whitebalance.h b/rtgui/whitebalance.h index 1d493c035..7366e55b5 100644 --- a/rtgui/whitebalance.h +++ b/rtgui/whitebalance.h @@ -86,7 +86,7 @@ protected: int _setActiveMethod (Glib::ustring &label, Gtk::TreeModel::Children &children); Gtk::TreeModel::Row getActiveMethod (); - int findWBEntryId (Glib::ustring label, enum WB_LabelType lblType = WBLT_GUI); + unsigned int findWBEntryId (const Glib::ustring &label, enum WB_LabelType lblType = WBLT_GUI); rtengine::procparams::WBEntry* findWBEntry (Glib::ustring label, enum WB_LabelType lblType = WBLT_GUI); public: diff --git a/win.cmake b/win.cmake index 0a32ac956..3b330ebe0 100644 --- a/win.cmake +++ b/win.cmake @@ -30,8 +30,8 @@ set(PROC_TARGET_NUMBER 0 CACHE STRING "Target Processor") # CMAKE_C_FLAGS and CMAKE_EXE_LINKER_FLAGS to select between 32/64bit build set(CMAKE_CXX_FLAGS "-mwin32 -m64 -mthreads -msse2" CACHE STRING "Compiler options for C++ source files") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g2" CACHE STRING "Compiler options for C++ source files and Debug target") -set(CMAKE_CXX_FLAGS_RELEASE "-mwindows -Wno-aggressive-loop-optimizations -DNDEBUG -O3" CACHE STRING "Compiler options for C++ source files and Release target") -set(CMAKE_CXX_FLAGS_MINSIZEREL "-mwindows -DNDEBUG -Os" CACHE STRING "Compiler options for C++ source files and MinSizeRel target") +set(CMAKE_CXX_FLAGS_RELEASE "-Wno-aggressive-loop-optimizations -DNDEBUG -O3" CACHE STRING "Compiler options for C++ source files and Release target") +set(CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG -Os" CACHE STRING "Compiler options for C++ source files and MinSizeRel target") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Compiler options for C++ source files and RelWithDebInfo target") # Uncomment the next line and set the right value to override the default value (special compiling flags for RTEngine) @@ -39,12 +39,12 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Compiler options for C set(CMAKE_C_FLAGS "-mwin32 -m64 -mthreads -msse2" CACHE STRING "Compiler options for C source files") set(CMAKE_C_FLAGS_DEBUG "-O0 -g2" CACHE STRING "Compiler options for C source files and Debug target") -set(CMAKE_C_FLAGS_RELEASE "-mwindows -DNDEBUG -O2" CACHE STRING "Compiler options for C source files and Release target") -set(CMAKE_C_FLAGS_MINSIZEREL "-mwindows -DNDEBUG -Os" CACHE STRING "Compiler options for C source files and MinSizeRel target") +set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2" CACHE STRING "Compiler options for C source files and Release target") +set(CMAKE_C_FLAGS_MINSIZEREL "-DNDEBUG -Os" CACHE STRING "Compiler options for C source files and MinSizeRel target") set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Compiler options for C source files and RelWithDebInfo target") set(CMAKE_EXE_LINKER_FLAGS "-m64 -mthreads -static-libgcc" CACHE STRING "Linker options") set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-O0" CACHE STRING "Linkage options for the Debug target") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-mwindows -s -O3" CACHE STRING "Linkage options for the Release target") -set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "-mwindows -s -Os" CACHE STRING "Linkage options for the MinSizeRel target") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s -O3" CACHE STRING "Linkage options for the Release target") +set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "-s -Os" CACHE STRING "Linkage options for the MinSizeRel target") set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "-s -O2" CACHE STRING "Linkage options for the RelWithDebInfo target")