From 04cef998a2bce468c9a633f446788ec80f9ec257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Wed, 14 Feb 2018 20:01:20 +0100 Subject: [PATCH 1/4] Fix some GCC 8 warnings (#4397) --- rtengine/colortemp.cc | 2 +- rtengine/demosaic_algos.cc | 8 ++++---- rtengine/rawimagesource.cc | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rtengine/colortemp.cc b/rtengine/colortemp.cc index ab318aa73..26975b233 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/rawimagesource.cc b/rtengine/rawimagesource.cc index 04066d49f..ec6c5620d 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -1346,7 +1346,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 From cf3ea4f451e929400fe07a2832b5388a3f715fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Wed, 14 Feb 2018 20:09:17 +0100 Subject: [PATCH 2/4] Turn `wavelet.Lmethod` into an integer (by @heckflosse, #4397) --- rtengine/ipwavelet.cc | 6 +++--- rtengine/procparams.cc | 18 +++++++++++++----- rtengine/procparams.h | 2 +- rtgui/ppversion.h | 4 +++- rtgui/wavelet.cc | 6 ++---- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index 4ffe9c9af..28b4738a0 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -2453,7 +2453,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; @@ -3266,7 +3266,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; } @@ -3524,7 +3524,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/procparams.cc b/rtengine/procparams.cc index 64b7fea15..7c33e11af 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2081,7 +2081,7 @@ WaveletParams::WaveletParams() : expfinal(false), exptoning(false), expnoise(false), - Lmethod("4_"), + Lmethod(4), CLmethod("all"), Backmethod("grey"), Tilesmethod("full"), @@ -2809,7 +2809,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->localContrast.amount, "Local Contrast", "Amount", localContrast.amount, keyFile); saveToKeyfile(!pedited || pedited->localContrast.darkness, "Local Contrast", "Darkness", localContrast.darkness, keyFile); saveToKeyfile(!pedited || pedited->localContrast.lightness, "Local Contrast", "Lightness", localContrast.lightness, keyFile); - + // Channel mixer saveToKeyfile(!pedited || pedited->chmixer.enabled, "Channel Mixer", "Enabled", chmixer.enabled, keyFile); @@ -3672,7 +3672,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) pedited->labCurve.enabled = true; } } - + assignFromKeyfile(keyFile, "Luminance Curve", "Brightness", pedited, labCurve.brightness, pedited->labCurve.brightness); assignFromKeyfile(keyFile, "Luminance Curve", "Contrast", pedited, labCurve.contrast, pedited->labCurve.contrast); @@ -4220,7 +4220,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); @@ -4595,7 +4603,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 14cf00581..1f8957888 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1098,7 +1098,7 @@ struct WaveletParams { bool exptoning; bool expnoise; - Glib::ustring Lmethod; + int Lmethod; Glib::ustring CLmethod; Glib::ustring Backmethod; Glib::ustring Tilesmethod; diff --git a/rtgui/ppversion.h b/rtgui/ppversion.h index 1eb54d68b..db36c380b 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 160abf07e..70ecc7858 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) From 28e1b83af97f04337e08098cf1318e56252503fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Thu, 15 Feb 2018 19:41:15 +0100 Subject: [PATCH 3/4] Find x87 and x86-32 SSE to adjust compile settings (fixes #4324) --- CMakeLists.txt | 11 ++++++ cmake/modules/FindX87Math.cmake | 60 +++++++++++++++++++++++++++++++++ rtengine/opthelper.h | 9 ++--- 3 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 cmake/modules/FindX87Math.cmake 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/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 From 1b048e147fa5cbf6bb11961fc319309c3a4ee484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Thu, 15 Feb 2018 19:58:08 +0100 Subject: [PATCH 4/4] Fix wrong `RESTRICT` (#4397) --- rtengine/gauss.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtengine/gauss.cc b/rtengine/gauss.cc index 78275da9f..972021336 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);