diff --git a/CMakeLists.txt b/CMakeLists.txt index fa153855b..cb45c573f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,6 +92,17 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PROC_FLAGS}") # Stop compilation on typos such as std:swap (missing colon will be detected as unused label): set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=unused-label") +# Special treatment for x87 and x86-32 SSE (see GitHub issue #4324) +include(FindX87Math) +if(HAVE_X87_MATH) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffloat-store") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffloat-store") +endif() +if(HAVE_X86_SSE_MATH) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -mfpmath=sse") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -mfpmath=sse") +endif() + if(WIN32) # Add additional paths. Look in the MinGW path first, then in the Gtkmm path. # If you wish to build some dependent libraries, you have to install them in MinGW to use them: diff --git a/cmake/modules/FindX87Math.cmake b/cmake/modules/FindX87Math.cmake new file mode 100644 index 000000000..b25ba3292 --- /dev/null +++ b/cmake/modules/FindX87Math.cmake @@ -0,0 +1,60 @@ +# This file is part of RawTherapee. +# +# Copyright (C) 2018 Flössie +# +# RawTherapee is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RawTherapee is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RawTherapee. If not, see . + +include(CheckCXXSourceCompiles) + +set(CMAKE_REQUIRED_QUIET_COPY "${CMAKE_REQUIRED_QUIET}") +set(CMAKE_REQUIRED_QUIET ON) + +set(TEST_SOURCE +" +#if !defined(__i386) && !defined(_M_IX86) +#error +#endif + +#if defined(__SSE2__) +#error +#endif + +int main() +{ +} +") + +CHECK_CXX_SOURCE_COMPILES("${TEST_SOURCE}" HAVE_X87_MATH) + +set(TEST_SOURCE +" +#if !defined(__i386) && !defined(_M_IX86) +#error +#endif + +#if !defined(__SSE2__) +#error +#endif + +int main() +{ +} +") + +CHECK_CXX_SOURCE_COMPILES("${TEST_SOURCE}" HAVE_X86_SSE_MATH) + +unset(TEST_SOURCE) + +set(CMAKE_REQUIRED_QUIET "${CMAKE_REQUIRED_QUIET_COPY}") +unset(CMAKE_REQUIRED_QUIET_COPY) diff --git a/rtengine/colortemp.cc b/rtengine/colortemp.cc index 21f1641cc..75b32c83c 100644 --- a/rtengine/colortemp.cc +++ b/rtengine/colortemp.cc @@ -1270,7 +1270,7 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, } if (settings->verbose) { - double correl_temp; + double correl_temp = 0.0; XYZtoCorColorTemp(Xwb, Ywb, Zwb, correl_temp); printf("Correlated temperature (lamp)=%i\n", (int) correl_temp); //use only for lamp...otherwise It give an information!! } diff --git a/rtengine/demosaic_algos.cc b/rtengine/demosaic_algos.cc index 1bbea204c..368a8edde 100644 --- a/rtengine/demosaic_algos.cc +++ b/rtengine/demosaic_algos.cc @@ -1880,7 +1880,7 @@ void RawImageSource::lmmse_interpolate_omp(int winw, int winh, array2D &r gamtab->makeIdentity(); } - array2D (*rgb[3]); + array2D* rgb[3]; rgb[0] = &red; rgb[1] = &green; rgb[2] = &blue; @@ -2619,7 +2619,7 @@ void RawImageSource::ahd_demosaic() static const int dir[4] = { -1, 1, -TS, TS }; float ldiff[2][4], abdiff[2][4], leps, abeps; float xyz[3], xyz_cam[3][4]; - float (*cbrt); + float* cbrt; float (*rgb)[TS][TS][3]; float (*lab)[TS][TS][3]; float (*lix)[3]; @@ -3982,10 +3982,10 @@ void RawImageSource::rcd_demosaic() //float V_Stat, H_Stat, P_Stat, Q_Stat; float VH_Central_Value, VH_Neighbour_Value, PQ_Central_Value, PQ_Neighbour_Value; */ - float ( *VH_Dir ), ( *PQ_Dir ); + float *VH_Dir, *PQ_Dir; //Low pass filter - float ( *lpf ); + float *lpf; /** diff --git a/rtengine/gauss.cc b/rtengine/gauss.cc index 8e23d5609..a0775033e 100644 --- a/rtengine/gauss.cc +++ b/rtengine/gauss.cc @@ -758,7 +758,7 @@ template void gaussVerticalSsemult (T** RESTRICT src, T** RESTRICT dst, } } -template void gaussVerticalSsediv (T** RESTRICT src, T** RESTRICT dst, T** divBuffer, const int W, const int H, const float sigma) +template void gaussVerticalSsediv (T** src, T** dst, T** divBuffer, const int W, const int H, const float sigma) { double b1, b2, b3, B, M[3][3]; calculateYvVFactors(sigma, b1, b2, b3, B, M); diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index 677584bf7..144c03ddd 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -2457,7 +2457,7 @@ void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, } } - int choicelevel = atoi (params->wavelet.Lmethod.data()) - 1; + int choicelevel = params->wavelet.Lmethod - 1; choicelevel = choicelevel == -1 ? 4 : choicelevel; int choiceClevel = 0; @@ -3270,7 +3270,7 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit } // to see each level of wavelet ...level from 0 to 8 - int choicelevel = atoi (params->wavelet.Lmethod.data()) - 1; + int choicelevel = params->wavelet.Lmethod - 1; choicelevel = choicelevel == -1 ? 4 : choicelevel; } @@ -3528,7 +3528,7 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, } // to see each level of wavelet ...level from 0 to 8 - int choicelevel = atoi (params->wavelet.Lmethod.data()) - 1; + int choicelevel = params->wavelet.Lmethod - 1; choicelevel = choicelevel == -1 ? 4 : choicelevel; int choiceClevel = 0; diff --git a/rtengine/opthelper.h b/rtengine/opthelper.h index 711322f56..ce1f620e1 100644 --- a/rtengine/opthelper.h +++ b/rtengine/opthelper.h @@ -30,13 +30,8 @@ #ifdef __GNUC__ #define RESTRICT __restrict__ - #if __SIZEOF_POINTER__ == 4 && __GNUC__ >= 7 // there seems to be a bug with __builtin_expect on 32bit systems when using gcc >= 7 - #define LIKELY(x) (x) - #define UNLIKELY(x) (x) - #else - #define LIKELY(x) __builtin_expect (!!(x), 1) - #define UNLIKELY(x) __builtin_expect (!!(x), 0) - #endif + #define LIKELY(x) __builtin_expect (!!(x), 1) + #define UNLIKELY(x) __builtin_expect (!!(x), 0) #define ALIGNED64 __attribute__ ((aligned (64))) #define ALIGNED16 __attribute__ ((aligned (16))) #else diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index c6f2279c9..6bb8f3a5b 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2088,7 +2088,7 @@ enabled(false), expfinal(false), exptoning(false), expnoise(false), - Lmethod("4_"), + Lmethod(4), CLmethod("all"), Backmethod("grey"), Tilesmethod("full"), @@ -4875,7 +4875,15 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Wavelet", "Lipst", pedited, wavelet.lipst, pedited->wavelet.lipst); assignFromKeyfile(keyFile, "Wavelet", "AvoidColorShift", pedited, wavelet.avoid, pedited->wavelet.avoid); assignFromKeyfile(keyFile, "Wavelet", "TMr", pedited, wavelet.tmr, pedited->wavelet.tmr); - assignFromKeyfile(keyFile, "Wavelet", "LevMethod", pedited, wavelet.Lmethod, pedited->wavelet.Lmethod); + if (ppVersion < 331) { // wavelet.Lmethod was a string before version 331 + Glib::ustring temp; + assignFromKeyfile(keyFile, "Wavelet", "LevMethod", pedited, temp, pedited->wavelet.Lmethod); + if (!temp.empty()) { + wavelet.Lmethod = std::stoi(temp); + } + } else { + assignFromKeyfile(keyFile, "Wavelet", "LevMethod", pedited, wavelet.Lmethod, pedited->wavelet.Lmethod); + } assignFromKeyfile(keyFile, "Wavelet", "ChoiceLevMethod", pedited, wavelet.CLmethod, pedited->wavelet.CLmethod); assignFromKeyfile(keyFile, "Wavelet", "BackMethod", pedited, wavelet.Backmethod, pedited->wavelet.Backmethod); assignFromKeyfile(keyFile, "Wavelet", "TilesMethod", pedited, wavelet.Tilesmethod, pedited->wavelet.Tilesmethod); @@ -5256,7 +5264,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "ColorToning", "LabGridALow", pedited, colorToning.labgridALow, pedited->colorToning.labgridALow); assignFromKeyfile(keyFile, "ColorToning", "LabGridBLow", pedited, colorToning.labgridBLow, pedited->colorToning.labgridBLow); assignFromKeyfile(keyFile, "ColorToning", "LabGridAHigh", pedited, colorToning.labgridAHigh, pedited->colorToning.labgridAHigh); - assignFromKeyfile(keyFile, "ColorToning", "LabGridBHigh", pedited, colorToning.labgridBHigh, pedited->colorToning.labgridBHigh); + assignFromKeyfile(keyFile, "ColorToning", "LabGridBHigh", pedited, colorToning.labgridBHigh, pedited->colorToning.labgridBHigh); } if (keyFile.has_group("RAW")) { diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 5ff2e2f9d..73e7c6e7a 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1237,7 +1237,7 @@ struct WaveletParams { bool exptoning; bool expnoise; - Glib::ustring Lmethod; + int Lmethod; Glib::ustring CLmethod; Glib::ustring Backmethod; Glib::ustring Tilesmethod; diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 7f8a207cd..b5f0ad4d6 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -1348,7 +1348,7 @@ int RawImageSource::findHotDeadPixels( PixelsMap &bpMap, float thresh, bool find float varthresh = (20.0 * (thresh / 100.0) + 1.0) / 24.f; // allocate temporary buffer - float (*cfablur); + float* cfablur; cfablur = (float (*)) malloc(H * W * sizeof * cfablur); // counter for dead or hot pixels diff --git a/rtgui/ppversion.h b/rtgui/ppversion.h index a3fcef20a..e2838c2c0 100644 --- a/rtgui/ppversion.h +++ b/rtgui/ppversion.h @@ -1,11 +1,13 @@ #pragma once // This number has to be incremented whenever the PP3 file format is modified or the behaviour of a tool changes -#define PPVERSION 330 +#define PPVERSION 331 #define PPVERSION_AEXP 301 //value of PPVERSION when auto exposure algorithm was modified /* Log of version changes + 331 2018-14-02 + changed wavelet.Lmethod to int 330 2018-20-01 Added 'Auto-matched Tone Curve' button, performing histogram matching 329 2017-12-09 diff --git a/rtgui/wavelet.cc b/rtgui/wavelet.cc index b24bfa207..d788b5b8b 100644 --- a/rtgui/wavelet.cc +++ b/rtgui/wavelet.cc @@ -1096,7 +1096,7 @@ void Wavelet::read (const ProcParams* pp, const ParamsEdited* pedited) Dirmethod->set_active (3); } - int selectedLevel = atoi(pp->wavelet.Lmethod.data()) - 1; + int selectedLevel = pp->wavelet.Lmethod - 1; Lmethod->set_active (selectedLevel == -1 ? 4 : selectedLevel); ccshape->setCurve (pp->wavelet.ccwcurve); @@ -1735,9 +1735,7 @@ void Wavelet::write (ProcParams* pp, ParamsEdited* pedited) pp->wavelet.Dirmethod = "all"; } - char lMethod[3]; // one additional char to avoid buffer overrun if someone increases number of levels > 9 - sprintf(lMethod, "%d", Lmethod->get_active_row_number() + 1); - pp->wavelet.Lmethod = lMethod; + pp->wavelet.Lmethod = Lmethod->get_active_row_number() + 1; } void Wavelet::curveChanged (CurveEditor* ce)