diff --git a/CMakeLists.txt b/CMakeLists.txt index a7e29e03a..d1893ca33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,228 +1,250 @@ -if (WIN32) +if(WIN32) cmake_minimum_required(VERSION 2.8.4) -else (WIN32) +else() cmake_minimum_required(VERSION 2.6) -endif (WIN32) +endif() -# must stay before the 'project' command +# Must stay before the PROJECT() command: if(${CMAKE_EXTRA_GENERATOR} MATCHES "Eclipse CDT4") set(CMAKE_CXX_COMPILER_ARG1 "-std=c++11" CACHE STRING "C++ version for eclipse" FORCE) - # users building with Eclipse should set CMAKE_ECLIPSE_VERSION through the command line to their current version of Eclipse + # Users building with Eclipse should set CMAKE_ECLIPSE_VERSION through the + # command line to their current version of Eclipse: #set(CMAKE_ECLIPSE_VERSION "4.6.0" CACHE STRING "Eclipse version" FORCE) endif() PROJECT(RawTherapee) -# the default target is 'Debug' -if (CMAKE_BUILD_TYPE STREQUAL "") - set (CMAKE_BUILD_TYPE Debug CACHE STRING "One of: None Debug Release RelWithDebInfo MinSizeRel." FORCE) -endif () +# The default target is Debug: +if(CMAKE_BUILD_TYPE STREQUAL "") + set (CMAKE_BUILD_TYPE Debug CACHE STRING "One of: None Debug Release RelWithDebInfo MinSizeRel" FORCE) +endif() -string (TOUPPER ${CMAKE_BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) +string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) -# Set required C and C++ standards and check GCC version -SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") -SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +# Set required C and C++ standards and check GCC version: +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9") message(FATAL_ERROR "Building RawTherapee requires using GCC version 4.9 or higher!") endif() -# We might want to build using the old C++ ABI, even when using a new GCC version -if (USE_OLD_CXX_ABI) +# We might want to build using the old C++ ABI, even when using a new GCC version: +if(USE_OLD_CXX_ABI) add_definitions (-D_GLIBCXX_USE_CXX11_ABI=0) endif() -if (UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") +if(UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") add_definitions (-D_DEBUG) -else () +else() add_definitions (-DNDEBUG) add_definitions (-D_DNDEBUG) -endif () +endif() message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") -# Examples: "" = ~/.config/RawTherapee, "latesttag" = ~/.config/RawTherapee4.2, "_testing" = ~/.config/RawTherapee_testing -set (CACHE_NAME_SUFFIX "" CACHE STRING "RawTherapee's cache folder suffix") +# Cache name suffix examples: "" = ~/.config/RawTherapee, "5" = ~/.config/RawTherapee-5, "_testing" = ~/.config/RawTherapee_testing +# Use "" for stable releases and "5-dev" for anything else. +set(CACHE_NAME_SUFFIX "" CACHE STRING "RawTherapee's cache folder suffix") -# By default, we don't use specific processor target, so PROC_TARGET_NUMBER is set to 0. If can specify other values to select specific -# processor targets, which list can be found in ProcessorTargets.cmake. -set (PROC_TARGET_NUMBER 0 CACHE STRING "Selected target processor from the list above (taken from ProcessorTargets.cmake)") +# By default we don't use a specific processor target, so PROC_TARGET_NUMBER is set to 0. +# Specify other values to optimize for specific processor architecture as listed in ProcessorTargets.cmake: +set(PROC_TARGET_NUMBER 0 CACHE STRING "Selected target processor from the list above (taken from ProcessorTargets.cmake)") -# The following line set special compilation flags for RTEngine, and will be added to CMAKE_CXX_FLAGS -set (RTENGINE_CXX_FLAGS "" CACHE STRING "Special compilation flags for RTEngine") +# Set special compilation flags for rtengine which get added to CMAKE_CXX_FLAGS: +set(RTENGINE_CXX_FLAGS "" CACHE STRING "Special compilation flags for RTEngine") -#loading the processor targets list -include (ProcessorTargets.cmake) -set (PROC_LABEL "undefined" CACHE STRING "Target processor label, unused if PROC_TARGET_NUMBER = 0 or 2") -set (PROC_FLAGS "" CACHE STRING "Target processor related build/link flags") -if ((NOT(PROC_TARGET_NUMBER EQUAL 0)) AND (NOT(PROC_TARGET_NUMBER EQUAL 2))) - set (PROC_LABEL ${PROC_TARGET_${PROC_TARGET_NUMBER}_LABEL}) -endif () -if (NOT(PROC_TARGET_NUMBER EQUAL 0)) - set (PROC_FLAGS ${PROC_TARGET_${PROC_TARGET_NUMBER}_FLAGS}) -endif () -if (UNIX AND PROC_LABEL STREQUAL "undefined") +# Loads the ProcessorTargets list: +include(ProcessorTargets.cmake) +set(PROC_LABEL "undefined" CACHE STRING "Target processor label, unused if PROC_TARGET_NUMBER = 0 or 2") +set(PROC_FLAGS "" CACHE STRING "Target processor related build/link flags") +if((NOT (PROC_TARGET_NUMBER EQUAL 0)) AND (NOT (PROC_TARGET_NUMBER EQUAL 2))) + set(PROC_LABEL ${PROC_TARGET_${PROC_TARGET_NUMBER}_LABEL}) +endif() +if(NOT(PROC_TARGET_NUMBER EQUAL 0)) + set(PROC_FLAGS ${PROC_TARGET_${PROC_TARGET_NUMBER}_FLAGS}) +endif() +if(UNIX AND PROC_LABEL STREQUAL "undefined") execute_process(COMMAND uname -p OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE cpu) - if ("${cpu}" STREQUAL "unknown") + if("${cpu}" STREQUAL "unknown") set(PROC_LABEL "${CMAKE_SYSTEM_PROCESSOR}") - else () - set (PROC_LABEL "${cpu}") - endif () -endif () + else() + set(PROC_LABEL "${cpu}") + endif() +endif() -# if it exists, the PROC_FORCED_LABEL value is loaded in PROC_LABEL to override the one of ProcessorTargets -if (DEFINED PROC_FORCED_LABEL) - set (PROC_LABEL ${PROC_FORCED_LABEL}) -endif (DEFINED PROC_FORCED_LABEL) +# If PROC_FORCED_LABEL exists, its value is loaded in PROC_LABEL to override the one from ProcessorTargets: +if(DEFINED PROC_FORCED_LABEL) + set(PROC_LABEL ${PROC_FORCED_LABEL}) +endif() -# adding the proc flags to the build flags +# Add the proc flags to the build flags: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PROC_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROC_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PROC_FLAGS}") -#stop compile on typos like std:swap (missing colon will be detected as unused label) +# 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") -if (WIN32) - # we additionnally look in the MinGW path first then in the Gtkmm path, - # so if you wish to build some dependant library, you have to install them in MinGW to use them +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: set(CMAKE_PREFIX_PATH $ENV{MINGW_BASEPATH} $ENV{GTKMM_BASEPATH} CACHE STRING "Additional search paths") -endif (WIN32) +endif() -if (APPLE) - if (CMAKE_CXX_COMPILER MATCHES "g\\+\\+-mp-4.[5-8]" OR - CMAKE_CXX_COMPILER_ARG1 MATCHES "g\\+\\+-mp-4.[5-8]") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /usr/lib/libstdc++.6.dylib") - message (STATUS "CMAKE_CXX_COMPILER is MacPorts GCC.\n CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") - endif () -endif (APPLE) +if(APPLE) + if(CMAKE_CXX_COMPILER MATCHES "g\\+\\+-mp-4.[5-8]" OR CMAKE_CXX_COMPILER_ARG1 MATCHES "g\\+\\+-mp-4.[5-8]") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /usr/lib/libstdc++.6.dylib") + message(STATUS "CMAKE_CXX_COMPILER is MacPorts GCC.\n CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") + endif() +endif() -option(USE_EXPERIMENTAL_LANG_VERSIONS "Build RT with -std=c++0x" OFF) -option (BUILD_SHARED "Build rawtherapee 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) -option (WITH_PROF "Build with profiling instrumentation" OFF) -option (OPTION_OMP "Build with OpenMP support" ON) -option (STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON) -option (TRACE_MYRWMUTEX "Trace RT's custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF) -option (AUTO_GDK_FLUSH "Use gdk_flush on all gdk_thread_leave other than the GUI thread; set it ON if you experience X Server warning/errors" OFF) +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) +option(WITH_PROF "Build with profiling instrumentation" OFF) +option(OPTION_OMP "Build with OpenMP support" ON) +option(STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON) +option(TRACE_MYRWMUTEX "Trace custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF) +option(AUTO_GDK_FLUSH "Use gdk_flush on all gdk_thread_leave other than the GUI thread; set it ON if you experience X Server warning/errors" OFF) +#option(TARGET32BIT "Build for 32-bit architecture when ON, otherwise 64-bit. Default is OFF" OFF) -# set install directories -if (WIN32 OR APPLE) +# Set installation directories: +if(WIN32 OR APPLE) + if(BUILD_BUNDLE) + message(STATUS "You have set BUILD_BUNDLE=ON but this is not necessary - the option is forced to ON for Windows and macOS.") + endif() set (BUILD_BUNDLE ON FORCE) -endif(WIN32 OR APPLE) +endif() -if (NOT DEFINED BUNDLE_BASE_INSTALL_DIR) - set (BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}") -endif (NOT DEFINED BUNDLE_BASE_INSTALL_DIR) +if(NOT DEFINED BUNDLE_BASE_INSTALL_DIR) + if(APPLE) + set(BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MacOS") + else() + set(BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}") + endif() +endif() -if (BUILD_BUNDLE) - set (BINDIR .) - set (CMAKE_INSTALL_PREFIX "${BUNDLE_BASE_INSTALL_DIR}") -endif (BUILD_BUNDLE) +if(BUILD_BUNDLE) + set(BINDIR .) + set(CMAKE_INSTALL_PREFIX "${BUNDLE_BASE_INSTALL_DIR}") +endif() -if (NOT DEFINED BINDIR) - set (BINDIR "${CMAKE_INSTALL_PREFIX}/bin") -endif (NOT DEFINED BINDIR) +if(NOT DEFINED BINDIR) + set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin") +endif() -if (NOT DEFINED DATADIR) - if (BUILD_BUNDLE) - set (DATADIR .) - else (BUILD_BUNDLE) - set (DATADIR "${CMAKE_INSTALL_PREFIX}/share/rawtherapee") - endif (BUILD_BUNDLE) -endif (NOT DEFINED DATADIR) +if(NOT DEFINED DATADIR) + if(BUILD_BUNDLE) + if(APPLE) + set(DATADIR "../Resources") + else() + set(DATADIR .) + endif() + else() + set(DATADIR "${CMAKE_INSTALL_PREFIX}/share/rawtherapee") + endif() +endif() -if (NOT DEFINED LIBDIR) - if (BUILD_BUNDLE) - set (LIBDIR .) - else (BUILD_BUNDLE) +if(NOT DEFINED LIBDIR) + if(BUILD_BUNDLE) + if(APPLE) + set(LIBDIR "../Frameworks") + else() + set(LIBDIR .) + endif() + else() # Respect CMAKE_INSTALL_LIBDIR if set - if (DEFINED CMAKE_INSTALL_LIBDIR) - if (IS_ABSOLUTE "${LIBDIR}") - set (LIBDIR "${CMAKE_INSTALL_LIBDIR}") - else (IS_ABSOLUTE "${LIBDIR}") - set (LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") - endif (IS_ABSOLUTE "${LIBDIR}") - else (DEFINED CMAKE_INSTALL_LIBDIR) - set (LIBDIR "${CMAKE_INSTALL_PREFIX}/lib") - endif (DEFINED CMAKE_INSTALL_LIBDIR) - endif (BUILD_BUNDLE) -endif (NOT DEFINED LIBDIR) + if(DEFINED CMAKE_INSTALL_LIBDIR) + if(IS_ABSOLUTE "${LIBDIR}") + set(LIBDIR "${CMAKE_INSTALL_LIBDIR}") + else() + set(LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") + endif() + else() + set(LIBDIR "${CMAKE_INSTALL_PREFIX}/lib") + endif() + endif() +endif() -if (NOT DEFINED DOCDIR) - if (BUILD_BUNDLE) - set (DOCDIR ./doc) - else (BUILD_BUNDLE) - set (DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") - endif (BUILD_BUNDLE) -endif (NOT DEFINED DOCDIR) +if(NOT DEFINED DOCDIR) + if(BUILD_BUNDLE) + set(DOCDIR "${DATADIR}/share/doc") + else() + set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") + endif() +endif() -if (NOT DEFINED CREDITSDIR) - if (BUILD_BUNDLE) - set (CREDITSDIR .) - else (BUILD_BUNDLE) - set (CREDITSDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") - endif (BUILD_BUNDLE) -endif (NOT DEFINED CREDITSDIR) +if(NOT DEFINED CREDITSDIR) + if(BUILD_BUNDLE) + set(CREDITSDIR "${DATADIR}") + else() + set(CREDITSDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") + endif() +endif() -if (NOT DEFINED LICENCEDIR) - if (BUILD_BUNDLE) - set (LICENCEDIR .) - else (BUILD_BUNDLE) - set (LICENCEDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") - endif (BUILD_BUNDLE) -endif (NOT DEFINED LICENCEDIR) +if(NOT DEFINED LICENCEDIR) + if(BUILD_BUNDLE) + set(LICENCEDIR "${DATADIR}") + else() + set(LICENCEDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") + endif() +endif() -if (NOT DEFINED DESKTOPDIR) - if (UNIX) - set (DESKTOPDIR "${CMAKE_INSTALL_PREFIX}/share/applications") - endif (UNIX) -endif (NOT DEFINED DESKTOPDIR) +if(NOT DEFINED DESKTOPDIR) + if(UNIX) + set(DESKTOPDIR "${CMAKE_INSTALL_PREFIX}/share/applications") # Absolute + #set(DESKTOPDIR "${DATADIR}/share/applications") # Relative + endif() +endif() -if (NOT DEFINED ICONSDIR) - if (UNIX) - set (ICONSDIR "${CMAKE_INSTALL_PREFIX}/share/icons") - endif (UNIX) -endif (NOT DEFINED ICONSDIR) +if(NOT DEFINED ICONSDIR) + if(UNIX) + set(ICONSDIR "${CMAKE_INSTALL_PREFIX}/share/icons") + endif() +endif() -if (NOT DEFINED APPDATADIR) - if (UNIX) - set (APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/appdata") - endif (UNIX) -endif (NOT DEFINED APPDATADIR) +if(NOT DEFINED APPDATADIR) + if(UNIX) + set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/appdata") + endif() +endif() -# non-bundle builds has to use absolute paths -if (NOT BUILD_BUNDLE AND NOT (IS_ABSOLUTE "${BINDIR}" AND IS_ABSOLUTE "${DATADIR}" AND IS_ABSOLUTE "${LIBDIR}" AND IS_ABSOLUTE "${DOCDIR}" AND IS_ABSOLUTE "${CREDITSDIR}" AND IS_ABSOLUTE "${LICENCEDIR}")) - message (FATAL_ERROR "The paths has to be absolute or use -DBUILD_BUNDLE=ON") -endif () +# Enforce absolute paths for non-bundle builds: +if(NOT BUILD_BUNDLE) + foreach(path BINDIR DATADIR LIBDIR DOCDIR CREDITSDIR LICENCEDIR) + if(NOT (IS_ABSOLUTE "${${path}}")) + message (FATAL_ERROR "The ${path} path has to be absolute when using -DBUILD_BUNDLE=OFF") + endif() + endforeach() +endif() -# MyMutex -if (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") - add_definitions (-DSTRICT_MUTEX=1) -else (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") - add_definitions (-DSTRICT_MUTEX=0) -endif (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") +# MyMutex: +if(STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") + add_definitions(-DSTRICT_MUTEX=1) +else() + add_definitions(-DSTRICT_MUTEX=0) +endif() -# MyRWMutex -if (TRACE_MYRWMUTEX) - add_definitions (-DTRACE_MYRWMUTEX=1) -else (TRACE_MYRWMUTEX) - add_definitions (-DTRACE_MYRWMUTEX=0) -endif (TRACE_MYRWMUTEX) +# MyRWMutex: +if(TRACE_MYRWMUTEX) + add_definitions(-DTRACE_MYRWMUTEX=1) +else() + add_definitions(-DTRACE_MYRWMUTEX=0) +endif() -if (AUTO_GDK_FLUSH) - add_definitions (-DAUTO_GDK_FLUSH=1) -else (AUTO_GDK_FLUSH) - add_definitions (-DAUTO_GDK_FLUSH=0) -endif (AUTO_GDK_FLUSH) +if(AUTO_GDK_FLUSH) + add_definitions(-DAUTO_GDK_FLUSH=1) +else() + add_definitions(-DAUTO_GDK_FLUSH=0) +endif() -# check for libraries +# Check for libraries: find_package(PkgConfig) pkg_check_modules (GTK REQUIRED gtk+-3.0>=3.16) pkg_check_modules (GLIB2 REQUIRED glib-2.0>=2.44) @@ -234,121 +256,119 @@ pkg_check_modules (GIOMM REQUIRED giomm-2.4>=2.44) pkg_check_modules (GTHREAD REQUIRED gthread-2.0>=2.44) pkg_check_modules (GOBJECT REQUIRED gobject-2.0>=2.44) pkg_check_modules (SIGC REQUIRED sigc++-2.0>=2.3.1) -# NOTE: The new mechanism has been tested with BUILD_SHARED = OFF -if (WIN32) - add_definitions (-DWIN32) - add_definitions (-D_WIN32) - if (MINGW) - add_definitions (-D__MINGW32__) - endif (MINGW) - if (CMAKE_SIZEOF_VOID_P EQUAL 4) - add_definitions (-DWINVER=0x0501) - endif (CMAKE_SIZEOF_VOID_P EQUAL 4) - set (EXTRA_LIB "-lws2_32 -lshlwapi") -endif (WIN32) -# you may need lcms v1.xx for older version : pkg_check_modules (LCMS REQUIRED lcms<=1.99) -pkg_check_modules (LCMS REQUIRED lcms2>=2.6) -pkg_check_modules (EXPAT REQUIRED expat>=2.1) -pkg_check_modules (FFTW3F REQUIRED fftw3f) -pkg_check_modules (IPTCDATA REQUIRED libiptcdata) -find_package (JPEG REQUIRED) -find_package (PNG REQUIRED) -find_package (TIFF REQUIRED) -find_package (ZLIB REQUIRED) -# link witz bzip -if (WITH_BZIP) +if(WIN32) + add_definitions(-DWIN32) + add_definitions(-D_WIN32) + if(MINGW) + add_definitions(-D__MINGW32__) + endif() + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + add_definitions(-DWINVER=0x0501) + endif() + set(EXTRA_LIB "-lws2_32 -lshlwapi") +endif() + +pkg_check_modules(LCMS REQUIRED lcms2>=2.6) +pkg_check_modules(EXPAT REQUIRED expat>=2.1) +pkg_check_modules(FFTW3F REQUIRED fftw3f) +pkg_check_modules(IPTCDATA REQUIRED libiptcdata) +find_package(JPEG REQUIRED) +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 (BZIP2_FOUND) -endif (WITH_BZIP) + 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) -endif (UNIX AND (NOT APPLE)) +# Check for libcanberra-gtk3 (sound events on Linux): +if(UNIX AND(NOT APPLE)) + pkg_check_modules(CANBERRA-GTK REQUIRED libcanberra-gtk3) +endif() -if (WITH_MYFILE_MMAP) - add_definitions (-DMYFILE_MMAP) -endif (WITH_MYFILE_MMAP) +if(WITH_MYFILE_MMAP) + add_definitions(-DMYFILE_MMAP) +endif() -if (WITH_LTO) - SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") - SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") - SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") -endif (WITH_LTO) +if(WITH_LTO) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") +endif() -if (WITH_SAN) - SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${WITH_SAN}") - SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${WITH_SAN}") - SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${WITH_SAN}") -endif (WITH_SAN) +if(WITH_SAN) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${WITH_SAN}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${WITH_SAN}") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${WITH_SAN}") +endif() -if (WITH_PROF) - SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") - SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") - SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") -endif (WITH_PROF) +if(WITH_PROF) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") +endif() -if (OPTION_OMP) +if(OPTION_OMP) find_package(OpenMP) - if (OPENMP_FOUND) + if(OPENMP_FOUND) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -Werror=unknown-pragmas -Wall -Wno-unused-result -Wno-deprecated-declarations") - endif (OPENMP_FOUND) -endif (OPTION_OMP) + endif() +endif() -# find out whether we are building out of source +# Find out whether we are building out of source: get_filename_component(ABS_SOURCE_DIR "${PROJECT_SOURCE_DIR}" ABSOLUTE) get_filename_component(ABS_BINARY_DIR "${CMAKE_BINARY_DIR}" ABSOLUTE) -set (OUT_OF_SOURCE_BUILD TRUE) -if (ABS_SOURCE_DIR STREQUAL ABS_BINARY_DIR) - set (OUT_OF_SOURCE_BUILD FALSE) - message (WARNING "You are performing an in-source build. This is discouraged. For an explanation and the advantages of out-of-source builds, please refer to http://www.cmake.org/Wiki/CMake_FAQ#What_is_an_.22out-of-source.22_build.3F") -endif () +set(OUT_OF_SOURCE_BUILD TRUE) +if(ABS_SOURCE_DIR STREQUAL ABS_BINARY_DIR) + set(OUT_OF_SOURCE_BUILD FALSE) + message(WARNING "You are performing an in-source build. This is discouraged. For an explanation and the advantages of out-of-source builds, please refer to http://www.cmake.org/Wiki/CMake_FAQ#What_is_an_.22out-of-source.22_build.3F") +endif() -# XXX remove files triggering the below check to prevent every developer from -# needing manual manual work. We will remove this after some time to have a -# clean build system without file modifications in the source tree again. +# Remove files which could require manual work. +# We will remove this after some time to have a clean build system without file modifications in the source tree again. (?) set(OOSB_FILES "${PROJECT_SOURCE_DIR}/rtdata/rawtherapee.desktop" "${PROJECT_SOURCE_DIR}/rtgui/version.h" "${PROJECT_SOURCE_DIR}/rtgui/config.h" "${PROJECT_SOURCE_DIR}/AboutThisBuild.txt") -if (OUT_OF_SOURCE_BUILD) +if(OUT_OF_SOURCE_BUILD) foreach(f ${OOSB_FILES}) - file (REMOVE "${f}") - endforeach(f) -endif () + file(REMOVE "${f}") + endforeach() +endif() -# check for generated files in the source tree which should not be there when -# doing out of source builds. Without checking for this it might happen that old -# versions are used for the compilation -if (OUT_OF_SOURCE_BUILD) +# Check for generated files in the source tree which should not be there when doing an out-of-source build. +# Without checking for this it might happen that old versions are used for the compilation: +if(OUT_OF_SOURCE_BUILD) foreach(f ${OOSB_FILES}) - if (EXISTS "${f}") - message (SEND_ERROR "Generated \"${f}\" found inside the source tree. Please remove it as it is a relic of the old build system and prevents valid compilation now.") - endif () - endforeach(f) -endif () + if(EXISTS "${f}") + message(SEND_ERROR "Generated \"${f}\" found inside the source tree. Please remove it as it is a relic of the old build system and prevents valid compilation now.") + endif() + endforeach() +endif() -## BEGIN: Create AboutThisBuild.txt and other version-dependent files. -# set the bit number information of the platform -if (CMAKE_SIZEOF_VOID_P EQUAL 4) +### Start generating AboutThisBuild.txt +# Set the platform bit-depth: +if(CMAKE_SIZEOF_VOID_P EQUAL 4) set(PROC_BIT_DEPTH 32 bits) -elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) +elseif() set(PROC_BIT_DEPTH 64 bits) -endif (CMAKE_SIZEOF_VOID_P EQUAL 4) +endif() -# Get comiler name and version -# only cmake > 2.8.7 knows CMAKE_*_COMPILER_VERSION -if (CMAKE_VERSION VERSION_GREATER 2.8.7) +# Get compiler name and version. +# Only CMake > 2.8.7 knows CMAKE_*_COMPILER_VERSION +if(CMAKE_VERSION VERSION_GREATER 2.8.7) get_filename_component(COMPILER_INFO ${CMAKE_C_COMPILER} NAME_WE) set(COMPILER_INFO "${COMPILER_INFO} ${CMAKE_C_COMPILER_VERSION}") -else () +else() execute_process(COMMAND gcc -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) set(COMPILER_INFO "gcc ${GCC_VERSION}") -endif () +endif() -# Get c++ and linker flags for rtengine (the gui's c++ flags may have less flags) +# Get C++ and linker flags for rtengine (the GUI's C++ flags may have fewer flags): set(CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPER_CMAKE_BUILD_TYPE}} ${RTENGINE_CXX_FLAGS}") set(LFLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${UPPER_CMAKE_BUILD_TYPE}}") @@ -362,24 +382,24 @@ set(ABOUT_COMMAND_WITH_ARGS ${CMAKE_COMMAND} -DOPTION_OMP:STRING=${OPTION_OMP} -DWITH_MYFILE_MMAP:STRING=${WITH_MYFILE_MMAP}) -if (WIN32) +if(WIN32) list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Windows -DCXX_FLAGS:STRING="${CXX_FLAGS}" -DLFLAGS:STRING="${LFLAGS}" -DCOMPILER_INFO:STRING="${COMPILER_INFO}" -DCMAKE_INSTALL_PREFIX:STRING="${CMAKE_INSTALL_PREFIX}" -DBIT_DEPTH:STRING="${CMAKE_SIZEOF_VOID_P}") -elseif (APPLE) +elseif(APPLE) list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Apple -DCXX_FLAGS:STRING=${CXX_FLAGS} -DLFLAGS:STRING=${LFLAGS} -DCOMPILER_INFO:STRING=${COMPILER_INFO}) -else (WIN32) +else() list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Linux -DCXX_FLAGS:STRING=${CXX_FLAGS} -DLFLAGS:STRING=${LFLAGS} -DCOMPILER_INFO:STRING=${COMPILER_INFO}) -endif (WIN32) +endif() list(APPEND ABOUT_COMMAND_WITH_ARGS -P "${PROJECT_SOURCE_DIR}/UpdateInfo.cmake") @@ -387,21 +407,29 @@ add_custom_target(UpdateInfo ALL COMMAND ${ABOUT_COMMAND_WITH_ARGS} COMMENT "Creating AboutThisBuild.txt and other version-dependent files") -## END: Generating AboutThisBuild.txt +### End generating AboutThisBuild.txt -install (FILES AUTHORS.txt DESTINATION "${CREDITSDIR}") -install (FILES LICENSE.txt DESTINATION "${LICENCEDIR}") -install (FILES "${CMAKE_BINARY_DIR}/AboutThisBuild.txt" DESTINATION "${CREDITSDIR}") -install (FILES RELEASE_NOTES.txt DESTINATION "${CREDITSDIR}" OPTIONAL) -if (WIN32) - install (DIRECTORY "licenses" DESTINATION "${LICENCEDIR}") -endif (WIN32) -if (UNIX) - install (FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1") - install (FILES rawtherapee.appdata.xml DESTINATION "${APPDATADIR}") -endif (UNIX) +install(FILES AUTHORS.txt DESTINATION "${CREDITSDIR}") +install(FILES LICENSE.txt DESTINATION "${LICENCEDIR}") +install(FILES "${CMAKE_BINARY_DIR}/AboutThisBuild.txt" DESTINATION "${CREDITSDIR}") +install(FILES RELEASE_NOTES.txt DESTINATION "${CREDITSDIR}" OPTIONAL) + +# The standard location for man pages in Linux is /usr/share/man +# Use "manpath" to see the search paths for man pages on your system. +if(UNIX OR WIN32) + install(FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1") +endif() + +if(WIN32) + install(DIRECTORY "licenses" DESTINATION "${LICENCEDIR}") +endif() + +if(UNIX) + install(FILES rawtherapee.appdata.xml DESTINATION "${APPDATADIR}") +endif() + +add_subdirectory(rtexif) +add_subdirectory(rtengine) +add_subdirectory(rtgui) +add_subdirectory(rtdata) -add_subdirectory (rtexif) -add_subdirectory (rtengine) -add_subdirectory (rtgui) -add_subdirectory (rtdata) diff --git a/rtdata/CMakeLists.txt b/rtdata/CMakeLists.txt index 5967bd70a..0bb356172 100644 --- a/rtdata/CMakeLists.txt +++ b/rtdata/CMakeLists.txt @@ -48,10 +48,6 @@ install (DIRECTORY ${IMAGESDIR} DESTINATION "${DATADIR}" FILES_MATCHING PATTERN install (DIRECTORY ${IMAGESDIR} DESTINATION "${DATADIR}" FILES_MATCHING PATTERN "*.png") install (FILES ${OPTIONSFILE} DESTINATION "${DATADIR}" PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ RENAME options) -if (WIN32) - install (FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1") -endif (WIN32) - if (APPLE) # CMake escapes first item quote character. Do not remove 'DUMMY_VARIABLE='. set (MACOSX_BUNDLE_COMMAND DUMMY_VARIABLE= diff --git a/rtengine/CA_correct_RT.cc b/rtengine/CA_correct_RT.cc index 8471a1393..e1493ae40 100644 --- a/rtengine/CA_correct_RT.cc +++ b/rtengine/CA_correct_RT.cc @@ -45,15 +45,14 @@ bool LinEqSolve(int nDim, double* pfMatr, double* pfVect, double* pfSolution) // //============================================================================== - double fMaxElem; double fAcc; - int i, j, k, m; + int i, j, k; for(k = 0; k < (nDim - 1); k++) { // base row of matrix // search of line with max element - fMaxElem = fabs( pfMatr[k * nDim + k] ); - m = k; + double fMaxElem = fabs( pfMatr[k * nDim + k] ); + int m = k; for (i = k + 1; i < nDim; i++) { if(fMaxElem < fabs(pfMatr[i * nDim + k]) ) { diff --git a/rtengine/EdgePreservingDecomposition.cc b/rtengine/EdgePreservingDecomposition.cc index 43a68f024..8c1ca56a7 100644 --- a/rtengine/EdgePreservingDecomposition.cc +++ b/rtengine/EdgePreservingDecomposition.cc @@ -395,6 +395,9 @@ SSEFUNCTION void MultiDiagonalSymmetricMatrix::VectorProduct(float* RESTRICT Pro } } } +#ifdef _OPENMP + static_cast(chunkSize); // to silence cppcheck warning +#endif } bool MultiDiagonalSymmetricMatrix::CreateIncompleteCholeskyFactorization(int MaxFillAbove) diff --git a/rtengine/PF_correct_RT.cc b/rtengine/PF_correct_RT.cc index 6808fd4eb..6e1fe75d6 100644 --- a/rtengine/PF_correct_RT.cc +++ b/rtengine/PF_correct_RT.cc @@ -663,12 +663,10 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d const int width = src->W, height = src->H; const float piid = 3.14159265f / 180.f; - float shfabs, shmed; - int i1, j1, tot; + int i1, j1; const float eps = 1.0f; const float eps2 = 0.01f; - float shsum, dirsh, norm, sum; float** sraa; sraa = new float*[height]; @@ -848,13 +846,13 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d __m128 onev = F2V(1.0f); #endif // __SSE2__ #ifdef _OPENMP - #pragma omp for private(shfabs, shmed,i1,j1) + #pragma omp for private(i1,j1) #endif for (int i = 0; i < height; i++) { for (j = 0; j < 2; j++) { - shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = 0; j1 <= j + 2; j1++ ) { @@ -879,8 +877,8 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d } for (; j < width - 2; j++) { - shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 <= j + 2; j1++ ) { @@ -893,8 +891,8 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d #else for (; j < width - 2; j++) { - shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 <= j + 2; j1++ ) { @@ -907,8 +905,8 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d #endif for (; j < width; j++) { - shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 < width; j1++ ) { @@ -927,7 +925,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d { int j; #ifdef _OPENMP - #pragma omp for private(shsum,norm,dirsh,sum,i1,j1) schedule(dynamic,16) + #pragma omp for private(i1,j1) schedule(dynamic,16) #endif for (int i = 0; i < height; i++) { @@ -936,10 +934,10 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d continue; } - norm = 0.0f; - shsum = 0.0f; - sum = 0.0f; - tot = 0; + float norm = 0.0f; + float shsum = 0.0f; + float sum = 0.0f; + int tot = 0; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = 0; j1 <= j + 2; j1++ ) { @@ -953,7 +951,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d sum += src->sh_p[i1][j1]; tot++; - dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps); + float dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps); shsum += dirsh * src->sh_p[i1][j1]; norm += dirsh; } @@ -972,10 +970,10 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d continue; } - norm = 0.0f; - shsum = 0.0f; - sum = 0.0f; - tot = 0; + float norm = 0.0f; + float shsum = 0.0f; + float sum = 0.0f; + int tot = 0; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 <= j + 2; j1++ ) { @@ -989,7 +987,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d sum += src->sh_p[i1][j1]; tot++; - dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps); + float dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps); shsum += dirsh * src->sh_p[i1][j1]; norm += dirsh; } @@ -1008,10 +1006,10 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d continue; } - norm = 0.0f; - shsum = 0.0f; - sum = 0.0f; - tot = 0; + float norm = 0.0f; + float shsum = 0.0f; + float sum = 0.0f; + int tot = 0; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 < width; j1++ ) { @@ -1025,7 +1023,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d sum += src->sh_p[i1][j1]; tot++; - dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps); + float dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps); shsum += dirsh * src->sh_p[i1][j1]; norm += dirsh; } @@ -1272,13 +1270,10 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d t1.set(); const int width = src->W, height = src->H; -// const float piid=3.14159265f/180.f; - float shfabs, shmed; - int i1, j1, tot; + int i1, j1; const float eps = 1.0f; const float eps2 = 0.01f; - float shsum, dirsh, norm, sum; float** sraa; sraa = new float*[height]; @@ -1455,13 +1450,13 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d __m128 onev = F2V(1.0f); #endif // __SSE2__ #ifdef _OPENMP - #pragma omp for private(shfabs, shmed,i1,j1) + #pragma omp for private(i1,j1) #endif for (int i = 0; i < height; i++) { for (j = 0; j < 2; j++) { - shfabs = fabs(src->L[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->L[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = 0; j1 <= j + 2; j1++ ) { @@ -1486,8 +1481,8 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d } for (; j < width - 2; j++) { - shfabs = fabs(src->L[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->L[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 <= j + 2; j1++ ) { @@ -1500,8 +1495,8 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d #else for (; j < width - 2; j++) { - shfabs = fabs(src->L[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->L[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 <= j + 2; j1++ ) { @@ -1514,8 +1509,8 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d #endif for (; j < width; j++) { - shfabs = fabs(src->L[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->L[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 < width; j1++ ) { @@ -1534,7 +1529,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d { int j; #ifdef _OPENMP - #pragma omp for private(shsum,norm,dirsh,sum,i1,j1) schedule(dynamic,16) + #pragma omp for private(i1,j1) schedule(dynamic,16) #endif for (int i = 0; i < height; i++) { @@ -1543,10 +1538,10 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d continue; } - norm = 0.0f; - shsum = 0.0f; - sum = 0.0f; - tot = 0; + float norm = 0.0f; + float shsum = 0.0f; + float sum = 0.0f; + int tot = 0; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = 0; j1 <= j + 2; j1++ ) { @@ -1560,7 +1555,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d sum += src->L[i1][j1]; tot++; - dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps); + float dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps); shsum += dirsh * src->L[i1][j1]; norm += dirsh; } @@ -1579,10 +1574,10 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d continue; } - norm = 0.0f; - shsum = 0.0f; - sum = 0.0f; - tot = 0; + float norm = 0.0f; + float shsum = 0.0f; + float sum = 0.0f; + int tot = 0; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 <= j + 2; j1++ ) { @@ -1596,7 +1591,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d sum += src->L[i1][j1]; tot++; - dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps); + float dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps); shsum += dirsh * src->L[i1][j1]; norm += dirsh; } @@ -1615,10 +1610,10 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d continue; } - norm = 0.0f; - shsum = 0.0f; - sum = 0.0f; - tot = 0; + float norm = 0.0f; + float shsum = 0.0f; + float sum = 0.0f; + int tot = 0; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 < width; j1++ ) { @@ -1632,7 +1627,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d sum += src->L[i1][j1]; tot++; - dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps); + float dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps); shsum += dirsh * src->L[i1][j1]; norm += dirsh; } diff --git a/rtengine/cfa_linedn_RT.cc b/rtengine/cfa_linedn_RT.cc index 21fcfb1e5..b5578898b 100644 --- a/rtengine/cfa_linedn_RT.cc +++ b/rtengine/cfa_linedn_RT.cc @@ -46,7 +46,7 @@ void RawImageSource::CLASS cfa_linedn(float noise) const float clip_pt = 0.8 * initialGain * 65535.0; - float eps = 1e-5; //tolerance to avoid dividing by zero + const float eps = 1e-5; //tolerance to avoid dividing by zero const float gauss[5] = {0.20416368871516755, 0.18017382291138087, 0.1238315368057753, 0.0662822452863612, 0.02763055063889883}; const float rolloff[8] = {0, 0.135335, 0.249352, 0.411112, 0.606531, 0.800737, 0.945959, 1}; //gaussian with sigma=3 diff --git a/rtengine/color.cc b/rtengine/color.cc index acb50eae5..f045a84d9 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -1817,7 +1817,7 @@ void Color::Lab2Yuv(float L, float a, float b, float &Y, float &u, float &v) v = 9.0 * Y / (X + 15 * Y + 3 * Z) - v0; } -void Color::Yuv2Lab(float Yin, float u, float v, float &L, float &a, float &b, double wp[3][3]) +void Color::Yuv2Lab(float Yin, float u, float v, float &L, float &a, float &b, const double wp[3][3]) { float u1 = u + u0; float v1 = v + v0; diff --git a/rtengine/color.h b/rtengine/color.h index b3fa9cc13..df2b933f1 100644 --- a/rtengine/color.h +++ b/rtengine/color.h @@ -92,10 +92,10 @@ private: // Separated from init() to keep the code clear static void initMunsell (); - static double hue2rgb(double p, double q, double t); - static float hue2rgbfloat(float p, float q, float t); + static double hue2rgb (double p, double q, double t); + static float hue2rgbfloat (float p, float q, float t); #ifdef __SSE2__ - static vfloat hue2rgb(vfloat p, vfloat q, vfloat t); + static vfloat hue2rgb (vfloat p, vfloat q, vfloat t); #endif public: @@ -167,13 +167,13 @@ public: * @return luminance value */ // xyz_sRGBD65 : conversion matrix from XYZ to sRGB for D65 illuminant: we use diagonal values - static float rgbLuminance(float r, float g, float b) + static float rgbLuminance (float r, float g, float b) { // WArning: The sum of xyz_sRGBd65[1][] is > 1.0 (i.e. 1.0000001), so we use our own adapted values) // 0.2126729, 0.7151521, 0.0721750 return r * 0.2126729f + g * 0.7151521f + b * 0.0721750f; } - static double rgbLuminance(double r, double g, double b) + static double rgbLuminance (double r, double g, double b) { return r * 0.2126729 + g * 0.7151521 + b * 0.0721750; } @@ -248,10 +248,10 @@ public: */ static void rgb2hsv (float r, float g, float b, float &h, float &s, float &v); - static inline float rgb2s(float r, float g, float b) // fast version if only saturation is needed + static inline float rgb2s (float r, float g, float b) // fast version if only saturation is needed { - float var_Min = min(r, g, b); - float var_Max = max(r, g, b); + float var_Min = min (r, g, b); + float var_Max = max (r, g, b); float del_Max = var_Max - var_Min; if (del_Max < 0.00001f) { @@ -261,19 +261,19 @@ public: } } - static inline bool rgb2hsvdcp(float r, float g, float b, float &h, float &s, float &v) + static inline bool rgb2hsvdcp (float r, float g, float b, float &h, float &s, float &v) { - float var_Min = min(r, g, b); + float var_Min = min (r, g, b); - if(var_Min < 0.f) { + if (var_Min < 0.f) { return false; } else { - float var_Max = max(r, g, b); + float var_Max = max (r, g, b); float del_Max = var_Max - var_Min; v = var_Max / 65535.f; - if (fabsf(del_Max) < 0.00001f) { + if (fabsf (del_Max) < 0.00001f) { h = 0.f; s = 0.f; } else { @@ -458,11 +458,11 @@ public: * @param y Y coordinate [0 ; 65535] ; can be negative! (return value) * @param z Z coordinate [0 ; 65535] ; can be negative! (return value) */ - static void Lab2XYZ(float L, float a, float b, float &x, float &y, float &z); - static void L2XYZ(float L, float &x, float &y, float &z); + static void Lab2XYZ (float L, float a, float b, float &x, float &y, float &z); + static void L2XYZ (float L, float &x, float &y, float &z); #ifdef __SSE2__ - static void Lab2XYZ(vfloat L, vfloat a, vfloat b, vfloat &x, vfloat &y, vfloat &z); + static void Lab2XYZ (vfloat L, vfloat a, vfloat b, vfloat &x, vfloat &y, vfloat &z); #endif // __SSE2__ /** @@ -474,7 +474,7 @@ public: * @param a channel [-42000 ; +42000] ; can be more than 42000 (return value) * @param b channel [-42000 ; +42000] ; can be more than 42000 (return value) */ - static void XYZ2Lab(float x, float y, float z, float &L, float &a, float &b); + static void XYZ2Lab (float x, float y, float z, float &L, float &a, float &b); /** @@ -486,7 +486,7 @@ public: * @param u red chrominance channel [0 ; 65535] (return value) * @param v blue chrominance channel [0 ; 65535] (return value) */ - static void Lab2Yuv(float L, float a, float b, float &Y, float &u, float &v); + static void Lab2Yuv (float L, float a, float b, float &Y, float &u, float &v); /** @@ -498,7 +498,7 @@ public: * @param a channel [-42000 ; +42000] ; can be more than 42000 (return value) * @param b channel [-42000 ; +42000] ; can be more than 42000 (return value) */ - static void Yuv2Lab(float Y, float u, float v, float &L, float &a, float &b, double wp[3][3]); + static void Yuv2Lab (float Y, float u, float v, float &L, float &a, float &b, const double wp[3][3]); /** @@ -508,7 +508,7 @@ public: * @param c 'c' channel return value, in [0 ; 42000] ; can be more than 42000 (return value) * @param h 'h' channel return value, in [-PI ; +PI] (return value) */ - static void Lab2Lch(float a, float b, float &c, float &h); + static void Lab2Lch (float a, float b, float &c, float &h); /** @@ -518,7 +518,7 @@ public: * @param a 'a' channel [-42000 ; +42000] ; can be more than 42000 (return value) * @param b 'b' channel [-42000 ; +42000] ; can be more than 42000 (return value) */ - static void Lch2Lab(float c, float h, float &a, float &b); + static void Lch2Lab (float c, float h, float &a, float &b); /** @@ -528,7 +528,7 @@ public: * @param c 'c' channel [unknown range!] (return value) * @param h 'h' channel [-PI ; +PI] (return value) */ - static void Luv2Lch(float u, float v, float &c, float &h); + static void Luv2Lch (float u, float v, float &c, float &h); /** @@ -538,7 +538,7 @@ public: * @param u 'u' channel [unknown range!] (return value) * @param v 'v' channel [unknown range!] (return value) */ - static void Lch2Luv(float c, float h, float &u, float &v); + static void Lch2Luv (float c, float h, float &u, float &v); /** @@ -574,7 +574,7 @@ public: * fy=(L+16)/116 L=luminance [0 ; 100] * fz=fy-b/200 b=chroma blue yellow [-128 ; +128] */ - static inline double f2xyz(double f) + static inline double f2xyz (double f) { const double epsilonExpInv3 = 6.0 / 29.0; const double kappaInv = 27.0 / 24389.0; // inverse of kappa @@ -582,7 +582,7 @@ public: return (f > epsilonExpInv3) ? f * f * f : (116. * f - 16.) * kappaInv; } - static inline float f2xyz(float f) + static inline float f2xyz (float f) { const float epsilonExpInv3 = 0.20689655f; // 6.0f/29.0f; const float kappaInv = 0.0011070565f; // 27.0f/24389.0f; // inverse of kappa @@ -590,13 +590,13 @@ public: return (f > epsilonExpInv3) ? f * f * f : (116.f * f - 16.f) * kappaInv; } #ifdef __SSE2__ - static inline vfloat f2xyz(vfloat f) + static inline vfloat f2xyz (vfloat f) { - const vfloat epsilonExpInv3 = F2V(0.20689655f); // 6.0f/29.0f; - const vfloat kappaInv = F2V(0.0011070565f); // 27.0f/24389.0f; // inverse of kappa + const vfloat epsilonExpInv3 = F2V (0.20689655f); // 6.0f/29.0f; + const vfloat kappaInv = F2V (0.0011070565f); // 27.0f/24389.0f; // inverse of kappa vfloat res1 = f * f * f; - vfloat res2 = (F2V(116.f) * f - F2V(16.f)) * kappaInv; - return vself(vmaskf_gt(f, epsilonExpInv3), res1, res2); + vfloat res2 = (F2V (116.f) * f - F2V (16.f)) * kappaInv; + return vself (vmaskf_gt (f, epsilonExpInv3), res1, res2); } #endif @@ -812,30 +812,30 @@ public: { float d = h2 - h1; float f; - f = T(balance); + f = T (balance); double h; if (h1 > h2) { - std::swap(h1, h2); + std::swap (h1, h2); d = -d; f = 1.f - f; } - if (d < T(-rtengine::RT_PI) || d < T(0) || d > T(rtengine::RT_PI)) { //there was an inversion here !! d > T(rtengine::RT_PI) - h1 += T(2 * rtengine::RT_PI); + if (d < T (-rtengine::RT_PI) || d < T (0) || d > T (rtengine::RT_PI)) { //there was an inversion here !! d > T(rtengine::RT_PI) + h1 += T (2 * rtengine::RT_PI); h = h1 + f * (h2 - h1); - h = std::fmod(h, 2 * rtengine::RT_PI); + h = std::fmod (h, 2 * rtengine::RT_PI); } else { h = h1 + f * d; } // not strictly necessary..but in case of - if(h < T(-rtengine::RT_PI)) { - h = T(2 * rtengine::RT_PI) - h; + if (h < T (-rtengine::RT_PI)) { + h = T (2 * rtengine::RT_PI) - h; } - if(h > T(rtengine::RT_PI)) { - h = h - T(2 * rtengine::RT_PI); + if (h > T (rtengine::RT_PI)) { + h = h - T (2 * rtengine::RT_PI); } return h; @@ -855,30 +855,30 @@ public: { float d = h2 - h1; float f; - f = T(balance); + f = T (balance); double h; if (h1 > h2) { - std::swap(h1, h2); + std::swap (h1, h2); d = -d; f = 1.f - f; } - if (d < T(0) || d < T(0.5) || d > T(1.)) { //there was an inversion here !! d > T(rtengine::RT_PI) - h1 += T(1.); + if (d < T (0) || d < T (0.5) || d > T (1.)) { //there was an inversion here !! d > T(rtengine::RT_PI) + h1 += T (1.); h = h1 + f * (h2 - h1); - h = std::fmod(h, 1.); + h = std::fmod (h, 1.); } else { h = h1 + f * d; } // not strictly necessary..but in case of - if(h < T(0)) { - h = T(1.) - h; + if (h < T (0)) { + h = T (1.) - h; } - if(h > T(1)) { - h = h - T(1.); + if (h > T (1)) { + h = h - T (1.); } return h; @@ -950,7 +950,7 @@ public: */ static inline double gamma2 (double x) // g3 1+g4 { - return x <= 0.003041 ? x * 12.92 : 1.055011 * exp(log(x) / sRGBGammaCurve) - 0.055011; + return x <= 0.003041 ? x * 12.92 : 1.055011 * exp (log (x) / sRGBGammaCurve) - 0.055011; } @@ -962,7 +962,7 @@ public: */ static inline double igamma2 (double x) //g2 { - return x <= 0.039293 ? x / 12.92 : exp(log((x + 0.055011) / 1.055011) * sRGBGammaCurve); + return x <= 0.039293 ? x / 12.92 : exp (log ((x + 0.055011) / 1.055011) * sRGBGammaCurve); } @@ -973,7 +973,7 @@ public: */ static inline double gamma55 (double x) // g3 1+g4 { - return x <= 0.013189 ? x * 10.0 : 1.593503 * exp(log(x) / 5.5) - 0.593503; // 5.5 10 + return x <= 0.013189 ? x * 10.0 : 1.593503 * exp (log (x) / 5.5) - 0.593503; // 5.5 10 } @@ -984,7 +984,7 @@ public: */ static inline double igamma55 (double x) //g2 { - return x <= 0.131889 ? x / 10.0 : exp(log((x + 0.593503) / 1.593503) * 5.5); // 5.5 10 + return x <= 0.131889 ? x / 10.0 : exp (log ((x + 0.593503) / 1.593503) * 5.5); // 5.5 10 } @@ -995,7 +995,7 @@ public: */ static inline double gamma4 (double x) // g3 1+g4 { - return x <= 0.03089 ? x * 5.0 : 1.478793 * exp(log(x) / 4.1) - 0.478793; // 4 5 + return x <= 0.03089 ? x * 5.0 : 1.478793 * exp (log (x) / 4.1) - 0.478793; // 4 5 } @@ -1006,7 +1006,7 @@ public: */ static inline double igamma4 (double x) //g2 { - return x <= 0.154449 ? x / 5.0 : exp(log((x + 0.478793) / 1.478793) * 4.1); // 4 5 + return x <= 0.154449 ? x / 5.0 : exp (log ((x + 0.478793) / 1.478793) * 4.1); // 4 5 } @@ -1037,7 +1037,7 @@ public: */ static inline double gamma24_17 (double x) { - return x <= 0.001867 ? x * 17.0 : 1.044445 * exp(log(x) / 2.4) - 0.044445; + return x <= 0.001867 ? x * 17.0 : 1.044445 * exp (log (x) / 2.4) - 0.044445; } @@ -1048,7 +1048,7 @@ public: */ static inline double igamma24_17 (double x) { - return x <= 0.031746 ? x / 17.0 : exp(log((x + 0.044445) / 1.044445) * 2.4); + return x <= 0.031746 ? x / 17.0 : exp (log ((x + 0.044445) / 1.044445) * 2.4); } @@ -1059,7 +1059,7 @@ public: */ static inline double gamma26_11 (double x) { - return x <= 0.004921 ? x * 11.0 : 1.086603 * exp(log(x) / 2.6) - 0.086603; + return x <= 0.004921 ? x * 11.0 : 1.086603 * exp (log (x) / 2.6) - 0.086603; } @@ -1070,7 +1070,7 @@ public: */ static inline double igamma26_11 (double x) { - return x <= 0.054127 ? x / 11.0 : exp(log((x + 0.086603) / 1.086603) * 2.6); + return x <= 0.054127 ? x / 11.0 : exp (log ((x + 0.086603) / 1.086603) * 2.6); } /** * @brief Get the gamma value for Gamma=1.3 Slope=2 @@ -1079,42 +1079,42 @@ public: */ static inline double gamma13_2 (double x) { - return x <= 0.016613 ? x * 2.0 : 1.009968 * exp(log(x) / 1.3) - 0.009968; + return x <= 0.016613 ? x * 2.0 : 1.009968 * exp (log (x) / 1.3) - 0.009968; } static inline double igamma13_2 (double x) { - return x <= 0.033226 ? x / 2.0 : exp(log((x + 0.009968) / 1.009968) * 1.3); + return x <= 0.033226 ? x / 2.0 : exp (log ((x + 0.009968) / 1.009968) * 1.3); } static inline double gamma115_2 (double x) { - return x <= 0.001692 ? x * 2.0 : 1.000508 * exp(log(x) / 1.15) - 0.000508; + return x <= 0.001692 ? x * 2.0 : 1.000508 * exp (log (x) / 1.15) - 0.000508; } static inline double igamma115_2 (double x) { - return x <= 0.003384 ? x / 2.0 : exp(log((x + 0.000508) / 1.000508) * 1.15); + return x <= 0.003384 ? x / 2.0 : exp (log ((x + 0.000508) / 1.000508) * 1.15); } static inline double gamma145_3 (double x) { - return x <= 0.009115 ? x * 3.0 : 1.012305 * exp(log(x) / 1.45) - 0.012305; + return x <= 0.009115 ? x * 3.0 : 1.012305 * exp (log (x) / 1.45) - 0.012305; } static inline double igamma145_3 (double x) { - return x <= 0.027345 ? x / 3.0 : exp(log((x + 0.012305) / 1.012305) * 1.45); + return x <= 0.027345 ? x / 3.0 : exp (log ((x + 0.012305) / 1.012305) * 1.45); } //gamma for Retinex static inline double gammareti (double x, double gamma, double start, double slope, double mul, double add) { - return (x <= start ? x*slope : exp(log(x) / gamma) * mul - add); + return (x <= start ? x*slope : exp (log (x) / gamma) * mul - add); } static inline double igammareti (double x, double gamma, double start, double slope, double mul, double add) { - return (x <= start * slope ? x / slope : exp(log((x + add) / mul) * gamma) ); + return (x <= start * slope ? x / slope : exp (log ((x + add) / mul) * gamma) ); } @@ -1124,12 +1124,12 @@ public: // X range 0..1 static inline double gamma (double x, double gamma, double start, double slope, double mul, double add) { - return (x <= start ? x*slope : exp(log(x) / gamma) * mul - add); + return (x <= start ? x*slope : exp (log (x) / gamma) * mul - add); } static inline float gammaf (float x, float gamma, float start, float slope) { - return x <= start ? x * slope : xexpf(xlogf(x) / gamma); + return x <= start ? x * slope : xexpf (xlogf (x) / gamma); } //fills a LUT of size 65536 using gamma with slope... @@ -1137,7 +1137,7 @@ public: static inline double igamma (double x, double gamma, double start, double slope, double mul, double add) { - return (x <= start * slope ? x / slope : exp(log((x + add) / mul) * gamma) ); + return (x <= start * slope ? x / slope : exp (log ((x + add) / mul) * gamma) ); } @@ -1149,7 +1149,7 @@ public: */ static inline double gamman (double x, double gamma) //standard gamma without slope... { - return exp(log(x) / gamma); + return exp (log (x) / gamma); } /** @@ -1160,7 +1160,7 @@ public: */ static inline float gammanf (float x, float gamma) //standard gamma without slope... { - return xexpf(xlogf(x) / gamma); + return xexpf (xlogf (x) / gamma); } //fills a LUT of size 65536 using gamma without slope... static void gammanf2lut (LUTf &gammacurve, float gamma, float divisor, float factor); @@ -1173,7 +1173,7 @@ public: */ static inline double igamman (double x, double gamma) //standard inverse gamma without slope... { - return exp(log(x) * gamma); + return exp (log (x) * gamma); } @@ -1355,41 +1355,41 @@ public: static inline void pregamutlab (float lum, float hue, float &chr)//big approximation to limit gamut (Prophoto) before good gamut procedure for locallab chroma, to avoid crash { if (lum >= 95.0f) { - if(hue > 1.5f && hue < 2.f ) { + if (hue > 1.5f && hue < 2.f ) { chr = 120.f; - } else if(hue > 0.7f && hue <= 1.5f) { + } else if (hue > 0.7f && hue <= 1.5f) { chr = 60.f; } else { chr = 40.f; } - } else if(lum > 75.f) { - if(hue > 1.f && hue < 3.14f ) { + } else if (lum > 75.f) { + if (hue > 1.f && hue < 3.14f ) { chr = 130.f; - } else if(hue > -0.4f && hue <= 1.f) { + } else if (hue > -0.4f && hue <= 1.f) { chr = 80.f; - } else if(hue > -3.15f && hue > -2.f) { + } else if (hue > -3.15f && hue > -2.f) { chr = 80.f; } else { chr = 60.f; } - } else if(lum > 35.f) { + } else if (lum > 35.f) { chr = 100.f; - } else if(lum > 20.f) { - if(hue < -1.f && hue > -2.f ) { + } else if (lum > 20.f) { + if (hue < -1.f && hue > -2.f ) { chr = 120.f; } else { chr = 80.f; } - } else if(lum > 7.f) { - if(hue < -1.f && hue > -1.8f ) { + } else if (lum > 7.f) { + if (hue < -1.f && hue > -1.8f ) { chr = 120.f; } else { chr = 60.f; } } else { - if(hue < -1.f && hue > -1.6f ) { + if (hue < -1.f && hue > -1.6f ) { chr = 80.f; } else { chr = 40.f; @@ -1413,10 +1413,10 @@ public: // wide area for transition, uses explicit factor 0.4 if (lum >= 85.0f) { - if((hue > (t_l + 0.53f - H9) && hue < (t_r + H9)) && (chrom > 8.0f && chrom < (14.0f + C9))) { + if ((hue > (t_l + 0.53f - H9) && hue < (t_r + H9)) && (chrom > 8.0f && chrom < (14.0f + C9))) { scale = (100.f - skinprot) / 100.1f; } else if (lum >= 92.0f) { - if((hue > t_l + 0.4f && hue < t_r) && (chrom > 7.0f && chrom < (15.0f))) { + if ((hue > t_l + 0.4f && hue < t_r) && (chrom > 7.0f && chrom < (15.0f))) { scale = (100.f - skinprot * 0.6f) / 100.1f; } else if ((hue > b_l && hue < t_r) && (chrom > 7.0f && chrom < (18.0f))) { scale = (100.f - skinprot * 0.4f) / 100.1f; @@ -1427,7 +1427,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 70.0f) { - if((hue > t_l + 0.15f && hue < (t_r - 0.2f + H8)) && (chrom > 8.0f && chrom < (35.0f + C8))) { + if ((hue > t_l + 0.15f && hue < (t_r - 0.2f + H8)) && (chrom > 8.0f && chrom < (35.0f + C8))) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1435,7 +1435,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 52.0f) { - if((hue > t_l && hue < (t_r + H7)) && (chrom > 11.0f && chrom < (35.0f + C7))) { + if ((hue > t_l && hue < (t_r + H7)) && (chrom > 11.0f && chrom < (35.0f + C7))) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1443,7 +1443,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 35.0f) { - if((hue > t_l && hue < (t_r + H4)) && (chrom > 13.0f && chrom < (37.0f + C4))) { + if ((hue > t_l && hue < (t_r + H4)) && (chrom > 13.0f && chrom < (37.0f + C4))) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1451,7 +1451,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 20.0f) { - if((hue > t_l && hue < (t_r + H3)) && (chrom > 7.0f && chrom < (35.0f + C3) )) { + if ((hue > t_l && hue < (t_r + H3)) && (chrom > 7.0f && chrom < (35.0f + C3) )) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1459,7 +1459,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 10.0f) { - if((hue > (t_l - 0.25f + H10) && hue < (t_r - 0.3f + H2)) && (chrom > 8.0f && chrom < (23.0f + C2))) { + if ((hue > (t_l - 0.25f + H10) && hue < (t_r - 0.3f + H2)) && (chrom > 8.0f && chrom < (23.0f + C2))) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1475,7 +1475,7 @@ public: } //extended zone for hair, beard and if user adjust high value for skinprot - if(skinprot > 85.f && chrom < 20.f && neg) { + if (skinprot > 85.f && chrom < 20.f && neg) { float modula = -0.0666f * skinprot + 6.66f; scale *= modula; } @@ -1490,12 +1490,12 @@ public: // "real" skin color : take into account a slightly usage of contrast and saturation in RT if option "skin" = 1, uses imolicit factor 1.0 // wide area skin color, useful if not accurate colorimetry or if the user has changed hue and saturation, uses explicit facor 0.6 // wide area for transition, uses explicit factor 0.4 - if((b_l > -0.3f && b_r < 2.f) || basc == 0) { //range maxi skin + if ((b_l > -0.3f && b_r < 2.f) || basc == 0) { //range maxi skin if (lum >= 85.0f) { - if((hue > (t_l + 0.53f - H9) && hue < (t_r + H9)) && (chrom > 8.0f && chrom < (14.0f + C9))) { + if ((hue > (t_l + 0.53f - H9) && hue < (t_r + H9)) && (chrom > 8.0f && chrom < (14.0f + C9))) { scale = (100.f - skinprot) / 100.1f; } else if (lum >= 92.0f) { - if((hue > t_l + 0.4f && hue < t_r) && (chrom > 7.0f && chrom < (15.0f))) { + if ((hue > t_l + 0.4f && hue < t_r) && (chrom > 7.0f && chrom < (15.0f))) { scale = (100.f - skinprot * 0.6f) / 100.1f; } else if ((hue > b_l && hue < t_r) && (chrom > 7.0f && chrom < (18.0f))) { scale = (100.f - skinprot * 0.4f) / 100.1f; @@ -1506,7 +1506,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 70.0f) { - if((hue > t_l + 0.15f && hue < (t_r - 0.2f + H8)) && (chrom > 8.0f && chrom < (35.0f + C8))) { + if ((hue > t_l + 0.15f && hue < (t_r - 0.2f + H8)) && (chrom > 8.0f && chrom < (35.0f + C8))) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1514,7 +1514,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 52.0f) { - if((hue > t_l && hue < (t_r + H7)) && (chrom > 11.0f && chrom < (35.0f + C7))) { + if ((hue > t_l && hue < (t_r + H7)) && (chrom > 11.0f && chrom < (35.0f + C7))) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1522,7 +1522,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 35.0f) { - if((hue > t_l && hue < (t_r + H4)) && (chrom > 13.0f && chrom < (37.0f + C4))) { + if ((hue > t_l && hue < (t_r + H4)) && (chrom > 13.0f && chrom < (37.0f + C4))) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1530,7 +1530,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 20.0f) { - if((hue > t_l && hue < (t_r + H3)) && (chrom > 7.0f && chrom < (35.0f + C3) )) { + if ((hue > t_l && hue < (t_r + H3)) && (chrom > 7.0f && chrom < (35.0f + C3) )) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1538,7 +1538,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 10.0f) { - if((hue > (t_l - 0.25f + H10) && hue < (t_r - 0.3f + H2)) && (chrom > 8.0f && chrom < (23.0f + C2))) { + if ((hue > (t_l - 0.25f + H10) && hue < (t_r - 0.3f + H2)) && (chrom > 8.0f && chrom < (23.0f + C2))) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1554,21 +1554,21 @@ public: } //extended zone for hair, beard and if user adjust high value for skinprot - if(skinprot > 85.f && chrom < 20.f && neg) { + if (skinprot > 85.f && chrom < 20.f && neg) { float modula = -0.0666f * skinprot + 6.66f; scale *= modula; } } //end hue skin algo else if (basc == 1) { //not hue skin linear transition or mod chroma curve - if(hue >= t_l && hue <= t_r) { + if (hue >= t_l && hue <= t_r) { scale = (100.f - skinprot) / 100.1f; - } else if(hue > b_l && hue < t_l) { + } else if (hue > b_l && hue < t_l) { float sc = (100.f - skinprot) / 100.1f; float aa = (1.f - sc) / (b_l - t_l); float bb = 1.f - aa * b_l; scale = aa * hue + bb; - } else if(hue > t_r && hue < b_r) { + } else if (hue > t_r && hue < b_r) { float sc = (100.f - skinprot) / 100.1f; float aa = (sc - 1.f) / (t_r - b_r); float bb = 1.f - aa * b_r; @@ -1589,15 +1589,15 @@ public: if (hue > 8.6f && hue <= 74.f ) { HH = (1.15f / 65.4f) * hue - 0.0012f; //H > 0.15 H<1.3 - } else if(hue > 0.f && hue <= 8.6f ) { + } else if (hue > 0.f && hue <= 8.6f ) { HH = (0.19f / 8.6f ) * hue - 0.04f; //H>-0.04 H < 0.15 - } else if(hue > 355.f && hue <= 360.f) { + } else if (hue > 355.f && hue <= 360.f) { HH = (0.11f / 5.0f ) * hue - 7.96f; //H>-0.15 <-0.04 - } else if(hue > 74.f && hue < 95.f ) { + } else if (hue > 74.f && hue < 95.f ) { HH = (0.30f / 21.0f) * hue + 0.24285f; //H>1.3 H<1.6 - } else if(hue >= 95.f && hue < 137.5f) { + } else if (hue >= 95.f && hue < 137.5f) { HH = 0.01882f * hue - 0.18823f; // H>1.6 H<2.4 - } else if(hue > 285.f && hue <= 355.f) { + } else if (hue > 285.f && hue <= 355.f) { HH = 0.1642f * hue - 5.982f; //HH>-1.3 HH <-0.15 } @@ -1608,10 +1608,10 @@ public: // wide area for transition, uses explicit factor 0.4 if (lum >= 85.0f) { - if((hue > (t_l + 0.53f - H9) && hue < (t_r + H9)) && (chrom > 8.0f && chrom < (14.0f + C9))) { + if ((hue > (t_l + 0.53f - H9) && hue < (t_r + H9)) && (chrom > 8.0f && chrom < (14.0f + C9))) { scale = (100.f - skinprot) / 100.1f; } else if (lum >= 92.0f) { - if((hue > t_l + 0.4f && hue < t_r) && (chrom > 7.0f && chrom < (15.0f))) { + if ((hue > t_l + 0.4f && hue < t_r) && (chrom > 7.0f && chrom < (15.0f))) { scale = (100.f - skinprot * 0.6f) / 100.1f; } else if ((hue > b_l && hue < t_r) && (chrom > 7.0f && chrom < (18.0f))) { scale = (100.f - skinprot * 0.4f) / 100.1f; @@ -1622,7 +1622,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 70.0f) { - if((hue > t_l + 0.15f && hue < (t_r - 0.2f + H8)) && (chrom > 8.0f && chrom < (35.0f + C8))) { + if ((hue > t_l + 0.15f && hue < (t_r - 0.2f + H8)) && (chrom > 8.0f && chrom < (35.0f + C8))) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1630,7 +1630,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 52.0f) { - if((hue > t_l && hue < (t_r + H7)) && (chrom > 11.0f && chrom < (35.0f + C7))) { + if ((hue > t_l && hue < (t_r + H7)) && (chrom > 11.0f && chrom < (35.0f + C7))) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1638,7 +1638,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 35.0f) { - if((hue > t_l && hue < (t_r + H4)) && (chrom > 13.0f && chrom < (37.0f + C4))) { + if ((hue > t_l && hue < (t_r + H4)) && (chrom > 13.0f && chrom < (37.0f + C4))) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1646,7 +1646,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 20.0f) { - if((hue > t_l && hue < (t_r + H3)) && (chrom > 7.0f && chrom < (35.0f + C3) )) { + if ((hue > t_l && hue < (t_r + H3)) && (chrom > 7.0f && chrom < (35.0f + C3) )) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1654,7 +1654,7 @@ public: scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 10.0f) { - if((hue > (t_l - 0.25f + H10) && hue < (t_r - 0.3f + H2)) && (chrom > 8.0f && chrom < (23.0f + C2))) { + if ((hue > (t_l - 0.25f + H10) && hue < (t_r - 0.3f + H2)) && (chrom > 8.0f && chrom < (23.0f + C2))) { scale = (100.f - skinprot) / 100.1f; } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1) )) { scale = (100.f - skinprot * 0.6f) / 100.1f; @@ -1670,7 +1670,7 @@ public: } //extended zone for hair, beard and if user adjust high value for skinprot - if(skinprot > 85.f && chrom < 20.f && neg) { + if (skinprot > 85.f && chrom < 20.f && neg) { float modula = -0.0666f * skinprot + 6.66f; scale *= modula; } @@ -1684,7 +1684,7 @@ public: * @param Z Z channel input value and corrected output value [0 ; 65535] * @param p working profile */ - static void gamutmap(float &X, float &Y, float &Z, const double p[3][3]); + static void gamutmap (float &X, float &Y, float &Z, const double p[3][3]); /** @@ -1700,29 +1700,29 @@ public: //allways put h between 0 and 1 if (HH >= 0.f && HH < 0.6f ) { - hr = 0.11666 * double(HH) + 0.93; //hr 0.93 1.00 full red + hr = 0.11666 * double (HH) + 0.93; //hr 0.93 1.00 full red } else if (HH >= 0.6f && HH < 1.4f ) { - hr = 0.1125 * double(HH) - 0.0675; //hr 0.00 0.09 red yellow orange + hr = 0.1125 * double (HH) - 0.0675; //hr 0.00 0.09 red yellow orange } else if (HH >= 1.4f && HH < 2.f ) { - hr = 0.2666 * double(HH) - 0.2833; //hr 0.09 0.25 orange yellow + hr = 0.2666 * double (HH) - 0.2833; //hr 0.09 0.25 orange yellow } else if (HH >= 2.f && HH < 3.14159f) { - hr = 0.1489 * double(HH) - 0.04785; //hr 0.25 0.42 yellow green green + hr = 0.1489 * double (HH) - 0.04785; //hr 0.25 0.42 yellow green green } else if (HH >= -3.14159f && HH < -2.8f ) { - hr = 0.23419 * double(HH) + 1.1557; //hr 0.42 0.50 green + hr = 0.23419 * double (HH) + 1.1557; //hr 0.42 0.50 green } else if (HH >= -2.8f && HH < -2.3f ) { - hr = 0.16 * double(HH) + 0.948; //hr 0.50 0.58 cyan + hr = 0.16 * double (HH) + 0.948; //hr 0.50 0.58 cyan } else if (HH >= -2.3f && HH < -0.9f ) { - hr = 0.12143 * double(HH) + 0.85928; //hr 0.58 0.75 blue blue-sky + hr = 0.12143 * double (HH) + 0.85928; //hr 0.58 0.75 blue blue-sky } else if (HH >= -0.9f && HH < -0.1f ) { - hr = 0.2125 * double(HH) + 0.94125; //hr 0.75 0.92 purple magenta + hr = 0.2125 * double (HH) + 0.94125; //hr 0.75 0.92 purple magenta } else if (HH >= -0.1f && HH < 0.f ) { - hr = 0.1 * double(HH) + 0.93; //hr 0.92 0.93 red + hr = 0.1 * double (HH) + 0.93; //hr 0.92 0.93 red } // in case of ! if (hr < 0.0) { hr += 1.0; - } else if(hr > 1.0) { + } else if (hr > 1.0) { hr -= 1.0; } diff --git a/rtengine/curves.h b/rtengine/curves.h index 4760b26d7..e97842b80 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -273,7 +273,7 @@ public: } float R = hlrange / (val * comp); - return log (1.0 + Y) * R; + return log1p (Y) * R; } else { return exp_scale; } diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index b52fafa57..84629e771 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -1639,15 +1639,38 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte parent->ipf.transCoord (parent->fw, parent->fh, bx1, by1, bw, bh, orx, ory, orw, orh); if (check_need_larger_crop_for_lcp_distortion (parent->fw, parent->fh, orx, ory, orw, orh, parent->params)) { - double dW = double (parent->fw) * 0.15 / skip; // TODO - this is hardcoded ATM! - double dH = double (parent->fh) * 0.15 / skip; // this is an estimate of the max - // distortion relative to the image - // size. BUT IS 15% REALLY ENOUGH? - // In fact, is there a better way?? - orx = max (int (orx - dW / 2.0), 0); - ory = max (int (ory - dH / 2.0), 0); - orw = min (int (orw + dW), parent->fw - orx); - orh = min (int (orh + dH), parent->fh - ory); + // TODO - this is an estimate of the max distortion relative to the image size. ATM it is hardcoded to be 15%, which seems enough. If not, need to revise + int dW = int (double (parent->fw) * 0.15 / (2 * skip)); + int dH = int (double (parent->fh) * 0.15 / (2 * skip)); + int x1 = orx - dW; + int x2 = orx + orw + dW; + int y1 = ory - dH; + int y2 = ory + orh + dH; + + if (x1 < 0) { + x2 += -x1; + x1 = 0; + } + + if (x2 > parent->fw) { + x1 -= x2 - parent->fw; + x2 = parent->fw; + } + + if (y1 < 0) { + y2 += -y1; + y1 = 0; + } + + if (y2 > parent->fh) { + y1 -= y2 - parent->fh; + y2 = parent->fh; + } + + orx = max (x1, 0); + ory = max (y1, 0); + orw = min (x2 - x1, parent->fw - orx); + orh = min (y2 - y1, parent->fh - ory); } diff --git a/rtengine/diagonalcurves.cc b/rtengine/diagonalcurves.cc index 9ab17a0f4..1c75e3059 100644 --- a/rtengine/diagonalcurves.cc +++ b/rtengine/diagonalcurves.cc @@ -33,7 +33,6 @@ DiagonalCurve::DiagonalCurve (const std::vector& p, int poly_pn) { ppn = poly_pn > 65500 ? 65500 : poly_pn; - bool identity = true; if (ppn < 500) { hashSize = 100; // Arbitrary cut-off value, but mutliple of 10 @@ -46,6 +45,7 @@ DiagonalCurve::DiagonalCurve (const std::vector& p, int poly_pn) if (p.size() < 3) { kind = DCT_Empty; } else { + bool identity = true; kind = (DiagonalCurveType)p[0]; if (kind == DCT_Linear || kind == DCT_Spline || kind == DCT_NURBS) { @@ -364,7 +364,6 @@ double DiagonalCurve::getVal (double t) const } return poly_y[k_lo] + (t - poly_x[k_lo]) * dyByDx[k_lo]; - break; } case DCT_Empty : diff --git a/rtengine/dirpyr_equalizer.cc b/rtengine/dirpyr_equalizer.cc index 1ebc0b5e5..2011c6cbe 100644 --- a/rtengine/dirpyr_equalizer.cc +++ b/rtengine/dirpyr_equalizer.cc @@ -491,9 +491,6 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float idirpyr_eq_channelcam (dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold , h_p, C_p, skinprot, b_l, t_l, t_r); } - - scale = scales[0]; - idirpyr_eq_channelcam (dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, h_p, C_p, skinprot, b_l, t_l, t_r); @@ -749,7 +746,7 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel (float ** data_fine, float ** d //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void ImProcFunctions::idirpyr_eq_channel_loc (float ** data_coarse, float ** data_fine, float ** loctemp, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r , int choice) { -// const float skinprotneg = -skinprot; + // const float skinprotneg = -skinprot; // const float factorHard = (1.f - skinprotneg / 100.f); float offs; @@ -841,10 +838,7 @@ void ImProcFunctions::idirpyr_eq_channel_loc (float ** data_coarse, float ** dat */ } - - - -void ImProcFunctions::idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r , int choice) +void ImProcFunctions::idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[6], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r , int choice) { const float skinprotneg = -skinprot; const float factorHard = (1.f - skinprotneg / 100.f); @@ -936,7 +930,7 @@ void ImProcFunctions::idirpyr_eq_channel (float ** data_coarse, float ** data_fi } -void ImProcFunctions::idirpyr_eq_channelcam (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r) +void ImProcFunctions::idirpyr_eq_channelcam (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r) { const float skinprotneg = -skinprot; diff --git a/rtengine/flatcurves.cc b/rtengine/flatcurves.cc index ae1a895ff..fe5ecc5e1 100644 --- a/rtengine/flatcurves.cc +++ b/rtengine/flatcurves.cc @@ -30,9 +30,8 @@ FlatCurve::FlatCurve (const std::vector& p, bool isPeriodic, int poly_pn poly_x.clear(); poly_y.clear(); - bool identity = true; - if (p.size() > 4) { + bool identity = true; kind = (FlatCurveType)p[0]; if (kind == FCT_MinMaxCPoints) { @@ -146,7 +145,6 @@ void FlatCurve::CtrlPoints_set () double length; double dx; double dy; - double xp1, xp2, yp2, xp3; bool startLinear, endLinear; startLinear = (rightTangent[i] == 0.) || (y[i] == y[i + 1]); @@ -171,6 +169,7 @@ void FlatCurve::CtrlPoints_set () sc_length[k++] = length; total_length += length; } else { + double xp1, xp2, yp2, xp3; if (startLinear) { xp1 = x[i]; } else { @@ -363,7 +362,6 @@ double FlatCurve::getVal (double t) const } return poly_y[k_lo] + (t - poly_x[k_lo]) * dyByDx[k_lo]; - break; } /*case Parametric : { diff --git a/rtengine/fujicompressed.cc b/rtengine/fujicompressed.cc index 75ca46c04..c5dfa8f13 100644 --- a/rtengine/fujicompressed.cc +++ b/rtengine/fujicompressed.cc @@ -151,7 +151,6 @@ void CLASS copy_line_to_xtrans (struct fuji_compressed_block* info, int cur_line ushort *lineBufB[3]; ushort *lineBufG[6]; ushort *lineBufR[3]; - unsigned pixel_count; ushort* line_buf; int index; @@ -169,7 +168,7 @@ void CLASS copy_line_to_xtrans (struct fuji_compressed_block* info, int cur_line } while (row_count < 6) { - pixel_count = 0; + unsigned pixel_count = 0; while (static_cast(pixel_count) < cur_block_width) { switch (xtrans_abs[row_count][ (pixel_count % 6)]) { @@ -203,7 +202,6 @@ void CLASS copy_line_to_bayer (struct fuji_compressed_block *info, int cur_line, ushort *lineBufB[3]; ushort *lineBufG[6]; ushort *lineBufR[3]; - unsigned pixel_count; ushort *line_buf; int fuji_bayer[2][2]; @@ -227,7 +225,7 @@ void CLASS copy_line_to_bayer (struct fuji_compressed_block *info, int cur_line, } while (row_count < 6) { - pixel_count = 0; + unsigned pixel_count = 0; while (static_cast(pixel_count) < cur_block_width) { switch (fuji_bayer[row_count & 1][pixel_count & 1]) { diff --git a/rtengine/hilite_recon.cc b/rtengine/hilite_recon.cc index b0b211e3d..f9e630f9d 100644 --- a/rtengine/hilite_recon.cc +++ b/rtengine/hilite_recon.cc @@ -217,7 +217,6 @@ void RawImageSource::boxblur_resamp(float **src, float **dst, float ** temp, int #pragma omp parallel #endif { - float tempval; #ifdef _OPENMP #pragma omp for #endif @@ -227,7 +226,7 @@ void RawImageSource::boxblur_resamp(float **src, float **dst, float ** temp, int for (int row = 0; row < H; row++) { int len = box + 1; - tempval = src[row][0] / len; + float tempval = src[row][0] / len; for (int j = 1; j <= box; j++) { tempval += src[row][j] / len; @@ -339,12 +338,11 @@ void RawImageSource::boxblur_resamp(float **src, float **dst, float ** temp, int // process remaining columns #pragma omp single { - float tempval; //vertical blur for (int col = (W / samp) - ((W / samp) % numCols); col < W / samp; col++) { int len = box + 1; - tempval = temp[0][col] / len; + float tempval = temp[0][col] / len; for (int i = 1; i <= box; i++) { tempval += temp[i][col] / len; diff --git a/rtengine/iccjpeg.cc b/rtengine/iccjpeg.cc index 31aa0ec7c..5e652296f 100644 --- a/rtengine/iccjpeg.cc +++ b/rtengine/iccjpeg.cc @@ -55,7 +55,6 @@ write_icc_profile (j_compress_ptr cinfo, { unsigned int num_markers; /* total number of markers we'll write */ int cur_marker = 1; /* per spec, counting starts at 1 */ - unsigned int length; /* number of bytes to write in this marker */ /* Calculate the number of markers we'll need, rounding up of course */ num_markers = icc_data_len / MAX_DATA_BYTES_IN_MARKER; @@ -66,7 +65,7 @@ write_icc_profile (j_compress_ptr cinfo, while (icc_data_len > 0) { /* length of profile to put in this marker */ - length = icc_data_len; + unsigned int length = icc_data_len; /* number of bytes to write in this marker */ if (length > MAX_DATA_BYTES_IN_MARKER) { length = MAX_DATA_BYTES_IN_MARKER; diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index 4c749e3c4..5aff1d335 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -864,7 +864,7 @@ cmsHPROFILE rtengine::ICCStore::makeStdGammaProfile(cmsHPROFILE iprof) } tags[tag_count]; const uint32_t gamma = 0x239; - int gamma_size =(gamma == 0 || gamma == 256) ? 12 : 14; + int gamma_size = 14; int data_size =(gamma_size + 3) & ~3; for (uint32_t i = 0; i < tag_count; i++) { diff --git a/rtengine/iimage.h b/rtengine/iimage.h index b06a188bc..149ed3787 100644 --- a/rtengine/iimage.h +++ b/rtengine/iimage.h @@ -376,6 +376,9 @@ public: v(y, x) = tmp; } } +#ifdef _OPENMP + static_cast(bigImage); // to silence cppcheck warning +#endif } } @@ -460,6 +463,9 @@ public: v(i, j) = v(i, x); v(i, x) = temp; } +#ifdef _OPENMP + static_cast(bigImage); // to silence cppcheck warning +#endif } void vflip () @@ -482,6 +488,9 @@ public: v(i, j) = v(y, j); v(y, j) = temp; } +#ifdef _OPENMP + static_cast(bigImage); // to silence cppcheck warning +#endif } void calcHist(unsigned int *hist16) @@ -790,6 +799,9 @@ public: b(y, x) = tmp; } } +#ifdef _OPENMP + static_cast(bigImage); // to silence cppcheck warning +#endif } } @@ -878,6 +890,9 @@ public: b(i, j) = b(i, x); b(i, x) = temp; } +#ifdef _OPENMP + static_cast(bigImage); // to silence cppcheck warning +#endif } void vflip () @@ -908,6 +923,9 @@ public: b(i, j) = b(y, j); b(y, j) = tempB; } +#ifdef _OPENMP + static_cast(bigImage); // to silence cppcheck warning +#endif } void calcGrayscaleHist(unsigned int *hist16) diff --git a/rtengine/imagefloat.cc b/rtengine/imagefloat.cc index a0a7e293c..30871c9b1 100644 --- a/rtengine/imagefloat.cc +++ b/rtengine/imagefloat.cc @@ -447,10 +447,8 @@ void Imagefloat::calcCroppedHistogram(const ProcParams ¶ms, float scale, LUT #pragma omp for nowait for (int y = y1; y < y2; y++) { - int i; - for (int x = x1; x < x2; x++) { - i = (int)(facRed * r(y, x) + facGreen * g(y, x) + facBlue * b(y, x)); + int i = (int)(facRed * r(y, x) + facGreen * g(y, x) + facBlue * b(y, x)); if (i < 0) { i = 0; diff --git a/rtengine/imageio.cc b/rtengine/imageio.cc index 197055858..8bc5362fd 100644 --- a/rtengine/imageio.cc +++ b/rtengine/imageio.cc @@ -696,7 +696,7 @@ int ImageIO::getTIFFSampleFormat (Glib::ustring fname, IIOSampleFormat &sFormat, sFormat = IIOSF_HALF; return IMIO_SUCCESS; }*/ - if ((samplesperpixel == 3 || samplesperpixel == 4) && bitspersample == 32) { + if (bitspersample == 32) { sFormat = IIOSF_FLOAT; return IMIO_SUCCESS; } diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index 8b4377c89..d6d0a618f 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -101,7 +101,7 @@ public: } virtual void getFullSize (int& w, int& h, int tr = TR_NONE) {} - virtual void getSize (PreviewProps pp, int& w, int& h) = 0; + virtual void getSize (const PreviewProps &pp, int& w, int& h) = 0; virtual int getRotateDegree() const { return 0; diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index cd59dbbe3..e1f49b6cd 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -693,6 +693,9 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) #endif lhist16 += lhist16thr; } +#ifdef _OPENMP + static_cast (numThreads); // to silence cppcheck warning +#endif CurveFactory::complexLCurve (params.labCurve.brightness, params.labCurve.contrast, params.labCurve.lcurve, lhist16, lumacurve, histLCurve, scale == 1 ? 1 : 16, utili); } diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 271e14637..6721850c5 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -189,6 +189,9 @@ void ImProcFunctions::firstAnalysis (const Imagefloat* const original, const Pro histogram += hist; } +#ifdef _OPENMP + static_cast (numThreads); // to silence cppcheck warning +#endif } else { for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { @@ -221,7 +224,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh LUTf dLcurve; LUTu hist16JCAM; bool jp = false; - float val; //preparate for histograms CIECAM if (pW != 1) { //only with improccoordinator @@ -231,7 +233,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh hist16JCAM.clear(); for (int i = 0; i < 32768; i++) { //# 32768*1.414 approximation maxi for chroma - val = (double)i / 32767.0; + float val = (double)i / 32767.0; dLcurve[i] = CLIPD (val); } } @@ -239,7 +241,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh LUTf dCcurve; LUTu hist16_CCAM; bool chropC = false; - float valc; if (pW != 1) { //only with improccoordinator dCcurve (65536, 0); @@ -247,7 +248,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh hist16_CCAM.clear(); for (int i = 0; i < 48000; i++) { //# 32768*1.414 approximation maxi for chroma - valc = (double)i / 47999.0; + float valc = (double)i / 47999.0; dCcurve[i] = CLIPD (valc); } } @@ -1219,9 +1220,9 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh artifact = 1.f; } - int hotbad = 0; float chrom = 50.f; { + int hotbad = 0; ImProcFunctions::badpixcam (ncie, artifact, 5, 2 , b_l, t_l, t_r, b_r, params->dirpyrequalizer.skinprotect , chrom, hotbad); //enabled remove artifacts for cbDL } } @@ -1244,15 +1245,15 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh //if(params->dirpyrequalizer.enabled) if(execsharp) { if (params->dirpyrequalizer.enabled /*&& (execsharp)*/) { - float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; - float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; - float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; - int choice = 0; //not disabled in case of ! always 0 // if (params->dirpyrequalizer.algo=="FI") choice=0; // else if(params->dirpyrequalizer.algo=="LA") choice=1; if (rtt == 1) { + float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; + float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; + float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; + float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; + int choice = 0; //not disabled in case of ! always 0 dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scalecd); //contrast by detail adapted to CIECAM } } @@ -1325,7 +1326,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh double chsacol = 327.; int libr = 0; int colch = 0; - float sa_t; if (curveMode == ColorAppearanceParams::TC_MODE_BRIGHT) { brli = 70.0; @@ -1371,7 +1371,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh if (colch == 0) { posc = CLIP ((int) (ncie->C_p[i][j] * chsacol)); //450.0 approximative factor for s 320 for M } else if (colch == 1) { - sa_t = 100.f * sqrt (ncie->C_p[i][j] / ncie->Q_p[i][j]); //Q_p always > 0 + float sa_t = 100.f * sqrt (ncie->C_p[i][j] / ncie->Q_p[i][j]); //Q_p always > 0 posc = CLIP ((int) (sa_t * chsacol)); } else { /*if(colch == 2)*/ posc = CLIP ((int) (ncie->M_p[i][j] * chsacol)); @@ -2603,15 +2603,15 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int //if(params->dirpyrequalizer.enabled) if(execsharp) { if (params->dirpyrequalizer.enabled /*&& execsharp*/) { - float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; - float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; - float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; - int choice = 0; // I have not suppress this statement in case of !! always to 0 // if(params->dirpyrequalizer.algo=="FI") choice=0; // else if(params->dirpyrequalizer.algo=="LA") choice=1; if (rtt == 1) { + float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; + float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; + float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; + float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; + int choice = 0; // I have not suppress this statement in case of !! always to 0 lab->deleteLab(); dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scalecd); //contrast by detail adapted to CIECAM lab->reallocLab(); @@ -3013,7 +3013,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer }; // For tonecurve histogram - float lumimulf[3] = {static_cast (lumimul[0]), static_cast (lumimul[1]), static_cast (lumimul[2])}; +// float lumimulf[3] = {static_cast (lumimul[0]), static_cast (lumimul[1]), static_cast (lumimul[2])}; bool mixchannels = (params->chmixer.red[0] != 100 || params->chmixer.red[1] != 0 || params->chmixer.red[2] != 0 || @@ -3232,9 +3232,6 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float gamvalr = 125.f; float gamvalg = 125.f; float gamvalb = 125.f; - double nr = 0; - double ng = 0; - double nb = 0; bool computeMixerAuto = params->blackwhite.autoc && (autor < -5000.f); if (bwrgam < 0) { @@ -3273,6 +3270,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer histToneCurveCompression = log2 (65536 / toneCurveHistSize); } + // For tonecurve histogram + const float lumimulf[3] = {static_cast (lumimul[0]), static_cast (lumimul[1]), static_cast (lumimul[2])}; + #define TS 112 @@ -4433,6 +4433,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer //end auto chmix if (computeMixerAuto) { // auto channel-mixer + double nr = 0; + double ng = 0; + double nb = 0; + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic, 16) reduction(+:nr,ng,nb) #endif @@ -4970,9 +4974,6 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go rlob = rlo; } - //second degree - float aa, bb, cc; - float v0 = 0.15f; //fixed value of reducac=0.3 //secondeg_end (reducac, v0, aa, bb, cc); @@ -4983,6 +4984,9 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go kl = (-1.f / 0.85f) * v + (1.f) / 0.85f; //Low light ==> decrease action after v=0.15 } } else { //color + float v0 = 0.15f; + //second degree + float aa, bb, cc; secondeg_end (reducac, v0, aa, bb, cc); float aab, bbb; secondeg_begin (0.7f, v0, aab, bbb); @@ -5042,7 +5046,6 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go // mid tones float km; float v0m = 0.5f; //max action - float v0mm = 0.5f; //max if (v < v0m) { float aam, bbm; @@ -5050,6 +5053,7 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go secondeg_begin (reducac, vend, aam, bbm); km = aam * v * v + bbm * v; //verification = good } else { + float v0mm = 0.5f; //max float aamm, bbmm, ccmm; secondeg_end (reducac, v0mm, aamm, bbmm, ccmm); km = aamm * v * v + bbmm * v + ccmm; //verification good @@ -5237,17 +5241,16 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g kl = aab * v * v + bbb * v; } - //rl gl bl - float RedL, GreenL, BlueL; - float krl = rl / (rl + gl + bl); - float kgl = gl / (rl + gl + bl); - float kbl = bl / (rl + gl + bl); if (SatLow > 0.f) { - float kmgb; + //rl gl bl + float krl = rl / (rl + gl + bl); + float kgl = gl / (rl + gl + bl); + float kbl = bl / (rl + gl + bl); + float RedL, GreenL, BlueL; if (g < 20000.f || b < 20000.f || r < 20000.f) { - kmgb = min (r, g, b); //I have tested ...0.85 compromise... + float kmgb = min (r, g, b); //I have tested ...0.85 compromise... kl *= pow ((kmgb / 20000.f), 0.85f); } @@ -5294,10 +5297,9 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g kh = aa0 * v * v + bb0 * v; } - float kmgb; if (g > 45535.f || b > 45535.f || r > 45535.f) { - kmgb = max (r, g, b); + float kmgb = max (r, g, b); float cora = 1.f / (45535.f - 65535.f); float corb = 1.f - cora * 45535.f; float cor = kmgb * cora + corb; @@ -5309,12 +5311,12 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g kh*=cor;*/ } - float RedH, GreenH, BlueH; - float krh = rh / (rh + gh + bh); - float kgh = gh / (rh + gh + bh); - float kbh = bh / (rh + gh + bh); if (SatHigh > 0.f) { + float RedH, GreenH, BlueH; + float krh = rh / (rh + gh + bh); + float kgh = gh / (rh + gh + bh); + float kbh = bh / (rh + gh + bh); RedH = 1.f + (SatHigh * krh) * kh * rlh * balanH; //1.2 if (krh > 0.f) { @@ -5642,14 +5644,14 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu const float amountchroma = (float) settings->amchroma; TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params->icm.working); - double wip[3][3] = { + const double wip[3][3] = { {wiprof[0][0], wiprof[0][1], wiprof[0][2]}, {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, {wiprof[2][0], wiprof[2][1], wiprof[2][2]} }; TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix (params->icm.working); - double wp[3][3] = { + const double wp[3][3] = { {wprof[0][0], wprof[0][1], wprof[0][2]}, {wprof[1][0], wprof[1][1], wprof[1][2]}, {wprof[2][0], wprof[2][1], wprof[2][2]} @@ -5806,7 +5808,6 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu float l_r;//Luminance Lab in 0..1 l_r = Lprov1 / 100.f; { - float khue = 1.9f; //in reserve in case of! float valparam = float ((lhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f)); //get l_r=f(H) float valparamneg; valparamneg = valparam; @@ -5820,6 +5821,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu } else //for negative { + float khue = 1.9f; //in reserve in case of! l_r *= (1.f + khue * valparamneg); } } @@ -5926,7 +5928,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu } if (clut) { // begin C=f(L) - float factorskin, factorsat, factor, factorskinext, interm; + float factorskin, factorsat, factor, factorskinext; float chromaCfactor = (clcurve[LL * 655.35f]) / (LL * 655.35f); //apply C=f(L) float curf = 0.7f; //empirical coeff because curve is more progressive float scale = 100.0f / 100.1f; //reduction in normal zone for curve C @@ -5960,7 +5962,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu } if (chromaCfactor > 1.0) { - interm = (chromaCfactor - 1.0f) * 100.0f; + float interm = (chromaCfactor - 1.0f) * 100.0f; factorskin = 1.0f + (interm * scale) / 100.0f; factorskinext = 1.0f + (interm * scaleext) / 100.0f; } else { @@ -5986,7 +5988,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu }//Lab C=f(C) pipette if (ccut) { - float factorskin, factorsat, factor, factorskinext, interm; + float factorskin, factorsat, factor, factorskinext; float chroma = sqrt (SQR (atmp) + SQR (btmp) + 0.001f); float chromaCfactor = (satcurve[chroma * adjustr]) / (chroma * adjustr); //apply C=f(C) float curf = 0.7f; //empirical coeff because curve is more progressive @@ -6021,7 +6023,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu } if (chromaCfactor > 1.0) { - interm = (chromaCfactor - 1.0f) * 100.0f; + float interm = (chromaCfactor - 1.0f) * 100.0f; factorskin = 1.0f + (interm * scale) / 100.0f; factorskinext = 1.0f + (interm * scaleext) / 100.0f; } else { @@ -6790,15 +6792,15 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double return; } - lodev = (lodev / (log (2.f) * losum)); - hidev = (hidev / (log (2.f) * hisum)); +// lodev = (lodev / (log(2.f) * losum)); +// hidev = (hidev / (log(2.f) * hisum)); - if (octile[6] > log ((float)imax + 1.f) / log2 (2.f)) { //if very overxposed image + if (octile[6] > log1p ((float)imax) / log2 (2.f)) { //if very overxposed image octile[6] = 1.5f * octile[5] - 0.5f * octile[4]; overex = 2; } - if (octile[7] > log ((float)imax + 1.f) / log2 (2.f)) { //if overexposed + if (octile[7] > log1p ((float)imax) / log2 (2.f)) { //if overexposed octile[7] = 1.5f * octile[6] - 0.5f * octile[5]; overex = 1; } @@ -6871,10 +6873,10 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double median <<= histcompr; shc <<= histcompr; - //prevent division by 0 - if (lodev == 0.f) { - lodev = 1.f; - } +// //prevent division by 0 +// if (lodev == 0.f) { +// lodev = 1.f; +// } //compute exposure compensation as geometric mean of the amount that //sets the mean or median at middle gray, and the amount that sets the estimated top @@ -7070,7 +7072,7 @@ double ImProcFunctions::getAutoDistor (const Glib::ustring &fname, int thumb_si int dist_result = calcDistortion (thumbGray, rawGray, width, h_thumb, 1, dist_amount); if (dist_result == -1) { // not enough features found, try increasing max. number of features by factor 4 - dist_result = calcDistortion (thumbGray, rawGray, width, h_thumb, 4, dist_amount); + calcDistortion (thumbGray, rawGray, width, h_thumb, 4, dist_amount); } delete thumbGray; diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 6ebf5c7e0..771359f9c 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -361,9 +361,9 @@ public: void cbdl_local_temp (float ** src, float ** dst, float ** loctemp, int srcwidth, int srcheight, const float * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale); void dirpyr_equalizercam (CieImage* ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale);//Emil's directional pyramid wavelet void dirpyr_channel (float ** data_fine, float ** data_coarse, int width, int height, int level, int scale); - void idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice); void idirpyr_eq_channel_loc (float ** data_coarse, float ** data_fine, float ** loctemp, float ** buffer, int width, int height, int level, float multi[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice); - void idirpyr_eq_channelcam (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r); + void idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice); + void idirpyr_eq_channelcam (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r); void defringe (LabImage* lab); void defringecam (CieImage* ncie); void badpixcam (CieImage* ncie, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad); diff --git a/rtengine/ipsharpen.cc b/rtengine/ipsharpen.cc index f94ff6e7f..f5a1f3cff 100644 --- a/rtengine/ipsharpen.cc +++ b/rtengine/ipsharpen.cc @@ -47,10 +47,10 @@ SSEFUNCTION void ImProcFunctions::dcdamping (float** aI, float** aO, float dampi #ifdef __SSE2__ __m128 Iv, Ov, Uv, zerov, onev, fourv, fivev, dampingFacv, Tv, Wv, Lv; zerov = _mm_setzero_ps( ); - onev = F2V( 1.0f ); - fourv = F2V( 4.0f ); - fivev = F2V( 5.0f ); - dampingFacv = F2V( dampingFac ); + onev = F2V ( 1.0f ); + fourv = F2V ( 4.0f ); + fivev = F2V ( 5.0f ); + dampingFacv = F2V ( dampingFac ); #endif #ifdef _OPENMP #pragma omp for @@ -61,24 +61,24 @@ SSEFUNCTION void ImProcFunctions::dcdamping (float** aI, float** aO, float dampi #ifdef __SSE2__ for (; j < W - 3; j += 4) { - Iv = LVFU( aI[i][j] ); - Ov = LVFU( aO[i][j] ); - Lv = xlogf(Iv / Ov); + Iv = LVFU ( aI[i][j] ); + Ov = LVFU ( aO[i][j] ); + Lv = xlogf (Iv / Ov); Wv = Ov - Iv; Uv = (Ov * Lv + Wv) * dampingFacv; - Uv = vminf(Uv, onev); + Uv = vminf (Uv, onev); Tv = Uv * Uv; Tv = Tv * Tv; Uv = Tv * (fivev - Uv * fourv); Uv = (Wv / Iv) * Uv + onev; - Uv = vselfzero(vmaskf_gt(Iv, zerov), Uv); - Uv = vselfzero(vmaskf_gt(Ov, zerov), Uv); - STVFU( aI[i][j], Uv ); + Uv = vselfzero (vmaskf_gt (Iv, zerov), Uv); + Uv = vselfzero (vmaskf_gt (Ov, zerov), Uv); + STVFU ( aI[i][j], Uv ); } #endif - for(; j < W; j++) { + for (; j < W; j++) { float I = aI[i][j]; float O = aO[i][j]; @@ -87,8 +87,8 @@ SSEFUNCTION void ImProcFunctions::dcdamping (float** aI, float** aO, float dampi continue; } - float U = (O * xlogf(I / O) - I + O) * dampingFac; - U = min(U, 1.0f); + float U = (O * xlogf (I / O) - I + O) * dampingFac; + U = min (U, 1.0f); U = U * U * U * U * (5.f - U * 4.f); aI[i][j] = (O - I) / I * U + 1.f; } @@ -110,7 +110,7 @@ void ImProcFunctions::deconvsharpening (float** luminance, float** tmp, int W, i } for (int i = 0; i < H; i++) { - for(int j = 0; j < W; j++) { + for (int j = 0; j < W; j++) { tmpI[i][j] = luminance[i][j]; } } @@ -146,7 +146,7 @@ void ImProcFunctions::deconvsharpening (float** luminance, float** tmp, int W, i for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) { - luminance[i][j] = luminance[i][j] * p1 + max(tmpI[i][j], 0.0f) * p2; + luminance[i][j] = luminance[i][j] * p1 + max (tmpI[i][j], 0.0f) * p2; } } // end parallel @@ -171,7 +171,7 @@ void ImProcFunctions::deconvsharpeningloc (float** luminance, float** tmp, int W } for (int i = 0; i < H; i++) { - for(int j = 0; j < W; j++) { + for (int j = 0; j < W; j++) { tmpI[i][j] = luminance[i][j]; } } @@ -180,7 +180,7 @@ void ImProcFunctions::deconvsharpeningloc (float** luminance, float** tmp, int W bool needdamp = damp > 0; double sigma = radi / scale; - if(sigma < 0.26f) { + if (sigma < 0.26f) { sigma = 0.26f; } @@ -213,7 +213,7 @@ void ImProcFunctions::deconvsharpeningloc (float** luminance, float** tmp, int W for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) { - loctemp[i][j] = luminance[i][j] * p1 + max(tmpI[i][j], 0.0f) * p2; + loctemp[i][j] = luminance[i][j] * p1 + max (tmpI[i][j], 0.0f) * p2; } } // end parallel @@ -280,8 +280,8 @@ void ImProcFunctions::sharpening (LabImage* lab, float** b2, SharpeningParams &s for (int j = 0; j < W; j++) { const float upperBound = 2000.f; // WARNING: Duplicated value, it's baaaaaad ! float diff = base[i][j] - b2[i][j]; - float delta = sharpenParam.threshold.multiply( - min(ABS(diff), upperBound), // X axis value = absolute value of the difference, truncated to the max value of this field + float delta = sharpenParam.threshold.multiply ( + min (ABS (diff), upperBound), // X axis value = absolute value of the difference, truncated to the max value of this field sharpenParam.amount * diff * 0.01f // Y axis max value ); lab->L[i][j] = lab->L[i][j] + delta; @@ -293,7 +293,7 @@ void ImProcFunctions::sharpening (LabImage* lab, float** b2, SharpeningParams &s // make a deep copy of lab->L labCopy = new float*[H]; - for( int i = 0; i < H; i++ ) { + for ( int i = 0; i < H; i++ ) { labCopy[i] = new float[W]; } @@ -301,8 +301,8 @@ void ImProcFunctions::sharpening (LabImage* lab, float** b2, SharpeningParams &s #pragma omp parallel for #endif - for( int i = 0; i < H; i++ ) - for( int j = 0; j < W; j++ ) { + for ( int i = 0; i < H; i++ ) + for ( int j = 0; j < W; j++ ) { labCopy[i][j] = lab->L[i][j]; } @@ -312,7 +312,7 @@ void ImProcFunctions::sharpening (LabImage* lab, float** b2, SharpeningParams &s sharpenHaloCtrl (lab->L, b2, base, W, H, sharpenParam); if (labCopy) { - for( int i = 0; i < H; i++ ) { + for ( int i = 0; i < H; i++ ) { delete[] labCopy[i]; } @@ -341,26 +341,26 @@ void ImProcFunctions::sharpenHaloCtrl (float** luminance, float** blurmap, float #endif for (int i = 2; i < H - 2; i++) { - float max1 = 0, max2 = 0, min1 = 0, min2 = 0, maxn, minn, np1, np2, np3, min_, max_, labL; + float max1 = 0, max2 = 0, min1 = 0, min2 = 0; for (int j = 2; j < W - 2; j++) { // compute 3 iterations, only forward - np1 = 2.f * (nL[i - 2][j] + nL[i - 2][j + 1] + nL[i - 2][j + 2] + nL[i - 1][j] + nL[i - 1][j + 1] + nL[i - 1][j + 2] + nL[i] [j] + nL[i] [j + 1] + nL[i] [j + 2]) / 27.f + nL[i - 1][j + 1] / 3.f; - np2 = 2.f * (nL[i - 1][j] + nL[i - 1][j + 1] + nL[i - 1][j + 2] + nL[i] [j] + nL[i] [j + 1] + nL[i] [j + 2] + nL[i + 1][j] + nL[i + 1][j + 1] + nL[i + 1][j + 2]) / 27.f + nL[i] [j + 1] / 3.f; - np3 = 2.f * (nL[i] [j] + nL[i] [j + 1] + nL[i] [j + 2] + nL[i + 1][j] + nL[i + 1][j + 1] + nL[i + 1][j + 2] + nL[i + 2][j] + nL[i + 2][j + 1] + nL[i + 2][j + 2]) / 27.f + nL[i + 1][j + 1] / 3.f; + float np1 = 2.f * (nL[i - 2][j] + nL[i - 2][j + 1] + nL[i - 2][j + 2] + nL[i - 1][j] + nL[i - 1][j + 1] + nL[i - 1][j + 2] + nL[i] [j] + nL[i] [j + 1] + nL[i] [j + 2]) / 27.f + nL[i - 1][j + 1] / 3.f; + float np2 = 2.f * (nL[i - 1][j] + nL[i - 1][j + 1] + nL[i - 1][j + 2] + nL[i] [j] + nL[i] [j + 1] + nL[i] [j + 2] + nL[i + 1][j] + nL[i + 1][j + 1] + nL[i + 1][j + 2]) / 27.f + nL[i] [j + 1] / 3.f; + float np3 = 2.f * (nL[i] [j] + nL[i] [j + 1] + nL[i] [j + 2] + nL[i + 1][j] + nL[i + 1][j + 1] + nL[i + 1][j + 2] + nL[i + 2][j] + nL[i + 2][j + 1] + nL[i + 2][j + 2]) / 27.f + nL[i + 1][j + 1] / 3.f; // Max/Min of all these deltas and the last two max/min - maxn = max(np1, np2, np3); - minn = min(np1, np2, np3); - max_ = max(max1, max2, maxn); - min_ = min(min1, min2, minn); + float maxn = max (np1, np2, np3); + float minn = min (np1, np2, np3); + float max_ = max (max1, max2, maxn); + float min_ = min (min1, min2, minn); // Shift the queue max1 = max2; max2 = maxn; min1 = min2; min2 = minn; - labL = luminance[i][j]; + float labL = luminance[i][j]; if (max_ < labL) { max_ = labL; @@ -374,8 +374,8 @@ void ImProcFunctions::sharpenHaloCtrl (float** luminance, float** blurmap, float float diff = nL[i][j] - blurmap[i][j]; const float upperBound = 2000.f; // WARNING: Duplicated value, it's baaaaaad ! - float delta = sharpenParam.threshold.multiply( - min(ABS(diff), upperBound), // X axis value = absolute value of the difference + float delta = sharpenParam.threshold.multiply ( + min (ABS (diff), upperBound), // X axis value = absolute value of the difference sharpFac * diff // Y axis max value = sharpening.amount * signed difference ); float newL = labL + delta; @@ -477,15 +477,15 @@ void ImProcFunctions::MLsharpen (LabImage* lab) #pragma omp parallel for private(j,i,iii,kkk, templab,offset,wH,wV,wD1,wD2,s,lumH,lumV,lumD1,lumD2,v,contrast,f1,f2,f3,f4,difT,difB,difL,difR,difLT,difLB,difRT,difRB) shared(lab,L,amount) #endif - for(j = 2; j < height - 2; j++) - for(i = 2, offset = j * width + i; i < width - 2; i++, offset++) { + for (j = 2; j < height - 2; j++) + for (i = 2, offset = j * width + i; i < width - 2; i++, offset++) { // weight functions - wH = eps2 + fabs(L[offset + 1] - L[offset - 1]); - wV = eps2 + fabs(L[offset + width] - L[offset - width]); + wH = eps2 + fabs (L[offset + 1] - L[offset - 1]); + wV = eps2 + fabs (L[offset + width] - L[offset - width]); - s = 1.0f + fabs(wH - wV) / 2.0f; - wD1 = eps2 + fabs(L[offset + width + 1] - L[offset - width - 1]) / s; - wD2 = eps2 + fabs(L[offset + width - 1] - L[offset - width + 1]) / s; + s = 1.0f + fabs (wH - wV) / 2.0f; + wD1 = eps2 + fabs (L[offset + width + 1] - L[offset - width - 1]) / s; + wD2 = eps2 + fabs (L[offset + width - 1] - L[offset - width + 1]) / s; s = wD1; wD1 /= wD2; wD2 /= wD1; @@ -504,7 +504,7 @@ void ImProcFunctions::MLsharpen (LabImage* lab) // contrast detection - contrast = sqrt(fabs(L[offset + 1] - L[offset - 1]) * fabs(L[offset + 1] - L[offset - 1]) + fabs(L[offset + width] - L[offset - width]) * fabs(L[offset + width] - L[offset - width])) / chmax[c]; + contrast = sqrt (fabs (L[offset + 1] - L[offset - 1]) * fabs (L[offset + 1] - L[offset - 1]) + fabs (L[offset + width] - L[offset - width]) * fabs (L[offset + width] - L[offset - width])) / chmax[c]; if (contrast > 1.0f) { contrast = 1.0f; @@ -512,15 +512,15 @@ void ImProcFunctions::MLsharpen (LabImage* lab) // new possible values if (((L[offset] < L[offset - 1]) && (L[offset] > L[offset + 1])) || ((L[offset] > L[offset - 1]) && (L[offset] < L[offset + 1]))) { - f1 = fabs(L[offset - 2] - L[offset - 1]); - f2 = fabs(L[offset - 1] - L[offset]); - f3 = fabs(L[offset - 1] - L[offset - width]) * fabs(L[offset - 1] - L[offset + width]); - f4 = sqrt(fabs(L[offset - 1] - L[offset - width2]) * fabs(L[offset - 1] - L[offset + width2])); + f1 = fabs (L[offset - 2] - L[offset - 1]); + f2 = fabs (L[offset - 1] - L[offset]); + f3 = fabs (L[offset - 1] - L[offset - width]) * fabs (L[offset - 1] - L[offset + width]); + f4 = sqrt (fabs (L[offset - 1] - L[offset - width2]) * fabs (L[offset - 1] - L[offset + width2])); difL = f1 * f2 * f2 * f3 * f3 * f4; - f1 = fabs(L[offset + 2] - L[offset + 1]); - f2 = fabs(L[offset + 1] - L[offset]); - f3 = fabs(L[offset + 1] - L[offset - width]) * fabs(L[offset + 1] - L[offset + width]); - f4 = sqrt(fabs(L[offset + 1] - L[offset - width2]) * fabs(L[offset + 1] - L[offset + width2])); + f1 = fabs (L[offset + 2] - L[offset + 1]); + f2 = fabs (L[offset + 1] - L[offset]); + f3 = fabs (L[offset + 1] - L[offset - width]) * fabs (L[offset + 1] - L[offset + width]); + f4 = sqrt (fabs (L[offset + 1] - L[offset - width2]) * fabs (L[offset + 1] - L[offset + width2])); difR = f1 * f2 * f2 * f3 * f3 * f4; if ((difR > epsil) && (difL > epsil)) { @@ -530,15 +530,15 @@ void ImProcFunctions::MLsharpen (LabImage* lab) } if (((L[offset] < L[offset - width]) && (L[offset] > L[offset + width])) || ((L[offset] > L[offset - width]) && (L[offset] < L[offset + width]))) { - f1 = fabs(L[offset - width2] - L[offset - width]); - f2 = fabs(L[offset - width] - L[offset]); - f3 = fabs(L[offset - width] - L[offset - 1]) * fabs(L[offset - width] - L[offset + 1]); - f4 = sqrt(fabs(L[offset - width] - L[offset - 2]) * fabs(L[offset - width] - L[offset + 2])); + f1 = fabs (L[offset - width2] - L[offset - width]); + f2 = fabs (L[offset - width] - L[offset]); + f3 = fabs (L[offset - width] - L[offset - 1]) * fabs (L[offset - width] - L[offset + 1]); + f4 = sqrt (fabs (L[offset - width] - L[offset - 2]) * fabs (L[offset - width] - L[offset + 2])); difT = f1 * f2 * f2 * f3 * f3 * f4; - f1 = fabs(L[offset + width2] - L[offset + width]); - f2 = fabs(L[offset + width] - L[offset]); - f3 = fabs(L[offset + width] - L[offset - 1]) * fabs(L[offset + width] - L[offset + 1]); - f4 = sqrt(fabs(L[offset + width] - L[offset - 2]) * fabs(L[offset + width] - L[offset + 2])); + f1 = fabs (L[offset + width2] - L[offset + width]); + f2 = fabs (L[offset + width] - L[offset]); + f3 = fabs (L[offset + width] - L[offset - 1]) * fabs (L[offset + width] - L[offset + 1]); + f4 = sqrt (fabs (L[offset + width] - L[offset - 2]) * fabs (L[offset + width] - L[offset + 2])); difB = f1 * f2 * f2 * f3 * f3 * f4; if ((difB > epsil) && (difT > epsil)) { @@ -548,15 +548,15 @@ void ImProcFunctions::MLsharpen (LabImage* lab) } if (((L[offset] < L[offset - 1 - width]) && (L[offset] > L[offset + 1 + width])) || ((L[offset] > L[offset - 1 - width]) && (L[offset] < L[offset + 1 + width]))) { - f1 = fabs(L[offset - 2 - width2] - L[offset - 1 - width]); - f2 = fabs(L[offset - 1 - width] - L[offset]); - f3 = fabs(L[offset - 1 - width] - L[offset - width + 1]) * fabs(L[offset - 1 - width] - L[offset + width - 1]); - f4 = sqrt(fabs(L[offset - 1 - width] - L[offset - width2 + 2]) * fabs(L[offset - 1 - width] - L[offset + width2 - 2])); + f1 = fabs (L[offset - 2 - width2] - L[offset - 1 - width]); + f2 = fabs (L[offset - 1 - width] - L[offset]); + f3 = fabs (L[offset - 1 - width] - L[offset - width + 1]) * fabs (L[offset - 1 - width] - L[offset + width - 1]); + f4 = sqrt (fabs (L[offset - 1 - width] - L[offset - width2 + 2]) * fabs (L[offset - 1 - width] - L[offset + width2 - 2])); difLT = f1 * f2 * f2 * f3 * f3 * f4; - f1 = fabs(L[offset + 2 + width2] - L[offset + 1 + width]); - f2 = fabs(L[offset + 1 + width] - L[offset]); - f3 = fabs(L[offset + 1 + width] - L[offset - width + 1]) * fabs(L[offset + 1 + width] - L[offset + width - 1]); - f4 = sqrt(fabs(L[offset + 1 + width] - L[offset - width2 + 2]) * fabs(L[offset + 1 + width] - L[offset + width2 - 2])); + f1 = fabs (L[offset + 2 + width2] - L[offset + 1 + width]); + f2 = fabs (L[offset + 1 + width] - L[offset]); + f3 = fabs (L[offset + 1 + width] - L[offset - width + 1]) * fabs (L[offset + 1 + width] - L[offset + width - 1]); + f4 = sqrt (fabs (L[offset + 1 + width] - L[offset - width2 + 2]) * fabs (L[offset + 1 + width] - L[offset + width2 - 2])); difRB = f1 * f2 * f2 * f3 * f3 * f4; if ((difLT > epsil) && (difRB > epsil)) { @@ -566,15 +566,15 @@ void ImProcFunctions::MLsharpen (LabImage* lab) } if (((L[offset] < L[offset + 1 - width]) && (L[offset] > L[offset - 1 + width])) || ((L[offset] > L[offset + 1 - width]) && (L[offset] < L[offset - 1 + width]))) { - f1 = fabs(L[offset - 2 + width2] - L[offset - 1 + width]); - f2 = fabs(L[offset - 1 + width] - L[offset]); - f3 = fabs(L[offset - 1 + width] - L[offset - width - 1]) * fabs(L[offset - 1 + width] - L[offset + width + 1]); - f4 = sqrt(fabs(L[offset - 1 + width] - L[offset - width2 - 2]) * fabs(L[offset - 1 + width] - L[offset + width2 + 2])); + f1 = fabs (L[offset - 2 + width2] - L[offset - 1 + width]); + f2 = fabs (L[offset - 1 + width] - L[offset]); + f3 = fabs (L[offset - 1 + width] - L[offset - width - 1]) * fabs (L[offset - 1 + width] - L[offset + width + 1]); + f4 = sqrt (fabs (L[offset - 1 + width] - L[offset - width2 - 2]) * fabs (L[offset - 1 + width] - L[offset + width2 + 2])); difLB = f1 * f2 * f2 * f3 * f3 * f4; - f1 = fabs(L[offset + 2 - width2] - L[offset + 1 - width]); - f2 = fabs(L[offset + 1 - width] - L[offset]) * fabs(L[offset + 1 - width] - L[offset]); - f3 = fabs(L[offset + 1 - width] - L[offset + width + 1]) * fabs(L[offset + 1 - width] - L[offset - width - 1]); - f4 = sqrt(fabs(L[offset + 1 - width] - L[offset + width2 + 2]) * fabs(L[offset + 1 - width] - L[offset - width2 - 2])); + f1 = fabs (L[offset + 2 - width2] - L[offset + 1 - width]); + f2 = fabs (L[offset + 1 - width] - L[offset]) * fabs (L[offset + 1 - width] - L[offset]); + f3 = fabs (L[offset + 1 - width] - L[offset + width + 1]) * fabs (L[offset + 1 - width] - L[offset - width - 1]); + f4 = sqrt (fabs (L[offset + 1 - width] - L[offset + width2 + 2]) * fabs (L[offset + 1 - width] - L[offset - width2 - 2])); difRT = f1 * f2 * f2 * f3 * f3 * f4; if ((difLB > epsil) && (difRT > epsil)) { @@ -586,7 +586,7 @@ void ImProcFunctions::MLsharpen (LabImage* lab) s = amount; // avoid sharpening diagonals too much - if (((fabs(wH / wV) < 0.45f) && (fabs(wH / wV) > 0.05f)) || ((fabs(wV / wH) < 0.45f) && (fabs(wV / wH) > 0.05f))) { + if (((fabs (wH / wV) < 0.45f) && (fabs (wH / wV) > 0.05f)) || ((fabs (wV / wH) < 0.45f) && (fabs (wV / wH) > 0.05f))) { s = amount / 3.0f; } @@ -596,8 +596,8 @@ void ImProcFunctions::MLsharpen (LabImage* lab) kkk = offset - iii * width; float provL = lab->L[iii][kkk] / 327.68f; - if(c == 0) { - if(provL < 92.f) { + if (c == 0) { + if (provL < 92.f) { templab = v * (1.f - s) + (lumH * wH + lumV * wV + lumD1 * wD1 + lumD2 * wD2) / (wH + wV + wD1 + wD2) * s; } else { templab = provL; @@ -607,7 +607,7 @@ void ImProcFunctions::MLsharpen (LabImage* lab) } if (c == 0) { - lab->L[iii][kkk] = fabs(327.68f * templab); // fabs because lab->L always >0 + lab->L[iii][kkk] = fabs (327.68f * templab); // fabs because lab->L always >0 } else if (c == 1) { lab->a[iii][kkk] = 327.68f * templab ; } else if (c == 2) { @@ -623,7 +623,7 @@ void ImProcFunctions::MLsharpen (LabImage* lab) t2e.set(); if (settings->verbose) { - printf("SharpenEdge gradient %d usec\n", t2e.etime(t1e)); + printf ("SharpenEdge gradient %d usec\n", t2e.etime (t1e)); } } @@ -636,7 +636,7 @@ void ImProcFunctions::MLsharpen (LabImage* lab) //!
The purpose is maximize clarity of the image without creating halo's. //!
Addition from JD : pyramid + pondered contrast with matrix 5x5 //! \param luminance : Luminance channel of image -void ImProcFunctions::MLmicrocontrast(float** luminance, int W, int H) +void ImProcFunctions::MLmicrocontrast (float** luminance, int W, int H) { if (!params->sharpenMicro.enabled) { return; @@ -655,7 +655,7 @@ void ImProcFunctions::MLmicrocontrast(float** luminance, int W, int H) int width = W, height = H; float uniform = params->sharpenMicro.uniformity;//between 0 to 100 int unif; - unif = (int)(uniform / 10.0f); //put unif between 0 to 10 + unif = (int) (uniform / 10.0f); //put unif between 0 to 10 float amount = params->sharpenMicro.amount / 1500.0f; //amount 2000.0 quasi no artefacts ==> 1500 = maximum, after artefacts if (amount < 0.000001f) { @@ -701,8 +701,8 @@ void ImProcFunctions::MLmicrocontrast(float** luminance, int W, int H) #pragma omp parallel for private(offset, i,j) shared(LM) #endif - for(j = 0; j < height; j++) - for(i = 0, offset = j * width + i; i < width; i++, offset++) { + for (j = 0; j < height; j++) + for (i = 0, offset = j * width + i; i < width; i++, offset++) { LM[offset] = luminance[j][i] / 327.68f; // adjust to 0.100 and to RT variables } @@ -710,14 +710,14 @@ void ImProcFunctions::MLmicrocontrast(float** luminance, int W, int H) #pragma omp parallel for private(j,i,offset,s,signs,v,n,row,col,offset2,contrast,temp,temp2,tempL,temp4) shared(luminance,LM,amount,chmax,unif,k,L98,L95,L92,L90,L87,L83,L80,L75,L70,L63,L58,Cont0,Cont1,Cont2,Cont3,Cont4,Cont5) #endif - for(j = k; j < height - k; j++) - for(i = k, offset = j * width + i; i < width - k; i++, offset++) { + for (j = k; j < height - k; j++) + for (i = k, offset = j * width + i; i < width - k; i++, offset++) { s = amount; v = LM[offset]; n = 0; - for(row = j - k; row <= j + k; row++) - for(col = i - k, offset2 = row * width + col; col <= i + k; col++, offset2++) { + for (row = j - k; row <= j + k; row++) + for (col = i - k, offset2 = row * width + col; col <= i + k; col++, offset2++) { signs[n] = 0; if (v < LM[offset2]) { @@ -732,9 +732,9 @@ void ImProcFunctions::MLmicrocontrast(float** luminance, int W, int H) } if (k == 1) { - contrast = sqrt(fabs(LM[offset + 1] - LM[offset - 1]) * fabs(LM[offset + 1] - LM[offset - 1]) + fabs(LM[offset + width] - LM[offset - width]) * fabs(LM[offset + width] - LM[offset - width])) / chmax; //for 3x3 - } else /* if (k==2) */ contrast = sqrt(fabs(LM[offset + 1] - LM[offset - 1]) * fabs(LM[offset + 1] - LM[offset - 1]) + fabs(LM[offset + width] - LM[offset - width]) * fabs(LM[offset + width] - LM[offset - width]) - + fabs(LM[offset + 2] - LM[offset - 2]) * fabs(LM[offset + 2] - LM[offset - 2]) + fabs(LM[offset + 2 * width] - LM[offset - 2 * width]) * fabs(LM[offset + 2 * width] - LM[offset - 2 * width])) / (2 * chmax); //for 5x5 + contrast = sqrt (fabs (LM[offset + 1] - LM[offset - 1]) * fabs (LM[offset + 1] - LM[offset - 1]) + fabs (LM[offset + width] - LM[offset - width]) * fabs (LM[offset + width] - LM[offset - width])) / chmax; //for 3x3 + } else /* if (k==2) */ contrast = sqrt (fabs (LM[offset + 1] - LM[offset - 1]) * fabs (LM[offset + 1] - LM[offset - 1]) + fabs (LM[offset + width] - LM[offset - width]) * fabs (LM[offset + width] - LM[offset - width]) + + fabs (LM[offset + 2] - LM[offset - 2]) * fabs (LM[offset + 2] - LM[offset - 2]) + fabs (LM[offset + 2 * width] - LM[offset - 2 * width]) * fabs (LM[offset + 2 * width] - LM[offset - 2 * width])) / (2 * chmax); //for 5x5 if (contrast > 1.0f) { contrast = 1.0f; @@ -742,34 +742,34 @@ void ImProcFunctions::MLmicrocontrast(float** luminance, int W, int H) //matrix 5x5 temp = luminance[j][i] / 327.68f; //begin 3x3 - temp += CLIREF(v - LM[offset - width - 1]) * sqrtf(2.0f) * s; - temp += CLIREF(v - LM[offset - width]) * s; - temp += CLIREF(v - LM[offset - width + 1]) * sqrtf(2.0f) * s; - temp += CLIREF(v - LM[offset - 1]) * s; - temp += CLIREF(v - LM[offset + 1]) * s; - temp += CLIREF(v - LM[offset + width - 1]) * sqrtf(2.0f) * s; - temp += CLIREF(v - LM[offset + width]) * s; - temp += CLIREF(v - LM[offset + width + 1]) * sqrtf(2.0f) * s; //end 3x3 + temp += CLIREF (v - LM[offset - width - 1]) * sqrtf (2.0f) * s; + temp += CLIREF (v - LM[offset - width]) * s; + temp += CLIREF (v - LM[offset - width + 1]) * sqrtf (2.0f) * s; + temp += CLIREF (v - LM[offset - 1]) * s; + temp += CLIREF (v - LM[offset + 1]) * s; + temp += CLIREF (v - LM[offset + width - 1]) * sqrtf (2.0f) * s; + temp += CLIREF (v - LM[offset + width]) * s; + temp += CLIREF (v - LM[offset + width + 1]) * sqrtf (2.0f) * s; //end 3x3 // add JD continue 5x5 if (k == 2) { - temp += 2.0f * CLIREF(v - LM[offset + 2 * width]) * s; - temp += 2.0f * CLIREF(v - LM[offset - 2 * width]) * s; - temp += 2.0f * CLIREF(v - LM[offset - 2 ]) * s; - temp += 2.0f * CLIREF(v - LM[offset + 2 ]) * s; + temp += 2.0f * CLIREF (v - LM[offset + 2 * width]) * s; + temp += 2.0f * CLIREF (v - LM[offset - 2 * width]) * s; + temp += 2.0f * CLIREF (v - LM[offset - 2 ]) * s; + temp += 2.0f * CLIREF (v - LM[offset + 2 ]) * s; - temp += 2.0f * CLIREF(v - LM[offset + 2 * width - 1]) * s * sqrtf(1.25f); // 1.25 = 1*1 + 0.5*0.5 - temp += 2.0f * CLIREF(v - LM[offset + 2 * width - 2]) * s * sqrtf(2.00f); - temp += 2.0f * CLIREF(v - LM[offset + 2 * width + 1]) * s * sqrtf(1.25f); - temp += 2.0f * CLIREF(v - LM[offset + 2 * width + 2]) * s * sqrtf(2.00f); - temp += 2.0f * CLIREF(v - LM[offset + width + 2]) * s * sqrtf(1.25f); - temp += 2.0f * CLIREF(v - LM[offset + width - 2]) * s * sqrtf(1.25f); - temp += 2.0f * CLIREF(v - LM[offset - 2 * width - 1]) * s * sqrtf(1.25f); - temp += 2.0f * CLIREF(v - LM[offset - 2 * width - 2]) * s * sqrtf(2.00f); - temp += 2.0f * CLIREF(v - LM[offset - 2 * width + 1]) * s * sqrtf(1.25f); - temp += 2.0f * CLIREF(v - LM[offset - 2 * width + 2]) * s * sqrtf(2.00f); - temp += 2.0f * CLIREF(v - LM[offset - width + 2]) * s * sqrtf(1.25f); - temp += 2.0f * CLIREF(v - LM[offset - width - 2]) * s * sqrtf(1.25f); + temp += 2.0f * CLIREF (v - LM[offset + 2 * width - 1]) * s * sqrtf (1.25f); // 1.25 = 1*1 + 0.5*0.5 + temp += 2.0f * CLIREF (v - LM[offset + 2 * width - 2]) * s * sqrtf (2.00f); + temp += 2.0f * CLIREF (v - LM[offset + 2 * width + 1]) * s * sqrtf (1.25f); + temp += 2.0f * CLIREF (v - LM[offset + 2 * width + 2]) * s * sqrtf (2.00f); + temp += 2.0f * CLIREF (v - LM[offset + width + 2]) * s * sqrtf (1.25f); + temp += 2.0f * CLIREF (v - LM[offset + width - 2]) * s * sqrtf (1.25f); + temp += 2.0f * CLIREF (v - LM[offset - 2 * width - 1]) * s * sqrtf (1.25f); + temp += 2.0f * CLIREF (v - LM[offset - 2 * width - 2]) * s * sqrtf (2.00f); + temp += 2.0f * CLIREF (v - LM[offset - 2 * width + 1]) * s * sqrtf (1.25f); + temp += 2.0f * CLIREF (v - LM[offset - 2 * width + 2]) * s * sqrtf (2.00f); + temp += 2.0f * CLIREF (v - LM[offset - width + 2]) * s * sqrtf (1.25f); + temp += 2.0f * CLIREF (v - LM[offset - width - 2]) * s * sqrtf (1.25f); } if (temp < 0.0f) { @@ -780,8 +780,8 @@ void ImProcFunctions::MLmicrocontrast(float** luminance, int W, int H) n = 0; - for(row = j - k; row <= j + k; row++) { - for(col = i - k, offset2 = row * width + col; col <= i + k; col++, offset2++) { + for (row = j - k; row <= j + k; row++) { + for (col = i - k, offset2 = row * width + col; col <= i + k; col++, offset2++) { if (((v < LM[offset2]) && (signs[n] > 0)) || ((v > LM[offset2]) && (signs[n] < 0))) { temp = v * 0.75f + LM[offset2] * 0.25f; // 0.75 0.25 } @@ -979,19 +979,19 @@ void ImProcFunctions::MLmicrocontrast(float** luminance, int W, int H) t2e.set(); if (settings->verbose) { - printf("Micro-contrast %d usec\n", t2e.etime(t1e)); + printf ("Micro-contrast %d usec\n", t2e.etime (t1e)); } } -void ImProcFunctions::MLmicrocontrast(LabImage* lab) +void ImProcFunctions::MLmicrocontrast (LabImage* lab) { - MLmicrocontrast(lab->L, lab->W, lab->H); + MLmicrocontrast (lab->L, lab->W, lab->H); } -void ImProcFunctions::MLmicrocontrastcam(CieImage* ncie) +void ImProcFunctions::MLmicrocontrastcam (CieImage* ncie) { - MLmicrocontrast(ncie->sh_p, ncie->W, ncie->H); + MLmicrocontrast (ncie->sh_p, ncie->W, ncie->H); } void ImProcFunctions::sharpeningcam (CieImage* ncie, float** b2) @@ -1046,12 +1046,12 @@ void ImProcFunctions::sharpeningcam (CieImage* ncie, float** b2) for (int j = 0; j < W; j++) { const float upperBound = 2000.f; // WARNING: Duplicated value, it's baaaaaad ! float diff = base[i][j] - b2[i][j]; - float delta = params->sharpening.threshold.multiply( - min(ABS(diff), upperBound), // X axis value = absolute value of the difference, truncated to the max value of this field + float delta = params->sharpening.threshold.multiply ( + min (ABS (diff), upperBound), // X axis value = absolute value of the difference, truncated to the max value of this field params->sharpening.amount * diff * 0.01f // Y axis max value ); - if(ncie->J_p[i][j] > 8.0f && ncie->J_p[i][j] < 92.0f) { + if (ncie->J_p[i][j] > 8.0f && ncie->J_p[i][j] < 92.0f) { ncie->sh_p[i][j] = ncie->sh_p[i][j] + delta; } } @@ -1062,7 +1062,7 @@ void ImProcFunctions::sharpeningcam (CieImage* ncie, float** b2) // make deep copy of ncie->sh_p ncieCopy = new float*[H]; - for( int i = 0; i < H; i++ ) { + for ( int i = 0; i < H; i++ ) { ncieCopy[i] = new float[W]; } @@ -1070,8 +1070,8 @@ void ImProcFunctions::sharpeningcam (CieImage* ncie, float** b2) #pragma omp parallel for #endif - for( int i = 0; i < H; i++ ) - for( int j = 0; j < W; j++ ) { + for ( int i = 0; i < H; i++ ) + for ( int j = 0; j < W; j++ ) { ncieCopy[i][j] = ncie->sh_p[i][j]; } @@ -1080,8 +1080,8 @@ void ImProcFunctions::sharpeningcam (CieImage* ncie, float** b2) sharpenHaloCtrl (ncie->sh_p, b2, base, W, H, params->sharpening); - if(ncieCopy) { - for( int i = 0; i < H; i++ ) { + if (ncieCopy) { + for ( int i = 0; i < H; i++ ) { delete[] ncieCopy[i]; } diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 04ba4966d..d01049774 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -85,16 +85,17 @@ float normn (float a, float b, int n) } } -void correct_distortion (const rtengine::LCPMapper *lcp, double &x, double &y, - int cx, int cy) + +void correct_distortion(const rtengine::LCPMapper *lcp, double &x, double &y, + int cx, int cy, double scale) { assert (lcp); x += cx; y += cy; - lcp->correctDistortion (x, y); - x -= cx; - y -= cy; + lcp->correctDistortion(x, y, scale); + x -= (cx * scale); + y -= (cy * scale); } } @@ -156,11 +157,14 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector &src, double x_d = src[i].x, y_d = src[i].y; if (pLCPMap && params->lensProf.useDist) { - correct_distortion (pLCPMap, x_d, y_d, 0, 0); + correct_distortion (pLCPMap, x_d, y_d, 0, 0, ascale); + } else { + x_d *= ascale; + y_d *= ascale; } - y_d = ascale * (y_d - h2); - x_d = ascale * (x_d - w2); + x_d += ascale * (0 - w2); // centering x coord & scale + y_d += ascale * (0 - h2); // centering y coord & scale if (needsPerspective()) { // horizontal perspective transformation @@ -390,7 +394,6 @@ static void calcGradientParams (int oW, int oH, const GradientParams& gradient, // division with extremely small numbers gp.transpose = true; gradient_angle += 0.5 * rtengine::RT_PI; - cosgrad = cos (gradient_angle); double gxc = gradient_center_x; gradient_center_x = 1.0 - gradient_center_y; gradient_center_y = gxc; @@ -799,11 +802,14 @@ void ImProcFunctions::transformHighQuality (Imagefloat* original, Imagefloat* tr double x_d = x, y_d = y; if (enableLCPDist) { - correct_distortion (pLCPMap, x_d, y_d, cx, cy); // must be first transform + correct_distortion(pLCPMap, x_d, y_d, cx, cy, ascale); // must be first transform + } else { + x_d *= ascale; + y_d *= ascale; } - x_d = ascale * (x_d + cx - w2); // centering x coord & scale - y_d = ascale * (y_d + cy - h2); // centering y coord & scale + x_d += ascale * (cx - w2); // centering x coord & scale + y_d += ascale * (cy - h2); // centering y coord & scale double vig_x_d = 0., vig_y_d = 0.; @@ -976,11 +982,14 @@ void ImProcFunctions::transformPreview (Imagefloat* original, Imagefloat* transf double x_d = x, y_d = y; if (pLCPMap && params->lensProf.useDist) { - correct_distortion (pLCPMap, x_d, y_d, cx, cy); // must be first transform + correct_distortion(pLCPMap, x_d, y_d, cx, cy, ascale); // must be first transform + } else { + x_d *= ascale; + y_d *= ascale; } - y_d = ascale * (y_d + cy - h2); // centering y coord & scale - x_d = ascale * (x_d + cx - w2); // centering x coord & scale + x_d += ascale * (cx - w2); // centering x coord & scale + y_d += ascale * (cy - h2); // centering y coord & scale double vig_x_d = 0., vig_y_d = 0.; diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index 3494c0874..3d0ac9182 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -140,7 +140,7 @@ struct cont_params { int wavNestedLevels = 1; -SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, LUTf &wavclCurve, bool wavcontlutili, int skip) +SSEFUNCTION void ImProcFunctions::ip_wavelet (LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, LUTf &wavclCurve, bool wavcontlutili, int skip) { @@ -149,7 +149,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int MunsellDebugInfo* MunsDebugInfo = new MunsellDebugInfo(); #endif TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params->icm.working); - double wip[3][3] = { + const double wip[3][3] = { {wiprof[0][0], wiprof[0][1], wiprof[0][2]}, {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, {wiprof[2][0], wiprof[2][1], wiprof[2][2]} @@ -158,28 +158,28 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int struct cont_params cp; cp.avoi = params->wavelet.avoid; - if(params->wavelet.Medgreinf == "more") { + if (params->wavelet.Medgreinf == "more") { cp.reinforce = 1; } - if(params->wavelet.Medgreinf == "none") { + if (params->wavelet.Medgreinf == "none") { cp.reinforce = 2; } - if(params->wavelet.Medgreinf == "less") { + if (params->wavelet.Medgreinf == "less") { cp.reinforce = 3; } - if(params->wavelet.NPmethod == "none") { + if (params->wavelet.NPmethod == "none") { cp.lip3 = false; } - if(params->wavelet.NPmethod == "low") { + if (params->wavelet.NPmethod == "low") { cp.lip3 = true; cp.neigh = 0; } - if(params->wavelet.NPmethod == "high") { + if (params->wavelet.NPmethod == "high") { cp.lip3 = true; cp.neigh = 1; } @@ -191,27 +191,27 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int cp.tonemap = false; cp.bam = false; - if(params->wavelet.tmrs == 0) { + if (params->wavelet.tmrs == 0) { cp.tonemap = false; } else { cp.tonemap = true; } - if(params->wavelet.TMmethod == "cont") { + if (params->wavelet.TMmethod == "cont") { cp.contmet = 1; - } else if(params->wavelet.TMmethod == "tm") { + } else if (params->wavelet.TMmethod == "tm") { cp.contmet = 2; } - if(params->wavelet.BAmethod != "none") { + if (params->wavelet.BAmethod != "none") { cp.bam = true; } - if(params->wavelet.BAmethod == "sli") { + if (params->wavelet.BAmethod == "sli") { cp.BAmet = 1; } - if(params->wavelet.BAmethod == "cur") { + if (params->wavelet.BAmethod == "cur") { cp.BAmet = 2; } @@ -225,15 +225,15 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int cp.toningena = params->wavelet.exptoning; cp.noiseena = params->wavelet.expnoise; - if(params->wavelet.Backmethod == "black") { + if (params->wavelet.Backmethod == "black") { cp.backm = 0; } - if(params->wavelet.Backmethod == "grey") { + if (params->wavelet.Backmethod == "grey") { cp.backm = 1; } - if(params->wavelet.Backmethod == "resid") { + if (params->wavelet.Backmethod == "resid") { cp.backm = 2; } @@ -245,7 +245,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int cp.edgsens = 60.f; cp.edgampl = 10.f; - if(cp.lipp) { + if (cp.lipp) { cp.edgsens = (float) params->wavelet.edgesensi; cp.edgampl = (float) params->wavelet.edgeampli; } @@ -256,7 +256,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int static const float scales[10] = {1.f, 2.f, 4.f, 8.f, 16.f, 32.f, 64.f, 128.f, 256.f, 512.f}; float scaleskip[10]; - for(int sc = 0; sc < 10; sc++) { + for (int sc = 0; sc < 10; sc++) { scaleskip[sc] = scales[sc] / skip; } @@ -266,23 +266,23 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int //int DaubLen = settings->daubech ? 8 : 6; int DaubLen; - if(params->wavelet.daubcoeffmethod == "2_") { + if (params->wavelet.daubcoeffmethod == "2_") { DaubLen = 4; } - if(params->wavelet.daubcoeffmethod == "4_") { + if (params->wavelet.daubcoeffmethod == "4_") { DaubLen = 6; } - if(params->wavelet.daubcoeffmethod == "6_") { + if (params->wavelet.daubcoeffmethod == "6_") { DaubLen = 8; } - if(params->wavelet.daubcoeffmethod == "10_") { + if (params->wavelet.daubcoeffmethod == "10_") { DaubLen = 12; } - if(params->wavelet.daubcoeffmethod == "14_") { + if (params->wavelet.daubcoeffmethod == "14_") { DaubLen = 16; } @@ -291,11 +291,11 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int // if(params->wavelet.CHSLmethod=="CU") cp.CHSLmet=2; cp.EDmet = 1; - if(params->wavelet.EDmethod == "SL") { + if (params->wavelet.EDmethod == "SL") { cp.EDmet = 1; } - if(params->wavelet.EDmethod == "CU") { + if (params->wavelet.EDmethod == "CU") { cp.EDmet = 2; } @@ -315,29 +315,29 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int cp.CHmet = 0; cp.HSmet = false; - if(params->wavelet.CHmethod == "with") { + if (params->wavelet.CHmethod == "with") { cp.CHmet = 1; } - if(params->wavelet.CHmethod == "link") { + if (params->wavelet.CHmethod == "link") { cp.CHmet = 2; } - if(params->wavelet.HSmethod == "with") { + if (params->wavelet.HSmethod == "with") { cp.HSmet = true; } - cp.strength = min(1.f, max(0.f, ((float)params->wavelet.strength / 100.f))); + cp.strength = min (1.f, max (0.f, ((float)params->wavelet.strength / 100.f))); - for(int m = 0; m < maxmul; m++) { + for (int m = 0; m < maxmul; m++) { cp.mulC[m] = waparams.ch[m]; } - if(waOpacityCurveRG) { + if (waOpacityCurveRG) { cp.opaRG = true; } - if(cp.opaRG) { + if (cp.opaRG) { cp.mulopaRG[0] = 200.f * (waOpacityCurveRG[0] - 0.5f); cp.mulopaRG[1] = 200.f * (waOpacityCurveRG[62] - 0.5f); cp.mulopaRG[2] = 200.f * (waOpacityCurveRG[125] - 0.5f); @@ -348,16 +348,16 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int cp.mulopaRG[7] = 200.f * (waOpacityCurveRG[438] - 0.5f); cp.mulopaRG[8] = 200.f * (waOpacityCurveRG[500] - 0.5f); } else { - for(int level = 0; level < 9; level++) { + for (int level = 0; level < 9; level++) { cp.mulopaRG[level] = 0.f; } } - if(waOpacityCurveBY) { + if (waOpacityCurveBY) { cp.opaBY = true; } - if(cp.opaBY) { + if (cp.opaBY) { cp.mulopaBY[0] = 200.f * (waOpacityCurveBY[0] - 0.5f); cp.mulopaBY[1] = 200.f * (waOpacityCurveBY[62] - 0.5f); cp.mulopaBY[2] = 200.f * (waOpacityCurveBY[125] - 0.5f); @@ -368,47 +368,47 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int cp.mulopaBY[7] = 200.f * (waOpacityCurveBY[438] - 0.5f); cp.mulopaBY[8] = 200.f * (waOpacityCurveBY[500] - 0.5f); } else { - for(int level = 0; level < 9; level++) { + for (int level = 0; level < 9; level++) { cp.mulopaBY[level] = 0.f; } } - if(wavCLVCcurve) { + if (wavCLVCcurve) { cp.edgcurv = true; } - if(waOpacityCurveWL) { + if (waOpacityCurveWL) { cp.diagcurv = true; } - for(int m = 0; m < maxmul; m++) { + for (int m = 0; m < maxmul; m++) { cp.mul[m] = waparams.c[m]; } cp.mul[9] = (float) waparams.sup; - for(int sc = 0; sc < 10; sc++) { //reduce strength if zoom < 100% for contrast - if(sc == 0) { - if(scaleskip[sc] < 1.f) { + for (int sc = 0; sc < 10; sc++) { //reduce strength if zoom < 100% for contrast + if (sc == 0) { + if (scaleskip[sc] < 1.f) { cp.mul[sc] *= (atten0 * scaleskip[sc]); } } else { - if(scaleskip[sc] < 1.f) { + if (scaleskip[sc] < 1.f) { cp.mul[sc] *= (atten123 * scaleskip[sc]); } } } // if(settings->verbose) printf("Wav mul 0=%f 1=%f 2=%f 3=%f 4=%f 5=%f 6=%f 7=%f 8=%f 9=%f\n",cp.mul[0],cp.mul[1],cp.mul[2],cp.mul[3],cp.mul[4],cp.mul[5],cp.mul[6],cp.mul[7],cp.mul[8],cp.mul[9]); - for(int sc = 0; sc < 9; sc++) { //reduce strength if zoom < 100% for chroma and tuning - if(sc == 0) { - if(scaleskip[sc] < 1.f) { + for (int sc = 0; sc < 9; sc++) { //reduce strength if zoom < 100% for chroma and tuning + if (sc == 0) { + if (scaleskip[sc] < 1.f) { cp.mulC[sc] *= (atten0 * scaleskip[sc]); cp.mulopaRG[sc] *= (atten0 * scaleskip[sc]); cp.mulopaBY[sc] *= (atten0 * scaleskip[sc]); } } else { - if(scaleskip[sc] < 1.f) { + if (scaleskip[sc] < 1.f) { cp.mulC[sc] *= (atten123 * scaleskip[sc]); cp.mulopaRG[sc] *= (atten123 * scaleskip[sc]); cp.mulopaBY[sc] *= (atten123 * scaleskip[sc]); @@ -428,88 +428,88 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int cp.chrores = waparams.reschro; //cp.hueres=waparams.reshue; cp.hueres = 2.f; - cp.th = float(waparams.thr); - cp.thH = float(waparams.thrH); + cp.th = float (waparams.thr); + cp.thH = float (waparams.thrH); cp.sky = waparams.sky; //skin - cp.b_l = static_cast(params->wavelet.hueskin.value[0]) / 100.0f; - cp.t_l = static_cast(params->wavelet.hueskin.value[1]) / 100.0f; - cp.b_r = static_cast(params->wavelet.hueskin.value[2]) / 100.0f; - cp.t_r = static_cast(params->wavelet.hueskin.value[3]) / 100.0f; + cp.b_l = static_cast (params->wavelet.hueskin.value[0]) / 100.0f; + cp.t_l = static_cast (params->wavelet.hueskin.value[1]) / 100.0f; + cp.b_r = static_cast (params->wavelet.hueskin.value[2]) / 100.0f; + cp.t_r = static_cast (params->wavelet.hueskin.value[3]) / 100.0f; - cp.b_ly = static_cast(params->wavelet.hueskin2.value[0]) / 100.0f; - cp.t_ly = static_cast(params->wavelet.hueskin2.value[1]) / 100.0f; - cp.b_ry = static_cast(params->wavelet.hueskin2.value[2]) / 100.0f; - cp.t_ry = static_cast(params->wavelet.hueskin2.value[3]) / 100.0f; + cp.b_ly = static_cast (params->wavelet.hueskin2.value[0]) / 100.0f; + cp.t_ly = static_cast (params->wavelet.hueskin2.value[1]) / 100.0f; + cp.b_ry = static_cast (params->wavelet.hueskin2.value[2]) / 100.0f; + cp.t_ry = static_cast (params->wavelet.hueskin2.value[3]) / 100.0f; cp.numlevH = params->wavelet.threshold; //shadows - cp.b_lsl = static_cast(params->wavelet.bllev.value[0]); - cp.t_lsl = static_cast(params->wavelet.bllev.value[1]); - cp.b_rsl = static_cast(params->wavelet.bllev.value[2]); - cp.t_rsl = static_cast(params->wavelet.bllev.value[3]); + cp.b_lsl = static_cast (params->wavelet.bllev.value[0]); + cp.t_lsl = static_cast (params->wavelet.bllev.value[1]); + cp.b_rsl = static_cast (params->wavelet.bllev.value[2]); + cp.t_rsl = static_cast (params->wavelet.bllev.value[3]); cp.numlevS = params->wavelet.threshold2; int maxlevS = 9 - cp.numlevH; - cp.numlevS = MIN(cp.numlevS, maxlevS); + cp.numlevS = MIN (cp.numlevS, maxlevS); //printf("levHigh=%d levShad=%d\n",cp.numlevH,cp.numlevS); //highlight - cp.b_lhl = static_cast(params->wavelet.hllev.value[0]); - cp.t_lhl = static_cast(params->wavelet.hllev.value[1]); - cp.b_rhl = static_cast(params->wavelet.hllev.value[2]); - cp.t_rhl = static_cast(params->wavelet.hllev.value[3]); + cp.b_lhl = static_cast (params->wavelet.hllev.value[0]); + cp.t_lhl = static_cast (params->wavelet.hllev.value[1]); + cp.b_rhl = static_cast (params->wavelet.hllev.value[2]); + cp.t_rhl = static_cast (params->wavelet.hllev.value[3]); //printf("BL=%f TL=%f BR=%f TR=%f\n",cp.b_lhl,cp.t_lhl,cp.b_rhl,cp.t_rhl); //pastel - cp.b_lpast = static_cast(params->wavelet.pastlev.value[0]); - cp.t_lpast = static_cast(params->wavelet.pastlev.value[1]); - cp.b_rpast = static_cast(params->wavelet.pastlev.value[2]); - cp.t_rpast = static_cast(params->wavelet.pastlev.value[3]); + cp.b_lpast = static_cast (params->wavelet.pastlev.value[0]); + cp.t_lpast = static_cast (params->wavelet.pastlev.value[1]); + cp.b_rpast = static_cast (params->wavelet.pastlev.value[2]); + cp.t_rpast = static_cast (params->wavelet.pastlev.value[3]); //saturated - cp.b_lsat = static_cast(params->wavelet.satlev.value[0]); - cp.t_lsat = static_cast(params->wavelet.satlev.value[1]); - cp.b_rsat = static_cast(params->wavelet.satlev.value[2]); - cp.t_rsat = static_cast(params->wavelet.satlev.value[3]); + cp.b_lsat = static_cast (params->wavelet.satlev.value[0]); + cp.t_lsat = static_cast (params->wavelet.satlev.value[1]); + cp.b_rsat = static_cast (params->wavelet.satlev.value[2]); + cp.t_rsat = static_cast (params->wavelet.satlev.value[3]); //edge local contrast - cp.edg_low = static_cast(params->wavelet.edgcont.value[0]); - cp.edg_mean = static_cast(params->wavelet.edgcont.value[1]); - cp.edg_max = static_cast(params->wavelet.edgcont.value[2]); - cp.edg_sd = static_cast(params->wavelet.edgcont.value[3]); + cp.edg_low = static_cast (params->wavelet.edgcont.value[0]); + cp.edg_mean = static_cast (params->wavelet.edgcont.value[1]); + cp.edg_max = static_cast (params->wavelet.edgcont.value[2]); + cp.edg_sd = static_cast (params->wavelet.edgcont.value[3]); //level noise - cp.lev0s = static_cast(params->wavelet.level0noise.value[0]); - cp.lev0n = static_cast(params->wavelet.level0noise.value[1]); - cp.lev1s = static_cast(params->wavelet.level1noise.value[0]); - cp.lev1n = static_cast(params->wavelet.level1noise.value[1]); - cp.lev2s = static_cast(params->wavelet.level2noise.value[0]); - cp.lev2n = static_cast(params->wavelet.level2noise.value[1]); - cp.lev3s = static_cast(params->wavelet.level3noise.value[0]); - cp.lev3n = static_cast(params->wavelet.level3noise.value[1]); + cp.lev0s = static_cast (params->wavelet.level0noise.value[0]); + cp.lev0n = static_cast (params->wavelet.level0noise.value[1]); + cp.lev1s = static_cast (params->wavelet.level1noise.value[0]); + cp.lev1n = static_cast (params->wavelet.level1noise.value[1]); + cp.lev2s = static_cast (params->wavelet.level2noise.value[0]); + cp.lev2n = static_cast (params->wavelet.level2noise.value[1]); + cp.lev3s = static_cast (params->wavelet.level3noise.value[0]); + cp.lev3n = static_cast (params->wavelet.level3noise.value[1]); cp.detectedge = params->wavelet.medianlev; //printf("low=%f mean=%f sd=%f max=%f\n",cp.edg_low,cp.edg_mean,cp.edg_sd,cp.edg_max); - int minwin = min(imwidth, imheight); + int minwin = min (imwidth, imheight); int maxlevelcrop = 9; - if(cp.mul[9] != 0) { + if (cp.mul[9] != 0) { maxlevelcrop = 10; } // adap maximum level wavelet to size of crop - if(minwin * skip < 1024) { + if (minwin * skip < 1024) { maxlevelcrop = 9; //sampling wavelet 512 } - if(minwin * skip < 512) { + if (minwin * skip < 512) { maxlevelcrop = 8; //sampling wavelet 256 } - if(minwin * skip < 256) { + if (minwin * skip < 256) { maxlevelcrop = 7; //sampling 128 } - if(minwin * skip < 128) { + if (minwin * skip < 128) { maxlevelcrop = 6; } - if(minwin < 64) { + if (minwin < 64) { maxlevelcrop = 5; } @@ -517,11 +517,11 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int int levwav = params->wavelet.thres; - if(levwav == 9 && cp.mul[9] != 0) { + if (levwav == 9 && cp.mul[9] != 0) { levwav = 10; } - levwav = min(maxlevelcrop, levwav); + levwav = min (maxlevelcrop, levwav); // determine number of levels to process. // for(levwav=min(maxlevelcrop,levwav);levwav>0;levwav--) @@ -529,7 +529,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int // if(cp.mul[levwav-1]!=0.f) // break; // I suppress this fonctionality ==> crash for level < 3 - if(levwav < 1) { + if (levwav < 1) { return; // nothing to do } @@ -539,11 +539,11 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int //output buffer int realtile; - if(params->wavelet.Tilesmethod == "big") { + if (params->wavelet.Tilesmethod == "big") { realtile = 22; } - if(params->wavelet.Tilesmethod == "lit") { + if (params->wavelet.Tilesmethod == "lit") { realtile = 12; } @@ -551,7 +551,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int int overlap = (int) tilesize * 0.125f; int numtiles_W, numtiles_H, tilewidth, tileheight, tileWskip, tileHskip; - if(params->wavelet.Tilesmethod == "full") { + if (params->wavelet.Tilesmethod == "full") { kall = 0; } @@ -560,10 +560,10 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int const int numtiles = numtiles_W * numtiles_H; LabImage * dsttmp; - if(numtiles == 1) { + if (numtiles == 1) { dsttmp = dst; } else { - dsttmp = new LabImage(imwidth, imheight); + dsttmp = new LabImage (imwidth, imheight); for (int n = 0; n < 3 * imwidth * imheight; n++) { dsttmp->data[n] = 0; @@ -572,26 +572,26 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int //now we have tile dimensions, overlaps //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - int minsizetile = min(tilewidth, tileheight); + int minsizetile = min (tilewidth, tileheight); int maxlev2 = 10; - if(minsizetile < 1024 && levwav == 10) { + if (minsizetile < 1024 && levwav == 10) { maxlev2 = 9; } - if(minsizetile < 512) { + if (minsizetile < 512) { maxlev2 = 8; } - if(minsizetile < 256) { + if (minsizetile < 256) { maxlev2 = 7; } - if(minsizetile < 128) { + if (minsizetile < 128) { maxlev2 = 6; } - levwav = min(maxlev2, levwav); + levwav = min (maxlev2, levwav); //printf("levwav = %d\n",levwav); @@ -600,33 +600,33 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int int maxnumberofthreadsforwavelet = 0; //reduce memory for big tile size - if(kall != 0) { - if(realtile <= 22) { + if (kall != 0) { + if (realtile <= 22) { maxnumberofthreadsforwavelet = 2; } - if(realtile <= 20) { + if (realtile <= 20) { maxnumberofthreadsforwavelet = 3; } - if(realtile <= 18) { + if (realtile <= 18) { maxnumberofthreadsforwavelet = 4; } - if(realtile <= 16) { + if (realtile <= 16) { maxnumberofthreadsforwavelet = 6; } - if(realtile <= 14) { + if (realtile <= 14) { maxnumberofthreadsforwavelet = 8; } //printf("maxNRT=%d\n",maxnumberofthreadsforwavelet); - if((maxnumberofthreadsforwavelet == 6 || maxnumberofthreadsforwavelet == 8) && levwav == 10) { + if ((maxnumberofthreadsforwavelet == 6 || maxnumberofthreadsforwavelet == 8) && levwav == 10) { maxnumberofthreadsforwavelet -= 2; } - if(levwav <= 7 && maxnumberofthreadsforwavelet == 8) { + if (levwav <= 7 && maxnumberofthreadsforwavelet == 8) { maxnumberofthreadsforwavelet = 0; } } @@ -635,35 +635,35 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int // Calculate number of tiles. If less than omp_get_max_threads(), then limit num_threads to number of tiles - if( options.rgbDenoiseThreadLimit > 0) { - maxnumberofthreadsforwavelet = min(max(options.rgbDenoiseThreadLimit / 2, 1), maxnumberofthreadsforwavelet); + if ( options.rgbDenoiseThreadLimit > 0) { + maxnumberofthreadsforwavelet = min (max (options.rgbDenoiseThreadLimit / 2, 1), maxnumberofthreadsforwavelet); } - numthreads = MIN(numtiles, omp_get_max_threads()); + numthreads = MIN (numtiles, omp_get_max_threads()); - if(maxnumberofthreadsforwavelet > 0) { - numthreads = MIN(numthreads, maxnumberofthreadsforwavelet); + if (maxnumberofthreadsforwavelet > 0) { + numthreads = MIN (numthreads, maxnumberofthreadsforwavelet); } #ifdef _RT_NESTED_OPENMP wavNestedLevels = omp_get_max_threads() / numthreads; bool oldNested = omp_get_nested(); - if(wavNestedLevels < 2) { + if (wavNestedLevels < 2) { wavNestedLevels = 1; } else { - omp_set_nested(true); + omp_set_nested (true); } - if(maxnumberofthreadsforwavelet > 0) - while(wavNestedLevels * numthreads > maxnumberofthreadsforwavelet) { + if (maxnumberofthreadsforwavelet > 0) + while (wavNestedLevels * numthreads > maxnumberofthreadsforwavelet) { wavNestedLevels--; } #endif - if(settings->verbose) { - printf("Ip Wavelet uses %d main thread(s) and up to %d nested thread(s) for each main thread\n", numthreads, wavNestedLevels); + if (settings->verbose) { + printf ("Ip Wavelet uses %d main thread(s) and up to %d nested thread(s) for each main thread\n", numthreads, wavNestedLevels); } #pragma omp parallel num_threads(numthreads) @@ -694,21 +694,21 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int for (int tiletop = 0; tiletop < imheight; tiletop += tileHskip) { for (int tileleft = 0; tileleft < imwidth ; tileleft += tileWskip) { - int tileright = MIN(imwidth, tileleft + tilewidth); - int tilebottom = MIN(imheight, tiletop + tileheight); + int tileright = MIN (imwidth, tileleft + tilewidth); + int tilebottom = MIN (imheight, tiletop + tileheight); int width = tileright - tileleft; int height = tilebottom - tiletop; LabImage * labco; float **Lold = nullptr; float *LoldBuffer = nullptr; - if(numtiles == 1) { // untiled processing => we can use output buffer for labco + if (numtiles == 1) { // untiled processing => we can use output buffer for labco labco = dst; - if(cp.avoi) { // we need a buffer to hold a copy of the L channel + if (cp.avoi) { // we need a buffer to hold a copy of the L channel Lold = new float*[tileheight]; LoldBuffer = new float[tilewidth * tileheight]; - memcpy(LoldBuffer, lab->L[0], tilewidth * tileheight * sizeof(float)); + memcpy (LoldBuffer, lab->L[0], tilewidth * tileheight * sizeof (float)); for (int i = 0; i < tileheight; i++) { Lold[i] = LoldBuffer + i * tilewidth; @@ -716,7 +716,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int } } else { - labco = new LabImage(width, height); + labco = new LabImage (width, height); Lold = lab->L; } @@ -728,22 +728,22 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int int i1 = i - tiletop; int j; #ifdef __SSE2__ - __m128 c327d68v = _mm_set1_ps(327.68f); + __m128 c327d68v = _mm_set1_ps (327.68f); __m128 av, bv, huev, chrov; for (j = tileleft; j < tileright - 3; j += 4) { int j1 = j - tileleft; - av = LVFU(lab->a[i][j]); - bv = LVFU(lab->b[i][j]); - huev = xatan2f(bv, av); - chrov = _mm_sqrt_ps(SQRV(av) + SQRV(bv)) / c327d68v; - _mm_storeu_ps(&varhue[i1][j1], huev); - _mm_storeu_ps(&varchro[i1][j1], chrov); + av = LVFU (lab->a[i][j]); + bv = LVFU (lab->b[i][j]); + huev = xatan2f (bv, av); + chrov = _mm_sqrt_ps (SQRV (av) + SQRV (bv)) / c327d68v; + _mm_storeu_ps (&varhue[i1][j1], huev); + _mm_storeu_ps (&varchro[i1][j1], chrov); - if(labco != lab) { - _mm_storeu_ps(&(labco->L[i1][j1]), LVFU(lab->L[i][j])); - _mm_storeu_ps(&(labco->a[i1][j1]), av); - _mm_storeu_ps(&(labco->b[i1][j1]), bv); + if (labco != lab) { + _mm_storeu_ps (& (labco->L[i1][j1]), LVFU (lab->L[i][j])); + _mm_storeu_ps (& (labco->a[i1][j1]), av); + _mm_storeu_ps (& (labco->b[i1][j1]), bv); } } @@ -755,10 +755,10 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int int j1 = j - tileleft; float a = lab->a[i][j]; float b = lab->b[i][j]; - varhue[i1][j1] = xatan2f(b, a); - varchro[i1][j1] = (sqrtf(a * a + b * b)) / 327.68f; + varhue[i1][j1] = xatan2f (b, a); + varchro[i1][j1] = (sqrtf (a * a + b * b)) / 327.68f; - if(labco != lab) { + if (labco != lab) { labco->L[i1][j1] = lab->L[i][j]; labco->a[i1][j1] = a; labco->b[i1][j1] = b; @@ -767,7 +767,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int } //to avoid artifacts in blue sky - if(params->wavelet.median) { + if (params->wavelet.median) { float** tmL; int wid = labco->W; int hei = labco->H; @@ -778,8 +778,8 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int tmL[i] = new float[wid]; } - for(int i = borderL; i < hei - borderL; i++ ) { - for(int j = borderL; j < wid - borderL; j++) { + for (int i = borderL; i < hei - borderL; i++ ) { + for (int j = borderL; j < wid - borderL; j++) { tmL[i][j] = labco->L[i][j]; } } @@ -790,14 +790,14 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int for (int i = 1; i < hei - 1; i++) { for (int j = 1; j < wid - 1; j++) { - if((varhue[i][j] < -1.3f && varhue[i][j] > - 2.5f) && (varchro[i][j] > 15.f && varchro[i][j] < 55.f) && labco->L[i][j] > 6000.f) { //blue sky + med3x3 ==> after for more effect use denoise - tmL[i][j] = median(labco->L[i][j] , labco->L[i - 1][j], labco->L[i + 1][j] , labco->L[i][j + 1], labco->L[i][j - 1], labco->L[i - 1][j - 1], labco->L[i - 1][j + 1], labco->L[i + 1][j - 1], labco->L[i + 1][j + 1]); //3x3 + if ((varhue[i][j] < -1.3f && varhue[i][j] > - 2.5f) && (varchro[i][j] > 15.f && varchro[i][j] < 55.f) && labco->L[i][j] > 6000.f) { //blue sky + med3x3 ==> after for more effect use denoise + tmL[i][j] = median (labco->L[i][j] , labco->L[i - 1][j], labco->L[i + 1][j] , labco->L[i][j + 1], labco->L[i][j - 1], labco->L[i - 1][j - 1], labco->L[i - 1][j + 1], labco->L[i + 1][j - 1], labco->L[i + 1][j + 1]); //3x3 } } } - for(int i = borderL; i < hei - borderL; i++ ) { - for(int j = borderL; j < wid - borderL; j++) { + for (int i = borderL; i < hei - borderL; i++ ) { + for (int j = borderL; j < wid - borderL; j++) { labco->L[i][j] = tmL[i][j]; } } @@ -810,9 +810,9 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int // end blue sky } - if(numtiles == 1) { + if (numtiles == 1) { // reduce the varhue array to get faster access in following processing and reduce peak memory usage - float temphue[(tilewidth + 1) / 2] ALIGNED64; + float temphue[ (tilewidth + 1) / 2] ALIGNED64; for (int i = 0; i < (tileheight + 1) / 2; i++) { for (int j = 0; j < (tilewidth + 1) / 2; j++) { @@ -820,11 +820,11 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int } delete [] varhue[i]; - varhue[i] = new float[(tilewidth + 1) / 2]; - memcpy(varhue[i], temphue, ((tilewidth + 1) / 2) * sizeof(float)); + varhue[i] = new float[ (tilewidth + 1) / 2]; + memcpy (varhue[i], temphue, ((tilewidth + 1) / 2) * sizeof (float)); } - for(int i = (tileheight + 1) / 2; i < tileheight; i++) { + for (int i = (tileheight + 1) / 2; i < tileheight; i++) { delete [] varhue[i]; varhue[i] = nullptr; } @@ -841,20 +841,20 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int int levwavL = levwav; bool ref0 = false; - if((cp.lev0s > 0.f || cp.lev1s > 0.f || cp.lev2s > 0.f || cp.lev3s > 0.f) && cp.noiseena) { + if ((cp.lev0s > 0.f || cp.lev1s > 0.f || cp.lev2s > 0.f || cp.lev3s > 0.f) && cp.noiseena) { ref0 = true; } // printf("LevwavL before: %d\n",levwavL); - if(cp.contrast == 0.f && !cp.tonemap && cp.conres == 0.f && cp.conresH == 0.f && cp.val == 0 && !ref0 && params->wavelet.CLmethod == "all") { // no processing of residual L or edge=> we probably can reduce the number of levels - while(levwavL > 0 && cp.mul[levwavL - 1] == 0.f) { // cp.mul[level] == 0.f means no changes to level + if (cp.contrast == 0.f && !cp.tonemap && cp.conres == 0.f && cp.conresH == 0.f && cp.val == 0 && !ref0 && params->wavelet.CLmethod == "all") { // no processing of residual L or edge=> we probably can reduce the number of levels + while (levwavL > 0 && cp.mul[levwavL - 1] == 0.f) { // cp.mul[level] == 0.f means no changes to level levwavL--; } } // printf("LevwavL after: %d\n",levwavL); // if(cp.noiseena){ - if(levwavL < 4 ) { + if (levwavL < 4 ) { levwavL = 4; //to allow edge => I always allocate 3 (4) levels..because if user select wavelet it is to do something !! } @@ -862,10 +862,10 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int // else { // if(levwavL < 3) levwavL=3;//to allow edge => I always allocate 3 (4) levels..because if user select wavelet it is to do something !! // } - if(levwavL > 0) { - wavelet_decomposition* Ldecomp = new wavelet_decomposition (labco->data, labco->W, labco->H, levwavL, 1, skip, max(1, wavNestedLevels), DaubLen ); + if (levwavL > 0) { + wavelet_decomposition* Ldecomp = new wavelet_decomposition (labco->data, labco->W, labco->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen ); - if(!Ldecomp->memoryAllocationFailed) { + if (!Ldecomp->memoryAllocationFailed) { float madL[8][3]; #ifdef _RT_NESTED_OPENMP @@ -874,58 +874,58 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int for (int lvl = 0; lvl < 4; lvl++) { for (int dir = 1; dir < 4; dir++) { - int Wlvl_L = Ldecomp->level_W(lvl); - int Hlvl_L = Ldecomp->level_H(lvl); + int Wlvl_L = Ldecomp->level_W (lvl); + int Hlvl_L = Ldecomp->level_H (lvl); - float ** WavCoeffs_L = Ldecomp->level_coeffs(lvl); + float ** WavCoeffs_L = Ldecomp->level_coeffs (lvl); - madL[lvl][dir - 1] = SQR(Mad(WavCoeffs_L[dir], Wlvl_L * Hlvl_L)); + madL[lvl][dir - 1] = SQR (Mad (WavCoeffs_L[dir], Wlvl_L * Hlvl_L)); } } int ind = 0; bool ref = false; - if((cp.lev0s > 0.f || cp.lev1s > 0.f || cp.lev2s > 0.f || cp.lev3s > 0.f) && cp.noiseena) { + if ((cp.lev0s > 0.f || cp.lev1s > 0.f || cp.lev2s > 0.f || cp.lev3s > 0.f) && cp.noiseena) { ref = true; } bool contr = false; - for(int f = 0; f < levwavL; f++) { - if(cp.mul[f] != 0.f) { + for (int f = 0; f < levwavL; f++) { + if (cp.mul[f] != 0.f) { contr = true; } } - if(cp.val > 0 || ref || contr) {//edge - Evaluate2(*Ldecomp, cp, ind, mean, meanN, sigma, sigmaN, MaxP, MaxN, madL); + if (cp.val > 0 || ref || contr) { //edge + Evaluate2 (*Ldecomp, cp, ind, mean, meanN, sigma, sigmaN, MaxP, MaxN, madL); } //init for edge and denoise float vari[4]; - vari[0] = 8.f * SQR((cp.lev0n / 125.0) * (1.0 + cp.lev0n / 25.0)); - vari[1] = 8.f * SQR((cp.lev1n / 125.0) * (1.0 + cp.lev1n / 25.0)); - vari[2] = 8.f * SQR((cp.lev2n / 125.0) * (1.0 + cp.lev2n / 25.0)); - vari[3] = 8.f * SQR((cp.lev3n / 125.0) * (1.0 + cp.lev3n / 25.0)); + vari[0] = 8.f * SQR ((cp.lev0n / 125.0) * (1.0 + cp.lev0n / 25.0)); + vari[1] = 8.f * SQR ((cp.lev1n / 125.0) * (1.0 + cp.lev1n / 25.0)); + vari[2] = 8.f * SQR ((cp.lev2n / 125.0) * (1.0 + cp.lev2n / 25.0)); + vari[3] = 8.f * SQR ((cp.lev3n / 125.0) * (1.0 + cp.lev3n / 25.0)); - if((cp.lev0n > 0.1f || cp.lev1n > 0.1f || cp.lev2n > 0.1f || cp.lev3n > 0.1f) && cp.noiseena) { + if ((cp.lev0n > 0.1f || cp.lev1n > 0.1f || cp.lev2n > 0.1f || cp.lev3n > 0.1f) && cp.noiseena) { int edge = 1; - vari[0] = max(0.0001f, vari[0]); - vari[1] = max(0.0001f, vari[1]); - vari[2] = max(0.0001f, vari[2]); - vari[3] = max(0.0001f, vari[3]); + vari[0] = max (0.0001f, vari[0]); + vari[1] = max (0.0001f, vari[1]); + vari[2] = max (0.0001f, vari[2]); + vari[3] = max (0.0001f, vari[3]); float* noisevarlum = nullptr; // we need a dummy to pass it to WaveletDenoiseAllL - WaveletDenoiseAllL(*Ldecomp, noisevarlum, madL, vari, edge, 1); + WaveletDenoiseAllL (*Ldecomp, noisevarlum, madL, vari, edge, 1); } ind = 1; //Flat curve for Contrast=f(H) in levels FlatCurve* ChCurve = nullptr;//curve C=f(H) bool Chutili = false; - ChCurve = new FlatCurve(params->wavelet.Chcurve); + ChCurve = new FlatCurve (params->wavelet.Chcurve); if (!ChCurve || ChCurve->isIdentity()) { if (ChCurve) { @@ -937,16 +937,16 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int } - WaveletcontAllL(labco, varhue, varchro, *Ldecomp, cp, skip, mean, meanN, sigma, sigmaN, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, waOpacityCurveWL, ChCurve, Chutili); + WaveletcontAllL (labco, varhue, varchro, *Ldecomp, cp, skip, mean, meanN, sigma, sigmaN, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, waOpacityCurveWL, ChCurve, Chutili); - if(cp.val > 0 || ref || contr || cp.diagcurv) {//edge - Evaluate2(*Ldecomp, cp, ind, mean, meanN, sigma, sigmaN, MaxP, MaxN, madL); + if (cp.val > 0 || ref || contr || cp.diagcurv) { //edge + Evaluate2 (*Ldecomp, cp, ind, mean, meanN, sigma, sigmaN, MaxP, MaxN, madL); } - WaveletcontAllLfinal(*Ldecomp, cp, mean, sigma, MaxP, waOpacityCurveWL); + WaveletcontAllLfinal (*Ldecomp, cp, mean, sigma, MaxP, waOpacityCurveWL); //Evaluate2(*Ldecomp, cp, ind, mean, meanN, sigma, sigmaN, MaxP, MaxN, madL); - Ldecomp->reconstruct(labco->data, cp.strength); + Ldecomp->reconstruct (labco->data, cp.strength); } delete Ldecomp; @@ -955,7 +955,7 @@ 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) bool hhutili = false; - hhCurve = new FlatCurve(params->wavelet.hhcurve); + hhCurve = new FlatCurve (params->wavelet.hhcurve); if (!hhCurve || hhCurve->isIdentity()) { if (hhCurve) { @@ -967,23 +967,23 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int } - if(!hhutili) {//always a or b + if (!hhutili) { //always a or b int levwava = levwav; // printf("Levwava before: %d\n",levwava); - if(cp.chrores == 0.f && params->wavelet.CLmethod == "all" && !cp.cbena) { // no processing of residual ab => we probably can reduce the number of levels - while(levwava > 0 && !cp.diag && (((cp.CHmet == 2 && (cp.chro == 0.f || cp.mul[levwava - 1] == 0.f )) || (cp.CHmet != 2 && (levwava == 10 || (!cp.curv || cp.mulC[levwava - 1] == 0.f))))) && (!cp.opaRG || levwava == 10 || (cp.opaRG && cp.mulopaRG[levwava - 1] == 0.f)) && ((levwava == 10 || (cp.CHSLmet == 1 && cp.mulC[levwava - 1] == 0.f)))) { + if (cp.chrores == 0.f && params->wavelet.CLmethod == "all" && !cp.cbena) { // no processing of residual ab => we probably can reduce the number of levels + while (levwava > 0 && !cp.diag && (((cp.CHmet == 2 && (cp.chro == 0.f || cp.mul[levwava - 1] == 0.f )) || (cp.CHmet != 2 && (levwava == 10 || (!cp.curv || cp.mulC[levwava - 1] == 0.f))))) && (!cp.opaRG || levwava == 10 || (cp.opaRG && cp.mulopaRG[levwava - 1] == 0.f)) && ((levwava == 10 || (cp.CHSLmet == 1 && cp.mulC[levwava - 1] == 0.f)))) { levwava--; } } //printf("Levwava after: %d\n",levwava); - if(levwava > 0) { - wavelet_decomposition* adecomp = new wavelet_decomposition (labco->data + datalen, labco->W, labco->H, levwava, 1, skip, max(1, wavNestedLevels), DaubLen ); + if (levwava > 0) { + wavelet_decomposition* adecomp = new wavelet_decomposition (labco->data + datalen, labco->W, labco->H, levwava, 1, skip, max (1, wavNestedLevels), DaubLen ); - if(!adecomp->memoryAllocationFailed) { - WaveletcontAllAB(labco, varhue, varchro, *adecomp, waOpacityCurveW, cp, true); - adecomp->reconstruct(labco->data + datalen, cp.strength); + if (!adecomp->memoryAllocationFailed) { + WaveletcontAllAB (labco, varhue, varchro, *adecomp, waOpacityCurveW, cp, true); + adecomp->reconstruct (labco->data + datalen, cp.strength); } delete adecomp; @@ -992,19 +992,19 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int int levwavb = levwav; //printf("Levwavb before: %d\n",levwavb); - if(cp.chrores == 0.f && params->wavelet.CLmethod == "all" && !cp.cbena) { // no processing of residual ab => we probably can reduce the number of levels - while(levwavb > 0 && !cp.diag && (((cp.CHmet == 2 && (cp.chro == 0.f || cp.mul[levwavb - 1] == 0.f )) || (cp.CHmet != 2 && (levwavb == 10 || (!cp.curv || cp.mulC[levwavb - 1] == 0.f))))) && (!cp.opaBY || levwavb == 10 || (cp.opaBY && cp.mulopaBY[levwavb - 1] == 0.f)) && ((levwavb == 10 || (cp.CHSLmet == 1 && cp.mulC[levwavb - 1] == 0.f)))) { + if (cp.chrores == 0.f && params->wavelet.CLmethod == "all" && !cp.cbena) { // no processing of residual ab => we probably can reduce the number of levels + while (levwavb > 0 && !cp.diag && (((cp.CHmet == 2 && (cp.chro == 0.f || cp.mul[levwavb - 1] == 0.f )) || (cp.CHmet != 2 && (levwavb == 10 || (!cp.curv || cp.mulC[levwavb - 1] == 0.f))))) && (!cp.opaBY || levwavb == 10 || (cp.opaBY && cp.mulopaBY[levwavb - 1] == 0.f)) && ((levwavb == 10 || (cp.CHSLmet == 1 && cp.mulC[levwavb - 1] == 0.f)))) { levwavb--; } } // printf("Levwavb after: %d\n",levwavb); - if(levwavb > 0) { - wavelet_decomposition* bdecomp = new wavelet_decomposition (labco->data + 2 * datalen, labco->W, labco->H, levwavb, 1, skip, max(1, wavNestedLevels), DaubLen ); + if (levwavb > 0) { + wavelet_decomposition* bdecomp = new wavelet_decomposition (labco->data + 2 * datalen, labco->W, labco->H, levwavb, 1, skip, max (1, wavNestedLevels), DaubLen ); - if(!bdecomp->memoryAllocationFailed) { - WaveletcontAllAB(labco, varhue, varchro, *bdecomp, waOpacityCurveW, cp, false); - bdecomp->reconstruct(labco->data + 2 * datalen, cp.strength); + if (!bdecomp->memoryAllocationFailed) { + WaveletcontAllAB (labco, varhue, varchro, *bdecomp, waOpacityCurveW, cp, false); + bdecomp->reconstruct (labco->data + 2 * datalen, cp.strength); } delete bdecomp; @@ -1013,24 +1013,24 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int int levwavab = levwav; // printf("Levwavab before: %d\n",levwavab); - if(cp.chrores == 0.f && !hhutili && params->wavelet.CLmethod == "all") { // no processing of residual ab => we probably can reduce the number of levels - while(levwavab > 0 && (((cp.CHmet == 2 && (cp.chro == 0.f || cp.mul[levwavab - 1] == 0.f )) || (cp.CHmet != 2 && (levwavab == 10 || (!cp.curv || cp.mulC[levwavab - 1] == 0.f))))) && (!cp.opaRG || levwavab == 10 || (cp.opaRG && cp.mulopaRG[levwavab - 1] == 0.f)) && ((levwavab == 10 || (cp.CHSLmet == 1 && cp.mulC[levwavab - 1] == 0.f)))) { + if (cp.chrores == 0.f && !hhutili && params->wavelet.CLmethod == "all") { // no processing of residual ab => we probably can reduce the number of levels + while (levwavab > 0 && (((cp.CHmet == 2 && (cp.chro == 0.f || cp.mul[levwavab - 1] == 0.f )) || (cp.CHmet != 2 && (levwavab == 10 || (!cp.curv || cp.mulC[levwavab - 1] == 0.f))))) && (!cp.opaRG || levwavab == 10 || (cp.opaRG && cp.mulopaRG[levwavab - 1] == 0.f)) && ((levwavab == 10 || (cp.CHSLmet == 1 && cp.mulC[levwavab - 1] == 0.f)))) { levwavab--; } } // printf("Levwavab after: %d\n",levwavab); - if(levwavab > 0) { - wavelet_decomposition* adecomp = new wavelet_decomposition (labco->data + datalen, labco->W, labco->H, levwavab, 1, skip, max(1, wavNestedLevels), DaubLen ); - wavelet_decomposition* bdecomp = new wavelet_decomposition (labco->data + 2 * datalen, labco->W, labco->H, levwavab, 1, skip, max(1, wavNestedLevels), DaubLen ); + if (levwavab > 0) { + wavelet_decomposition* adecomp = new wavelet_decomposition (labco->data + datalen, labco->W, labco->H, levwavab, 1, skip, max (1, wavNestedLevels), DaubLen ); + wavelet_decomposition* bdecomp = new wavelet_decomposition (labco->data + 2 * datalen, labco->W, labco->H, levwavab, 1, skip, max (1, wavNestedLevels), DaubLen ); - if(!adecomp->memoryAllocationFailed && !bdecomp->memoryAllocationFailed) { - WaveletcontAllAB(labco, varhue, varchro, *adecomp, waOpacityCurveW, cp, true); - WaveletcontAllAB(labco, varhue, varchro, *bdecomp, waOpacityCurveW, cp, false); - WaveletAandBAllAB(labco, varhue, varchro, *adecomp, *bdecomp, cp, waOpacityCurveW, hhCurve, hhutili ); + if (!adecomp->memoryAllocationFailed && !bdecomp->memoryAllocationFailed) { + WaveletcontAllAB (labco, varhue, varchro, *adecomp, waOpacityCurveW, cp, true); + WaveletcontAllAB (labco, varhue, varchro, *bdecomp, waOpacityCurveW, cp, false); + WaveletAandBAllAB (labco, varhue, varchro, *adecomp, *bdecomp, cp, waOpacityCurveW, hhCurve, hhutili ); - adecomp->reconstruct(labco->data + datalen, cp.strength); - bdecomp->reconstruct(labco->data + 2 * datalen, cp.strength); + adecomp->reconstruct (labco->data + datalen, cp.strength); + bdecomp->reconstruct (labco->data + 2 * datalen, cp.strength); } @@ -1043,12 +1043,12 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int delete hhCurve; } - if(numtiles > 1 || (numtiles == 1 /*&& cp.avoi*/)) {//in all case since I add contrast curve + if (numtiles > 1 || (numtiles == 1 /*&& cp.avoi*/)) { //in all case since I add contrast curve //calculate mask for feathering output tile overlaps float Vmask[height + overlap] ALIGNED16; float Hmask[width + overlap] ALIGNED16; - if(numtiles > 1) { + if (numtiles > 1) { for (int i = 0; i < height; i++) { Vmask[i] = 1; } @@ -1058,7 +1058,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int } for (int i = 0; i < overlap; i++) { - float mask = SQR(sin((rtengine::RT_PI * i) / (2 * overlap))); + float mask = SQR (sin ((rtengine::RT_PI * i) / (2 * overlap))); if (tiletop > 0) { Vmask[i] = mask; @@ -1094,37 +1094,37 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int float xBuffer[rowWidth] ALIGNED64; float yBuffer[rowWidth] ALIGNED64; - if(cp.avoi) { + if (cp.avoi) { int col; __m128 av, bv; __m128 cv, yv, xv; __m128 zerov = _mm_setzero_ps(); - __m128 onev = _mm_set1_ps(1.f); - __m128 c327d68v = _mm_set1_ps(327.68f); + __m128 onev = _mm_set1_ps (1.f); + __m128 c327d68v = _mm_set1_ps (327.68f); vmask xyMask; - for(col = 0; col < rowWidth - 3; col += 4) { - av = LVFU(labco->a[i1][col]); - bv = LVFU(labco->b[i1][col]); - STVF(atan2Buffer[col], xatan2f(bv, av)); + for (col = 0; col < rowWidth - 3; col += 4) { + av = LVFU (labco->a[i1][col]); + bv = LVFU (labco->b[i1][col]); + STVF (atan2Buffer[col], xatan2f (bv, av)); - cv = _mm_sqrt_ps(SQRV(av) + SQRV(bv)); + cv = _mm_sqrt_ps (SQRV (av) + SQRV (bv)); yv = av / cv; xv = bv / cv; - xyMask = vmaskf_eq(zerov, cv); - yv = vself(xyMask, onev, yv); - xv = vself(xyMask, zerov, xv); - STVF(yBuffer[col], yv); - STVF(xBuffer[col], xv); - STVF(chprovBuffer[col], cv / c327d68v); + xyMask = vmaskf_eq (zerov, cv); + yv = vself (xyMask, onev, yv); + xv = vself (xyMask, zerov, xv); + STVF (yBuffer[col], yv); + STVF (xBuffer[col], xv); + STVF (chprovBuffer[col], cv / c327d68v); } - for(; col < rowWidth; col++) { + for (; col < rowWidth; col++) { float a = labco->a[i1][col]; float b = labco->b[i1][col]; - atan2Buffer[col] = xatan2f(b, a); - float Chprov1 = sqrtf(SQR(a) + SQR(b)); + atan2Buffer[col] = xatan2f (b, a); + float Chprov1 = sqrtf (SQR (a) + SQR (b)); yBuffer[col] = (Chprov1 == 0.f) ? 1.f : a / Chprov1; xBuffer[col] = (Chprov1 == 0.f) ? 0.f : b / Chprov1; chprovBuffer[col] = Chprov1 / 327.68; @@ -1136,7 +1136,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int for (int j = tileleft; j < tileright; j++) { int j1 = j - tileleft; - if(cp.avoi) { //Gamut and Munsell + if (cp.avoi) { //Gamut and Munsell #ifdef __SSE2__ float HH = atan2Buffer[j1]; float Chprov1 = chprovBuffer[j1]; @@ -1146,8 +1146,8 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int #else a = labco->a[i1][j1]; b = labco->b[i1][j1]; - float HH = xatan2f(b, a); - float Chprov1 = sqrtf(SQR(a) + SQR(b)); + float HH = xatan2f (b, a); + float Chprov1 = sqrtf (SQR (a) + SQR (b)); float2 sincosv; sincosv.y = (Chprov1 == 0.0f) ? 1.f : a / (Chprov1); sincosv.x = (Chprov1 == 0.0f) ? 0.f : b / (Chprov1); @@ -1156,7 +1156,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int L = labco->L[i1][j1]; const float Lin = labco->L[i1][j1]; - if(wavclCurve && cp.finena) { + if (wavclCurve && cp.finena) { labco->L[i1][j1] = (0.5f * Lin + 1.5f * wavclCurve[Lin]) / 2.f; //apply contrast curve } @@ -1169,9 +1169,9 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int #ifdef _DEBUG bool neg = false; bool more_rgb = false; - Color::gamutLchonly(HH, sincosv, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly (HH, sincosv, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f, neg, more_rgb); #else - Color::gamutLchonly(HH, sincosv, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f); + Color::gamutLchonly (HH, sincosv, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f); #endif L = Lprov1 * 327.68f; @@ -1180,19 +1180,19 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int float correctionHue = 0.0f; // Munsell's correction float correctlum = 0.0f; Lprov1 = L / 327.68f; - float Chprov = sqrtf(SQR(a) + SQR(b)) / 327.68f; + float Chprov = sqrtf (SQR (a) + SQR (b)) / 327.68f; #ifdef _DEBUG - Color::AllMunsellLch(true, Lprov1, Lprov2, HH, Chprov, memChprov, correctionHue, correctlum, MunsDebugInfo); + Color::AllMunsellLch (true, Lprov1, Lprov2, HH, Chprov, memChprov, correctionHue, correctlum, MunsDebugInfo); #else - Color::AllMunsellLch(true, Lprov1, Lprov2, HH, Chprov, memChprov, correctionHue, correctlum); + Color::AllMunsellLch (true, Lprov1, Lprov2, HH, Chprov, memChprov, correctionHue, correctlum); #endif - if(correctionHue != 0.f || correctlum != 0.f) { // only calculate sin and cos if HH changed - if(fabs(correctionHue) < 0.015f) { + if (correctionHue != 0.f || correctlum != 0.f) { // only calculate sin and cos if HH changed + if (fabs (correctionHue) < 0.015f) { HH += correctlum; // correct only if correct Munsell chroma very little. } - sincosv = xsincosf(HH + correctionHue); + sincosv = xsincosf (HH + correctionHue); } a = 327.68f * Chprov * sincosv.y; // apply Munsell @@ -1201,7 +1201,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int L = labco->L[i1][j1]; const float Lin = labco->L[i1][j1]; - if(wavclCurve && cp.finena) { + if (wavclCurve && cp.finena) { labco->L[i1][j1] = (0.5f * Lin + 1.5f * wavclCurve[Lin]) / 2.f; //apply contrast curve } @@ -1210,7 +1210,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int b = labco->b[i1][j1]; } - if(numtiles > 1) { + if (numtiles > 1) { float factor = Vmask[i1] * Hmask[j1]; dsttmp->L[i][j] += factor * L; dsttmp->a[i][j] += factor * a; @@ -1225,19 +1225,19 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int } } - if(LoldBuffer != nullptr) { + if (LoldBuffer != nullptr) { delete [] LoldBuffer; delete [] Lold; } - if(numtiles > 1) { + if (numtiles > 1) { delete labco; } } } for (int i = 0; i < tileheight; i++) - if(varhue[i] != nullptr) { + if (varhue[i] != nullptr) { delete [] varhue[i]; } @@ -1256,11 +1256,11 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int } #ifdef _RT_NESTED_OPENMP - omp_set_nested(oldNested); + omp_set_nested (oldNested); #endif - if(numtiles > 1) { - dst->CopyFrom(dsttmp); + if (numtiles > 1) { + dst->CopyFrom (dsttmp); delete dsttmp; } @@ -1271,7 +1271,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int #undef offset #undef epsilon -void ImProcFunctions::Aver( float * RESTRICT DataList, int datalen, float &averagePlus, float &averageNeg, float &max, float &min) +void ImProcFunctions::Aver ( float * RESTRICT DataList, int datalen, float &averagePlus, float &averageNeg, float &max, float &min) { //find absolute mean @@ -1290,19 +1290,19 @@ void ImProcFunctions::Aver( float * RESTRICT DataList, int datalen, float &aver #pragma omp for reduction(+:averaP,averaN,countP,countN) nowait #endif - for(int i = 0; i < datalen; i++) { - if(DataList[i] >= thres) { + for (int i = 0; i < datalen; i++) { + if (DataList[i] >= thres) { averaP += DataList[i]; - if(DataList[i] > lmax) { + if (DataList[i] > lmax) { lmax = DataList[i]; } countP++; - } else if(DataList[i] < -thres) { + } else if (DataList[i] < -thres) { averaN += DataList[i]; - if(DataList[i] < lmin) { + if (DataList[i] < lmin) { lmin = DataList[i]; } @@ -1319,13 +1319,13 @@ void ImProcFunctions::Aver( float * RESTRICT DataList, int datalen, float &aver } } - if(countP > 0) { + if (countP > 0) { averagePlus = averaP / countP; } else { averagePlus = 0; } - if(countN > 0) { + if (countN > 0) { averageNeg = averaN / countN; } else { averageNeg = 0; @@ -1334,7 +1334,7 @@ void ImProcFunctions::Aver( float * RESTRICT DataList, int datalen, float &aver } -void ImProcFunctions::Sigma( float * RESTRICT DataList, int datalen, float averagePlus, float averageNeg, float &sigmaPlus, float &sigmaNeg) +void ImProcFunctions::Sigma ( float * RESTRICT DataList, int datalen, float averagePlus, float averageNeg, float &sigmaPlus, float &sigmaNeg) { int countP = 0, countN = 0; float variP = 0.f, variN = 0.f; @@ -1344,44 +1344,44 @@ void ImProcFunctions::Sigma( float * RESTRICT DataList, int datalen, float aver #pragma omp parallel for reduction(+:variP,variN,countP,countN) num_threads(wavNestedLevels) if(wavNestedLevels>1) #endif - for(int i = 0; i < datalen; i++) { - if(DataList[i] >= thres) { - variP += SQR(DataList[i] - averagePlus); + for (int i = 0; i < datalen; i++) { + if (DataList[i] >= thres) { + variP += SQR (DataList[i] - averagePlus); countP++; - } else if(DataList[i] <= -thres) { - variN += SQR(DataList[i] - averageNeg); + } else if (DataList[i] <= -thres) { + variN += SQR (DataList[i] - averageNeg); countN++; } } - if(countP > 0) { - sigmaPlus = sqrt(variP / countP); + if (countP > 0) { + sigmaPlus = sqrt (variP / countP); } else { sigmaPlus = 0; } - if(countN > 0) { - sigmaNeg = sqrt(variN / countN); + if (countN > 0) { + sigmaNeg = sqrt (variN / countN); } else { sigmaNeg = 0; } } -void ImProcFunctions::Evaluate2(wavelet_decomposition &WaveletCoeffs_L, - const struct cont_params& cp, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float madL[8][3]) +void ImProcFunctions::Evaluate2 (wavelet_decomposition &WaveletCoeffs_L, + const struct cont_params& cp, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float madL[8][3]) { //StopWatch Stop1("Evaluate2"); int maxlvl = WaveletCoeffs_L.maxlevel(); for (int lvl = 0; lvl < maxlvl; lvl++) { - int Wlvl_L = WaveletCoeffs_L.level_W(lvl); - int Hlvl_L = WaveletCoeffs_L.level_H(lvl); + int Wlvl_L = WaveletCoeffs_L.level_W (lvl); + int Hlvl_L = WaveletCoeffs_L.level_H (lvl); - int skip_L = WaveletCoeffs_L.level_stride(lvl); + int skip_L = WaveletCoeffs_L.level_stride (lvl); - float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs(lvl); + float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs (lvl); Eval2 (WavCoeffs_L, lvl, cp, Wlvl_L, Hlvl_L, skip_L, ind, mean, meanN, sigma, sigmaN, MaxP, MaxN, madL[lvl]); } @@ -1397,8 +1397,8 @@ void ImProcFunctions::Eval2 (float ** WavCoeffs_L, int level, const struct cont float AvL, AvN, SL, SN, maxLP, maxLN; for (int dir = 1; dir < 4; dir++) { - Aver(WavCoeffs_L[dir], W_L * H_L, avLP[dir], avLN[dir], maxL[dir], minL[dir]); - Sigma(WavCoeffs_L[dir], W_L * H_L, avLP[dir], avLN[dir], sigP[dir], sigN[dir]); + Aver (WavCoeffs_L[dir], W_L * H_L, avLP[dir], avLN[dir], maxL[dir], minL[dir]); + Sigma (WavCoeffs_L[dir], W_L * H_L, avLP[dir], avLN[dir], sigP[dir], sigN[dir]); } AvL = 0.f; @@ -1432,15 +1432,15 @@ void ImProcFunctions::Eval2 (float ** WavCoeffs_L, int level, const struct cont MaxN[level] = maxLN; } -float *ImProcFunctions::ContrastDR(float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Contrast) +float *ImProcFunctions::ContrastDR (float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Contrast) { int n = W_L * H_L; - if(Contrast == nullptr) { + if (Contrast == nullptr) { Contrast = new float[n]; } - memcpy(Contrast, Source, n * sizeof(float)); + memcpy (Contrast, Source, n * sizeof (float)); #ifdef _RT_NESTED_OPENMP #pragma omp parallel for #endif @@ -1452,7 +1452,7 @@ float *ImProcFunctions::ContrastDR(float *Source, int skip, struct cont_params & return Contrast; } -SSEFUNCTION float *ImProcFunctions::CompressDR(float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Compressed) +SSEFUNCTION float *ImProcFunctions::CompressDR (float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Compressed) { const float eps = 0.000001f; @@ -1463,18 +1463,18 @@ SSEFUNCTION float *ImProcFunctions::CompressDR(float *Source, int skip, struct c #pragma omp parallel #endif { - __m128 epsv = _mm_set1_ps( eps ); + __m128 epsv = _mm_set1_ps ( eps ); #ifdef _RT_NESTED_OPENMP #pragma omp for #endif - for(int ii = 0; ii < n - 3; ii += 4) { - _mm_storeu_ps( &Source[ii], xlogf(LVFU(Source[ii]) + epsv)); + for (int ii = 0; ii < n - 3; ii += 4) { + _mm_storeu_ps ( &Source[ii], xlogf (LVFU (Source[ii]) + epsv)); } } - for(int ii = n - (n % 4); ii < n; ii++) { - Source[ii] = xlogf(Source[ii] + eps); + for (int ii = n - (n % 4); ii < n; ii++) { + Source[ii] = xlogf (Source[ii] + eps); } #else @@ -1482,31 +1482,31 @@ SSEFUNCTION float *ImProcFunctions::CompressDR(float *Source, int skip, struct c #pragma omp parallel for #endif - for(int ii = 0; ii < n; ii++) { - Source[ii] = xlogf(Source[ii] + eps); + for (int ii = 0; ii < n; ii++) { + Source[ii] = xlogf (Source[ii] + eps); } #endif - float *ucr = ContrastDR(Source, skip, cp, W_L, H_L, Compression, DetailBoost, max0, min0, ave, ah, bh, al, bl, factorx); + float *ucr = ContrastDR (Source, skip, cp, W_L, H_L, Compression, DetailBoost, max0, min0, ave, ah, bh, al, bl, factorx); - if(Compressed == nullptr) { + if (Compressed == nullptr) { Compressed = ucr; } float temp; - if(DetailBoost > 0.f && DetailBoost < 0.05f ) { - float betemp = expf(-(2.f - DetailBoost + 0.694f)) - 1.f; //0.694 = log(2) - temp = 1.2f * xlogf( -betemp); + if (DetailBoost > 0.f && DetailBoost < 0.05f ) { + float betemp = expf (- (2.f - DetailBoost + 0.694f)) - 1.f; //0.694 = log(2) + temp = 1.2f * xlogf ( -betemp); temp /= 20.f; - } else if(DetailBoost >= 0.05f && DetailBoost < 0.25f ) { - float betemp = expf(-(2.f - DetailBoost + 0.694f)) - 1.f; //0.694 = log(2) - temp = 1.2f * xlogf( -betemp); + } else if (DetailBoost >= 0.05f && DetailBoost < 0.25f ) { + float betemp = expf (- (2.f - DetailBoost + 0.694f)) - 1.f; //0.694 = log(2) + temp = 1.2f * xlogf ( -betemp); temp /= (-75.f * DetailBoost + 23.75f); - } else if(DetailBoost >= 0.25f) { - float betemp = expf(-(2.f - DetailBoost + 0.694f)) - 1.f; //0.694 = log(2) - temp = 1.2f * xlogf( -betemp); + } else if (DetailBoost >= 0.25f) { + float betemp = expf (- (2.f - DetailBoost + 0.694f)) - 1.f; //0.694 = log(2) + temp = 1.2f * xlogf ( -betemp); temp /= (-2.f * DetailBoost + 5.5f); } @@ -1520,26 +1520,26 @@ SSEFUNCTION float *ImProcFunctions::CompressDR(float *Source, int skip, struct c #endif { __m128 cev, uev, sourcev; - __m128 epsv = _mm_set1_ps( eps ); - __m128 DetailBoostv = _mm_set1_ps( DetailBoost ); - __m128 tempv = _mm_set1_ps( temp ); + __m128 epsv = _mm_set1_ps ( eps ); + __m128 DetailBoostv = _mm_set1_ps ( DetailBoost ); + __m128 tempv = _mm_set1_ps ( temp ); #ifdef _RT_NESTED_OPENMP #pragma omp for #endif - for(int i = 0; i < n - 3; i += 4) { - cev = xexpf(LVFU(Source[i]) + LVFU(ucr[i]) * (tempv)) - epsv; - uev = xexpf(LVFU(ucr[i])) - epsv; - sourcev = xexpf(LVFU(Source[i])) - epsv; - _mm_storeu_ps( &Source[i], sourcev); - _mm_storeu_ps( &Compressed[i], cev + DetailBoostv * (sourcev - uev) ); + for (int i = 0; i < n - 3; i += 4) { + cev = xexpf (LVFU (Source[i]) + LVFU (ucr[i]) * (tempv)) - epsv; + uev = xexpf (LVFU (ucr[i])) - epsv; + sourcev = xexpf (LVFU (Source[i])) - epsv; + _mm_storeu_ps ( &Source[i], sourcev); + _mm_storeu_ps ( &Compressed[i], cev + DetailBoostv * (sourcev - uev) ); } } - for(int i = n - (n % 4); i < n; i++) { - float ce = xexpf(Source[i] + ucr[i] * (temp)) - eps; - float ue = xexpf(ucr[i]) - eps; - Source[i] = xexpf(Source[i]) - eps; + for (int i = n - (n % 4); i < n; i++) { + float ce = xexpf (Source[i] + ucr[i] * (temp)) - eps; + float ue = xexpf (ucr[i]) - eps; + Source[i] = xexpf (Source[i]) - eps; Compressed[i] = ce + DetailBoost * (Source[i] - ue); } @@ -1548,16 +1548,16 @@ SSEFUNCTION float *ImProcFunctions::CompressDR(float *Source, int skip, struct c #pragma omp parallel for #endif - for(int i = 0; i < n; i++) { - float ce = xexpf(Source[i] + ucr[i] * (temp)) - eps; - float ue = xexpf(ucr[i]) - eps; - Source[i] = xexpf(Source[i]) - eps; + for (int i = 0; i < n; i++) { + float ce = xexpf (Source[i] + ucr[i] * (temp)) - eps; + float ue = xexpf (ucr[i]) - eps; + Source[i] = xexpf (Source[i]) - eps; Compressed[i] = ce + DetailBoost * (Source[i] - ue); } #endif - if(Compressed != ucr) { + if (Compressed != ucr) { delete[] ucr; } @@ -1566,13 +1566,13 @@ SSEFUNCTION float *ImProcFunctions::CompressDR(float *Source, int skip, struct c } -void ImProcFunctions::ContrastResid(float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params &cp, int W_L, int H_L, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx) +void ImProcFunctions::ContrastResid (float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params &cp, int W_L, int H_L, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx) { float stren = cp.tmstrength; float gamm = params->wavelet.gamma; cp.TMmeth = 2; //default after testing - if(cp.TMmeth == 1) { + if (cp.TMmeth == 1) { min0 = 0.0f; max0 = 32768.f; } else if (cp.TMmeth == 2) { @@ -1583,27 +1583,27 @@ void ImProcFunctions::ContrastResid(float * WavCoeffs_L0, unsigned int Iterates #pragma omp parallel for #endif - for(int i = 0; i < W_L * H_L; i++) { + for (int i = 0; i < W_L * H_L; i++) { WavCoeffs_L0[i] = (WavCoeffs_L0[i] - min0) / max0; WavCoeffs_L0[i] *= gamm; } - float Compression = expf(-stren); //This modification turns numbers symmetric around 0 into exponents. + float Compression = expf (-stren); //This modification turns numbers symmetric around 0 into exponents. float DetailBoost = stren; - if(stren < 0.0f) { + if (stren < 0.0f) { DetailBoost = 0.0f; //Go with effect of exponent only if uncompressing. } - CompressDR(WavCoeffs_L0, skip, cp, W_L, H_L, Compression, DetailBoost, max0, min0, ave, ah, bh, al, bl, factorx, WavCoeffs_L0); + CompressDR (WavCoeffs_L0, skip, cp, W_L, H_L, Compression, DetailBoost, max0, min0, ave, ah, bh, al, bl, factorx, WavCoeffs_L0); #ifdef _RT_NESTED_OPENMP #pragma omp parallel for // removed schedule(dynamic,10) #endif - for(int ii = 0; ii < W_L * H_L; ii++) { + for (int ii = 0; ii < W_L * H_L; ii++) { WavCoeffs_L0[ii] = WavCoeffs_L0[ii] * max0 * (1.f / gamm) + min0; } } @@ -1611,7 +1611,7 @@ void ImProcFunctions::ContrastResid(float * WavCoeffs_L0, unsigned int Iterates -void ImProcFunctions::EPDToneMapResid(float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params& cp, int W_L, int H_L, float max0, float min0) +void ImProcFunctions::EPDToneMapResid (float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params& cp, int W_L, int H_L, float max0, float min0) { @@ -1620,10 +1620,10 @@ void ImProcFunctions::EPDToneMapResid(float * WavCoeffs_L0, unsigned int Iterat float sca = params->epd.scale; float gamm = params->wavelet.gamma; float rew = params->epd.reweightingIterates; - EdgePreservingDecomposition epd2(W_L, H_L); + EdgePreservingDecomposition epd2 (W_L, H_L); cp.TMmeth = 2; //default after testing - if(cp.TMmeth == 1) { + if (cp.TMmeth == 1) { min0 = 0.0f; max0 = 32768.f; } else if (cp.TMmeth == 2) { @@ -1635,58 +1635,58 @@ void ImProcFunctions::EPDToneMapResid(float * WavCoeffs_L0, unsigned int Iterat #pragma omp parallel for #endif - for(int i = 0; i < W_L * H_L; i++) { + for (int i = 0; i < W_L * H_L; i++) { WavCoeffs_L0[i] = (WavCoeffs_L0[i] - min0) / max0; WavCoeffs_L0[i] *= gamm; } - float Compression = expf(-stren); //This modification turns numbers symmetric around 0 into exponents. + float Compression = expf (-stren); //This modification turns numbers symmetric around 0 into exponents. float DetailBoost = stren; - if(stren < 0.0f) { + if (stren < 0.0f) { DetailBoost = 0.0f; //Go with effect of exponent only if uncompressing. } //Auto select number of iterates. Note that p->EdgeStopping = 0 makes a Gaussian blur. - if(Iterates == 0) { - Iterates = (unsigned int)(edgest * 15.0f); + if (Iterates == 0) { + Iterates = (unsigned int) (edgest * 15.0f); } - 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, WavCoeffs_L0); //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. #ifdef _RT_NESTED_OPENMP #pragma omp parallel for // removed schedule(dynamic,10) #endif - for(int ii = 0; ii < W_L * H_L; ii++) { + for (int ii = 0; ii < W_L * H_L; ii++) { WavCoeffs_L0[ii] = WavCoeffs_L0[ii] * max0 * (1.f / gamm) + min0; } } -void ImProcFunctions::WaveletcontAllLfinal(wavelet_decomposition &WaveletCoeffs_L, struct cont_params &cp, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL) +void ImProcFunctions::WaveletcontAllLfinal (wavelet_decomposition &WaveletCoeffs_L, struct cont_params &cp, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL) { int maxlvl = WaveletCoeffs_L.maxlevel(); float * WavCoeffs_L0 = WaveletCoeffs_L.coeff0; for (int dir = 1; dir < 4; dir++) { for (int lvl = 0; lvl < maxlvl; lvl++) { - int Wlvl_L = WaveletCoeffs_L.level_W(lvl); - int Hlvl_L = WaveletCoeffs_L.level_H(lvl); - float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs(lvl); + int Wlvl_L = WaveletCoeffs_L.level_W (lvl); + int Hlvl_L = WaveletCoeffs_L.level_H (lvl); + float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs (lvl); finalContAllL (WavCoeffs_L, WavCoeffs_L0, lvl, dir, cp, Wlvl_L, Hlvl_L, mean, sigma, MaxP, waOpacityCurveWL); } } } -void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_L, - struct cont_params &cp, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, FlatCurve* ChCurve, bool Chutili) +void ImProcFunctions::WaveletcontAllL (LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_L, + struct cont_params &cp, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, FlatCurve* ChCurve, bool Chutili) { int maxlvl = WaveletCoeffs_L.maxlevel(); - int W_L = WaveletCoeffs_L.level_W(0); - int H_L = WaveletCoeffs_L.level_H(0); + int W_L = WaveletCoeffs_L.level_W (0); + int H_L = WaveletCoeffs_L.level_H (0); float * WavCoeffs_L0 = WaveletCoeffs_L.coeff0; float maxh = 2.5f; //amplification contrast above mean @@ -1698,7 +1698,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * float max0 = 0.f; float min0 = FLT_MAX; - if(contrast != 0.f || (cp.tonemap && cp.resena)) { // contrast = 0.f means that all will be multiplied by 1.f, so we can skip this step + if (contrast != 0.f || (cp.tonemap && cp.resena)) { // contrast = 0.f means that all will be multiplied by 1.f, so we can skip this step #ifdef _RT_NESTED_OPENMP #pragma omp parallel for reduction(+:avedbl) num_threads(wavNestedLevels) if(wavNestedLevels>1) #endif @@ -1718,12 +1718,12 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * #pragma omp for #endif - for(int i = 0; i < W_L * H_L; i++) { - if(WavCoeffs_L0[i] < lminL) { + for (int i = 0; i < W_L * H_L; i++) { + if (WavCoeffs_L0[i] < lminL) { lminL = WavCoeffs_L0[i]; } - if(WavCoeffs_L0[i] > lmaxL) { + if (WavCoeffs_L0[i] > lmaxL) { lmaxL = WavCoeffs_L0[i]; } @@ -1733,11 +1733,11 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * #pragma omp critical #endif { - if(lminL < min0) { + if (lminL < min0) { min0 = lminL; } - if(lmaxL > max0) { + if (lmaxL > max0) { max0 = lmaxL; } } @@ -1749,9 +1749,9 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * // printf("MAXmax0=%f MINmin0=%f\n",max0,min0); //tone mapping - if(cp.tonemap && cp.contmet == 2 && cp.resena) { + if (cp.tonemap && cp.contmet == 2 && cp.resena) { //iterate = 5 - EPDToneMapResid(WavCoeffs_L0, 5, skip, cp, W_L, H_L, max0, min0); + EPDToneMapResid (WavCoeffs_L0, 5, skip, cp, W_L, H_L, max0, min0); } @@ -1760,7 +1760,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * max0 /= 327.68f; min0 /= 327.68f; - float ave = avedbl / (double)(W_L * H_L); + float ave = avedbl / (double) (W_L * H_L); float av = ave / 327.68f; float ah = (multH - 1.f) / (av - max0); // float bh = 1.f - max0 * ah; @@ -1774,7 +1774,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * float *koeLibuffer = nullptr; - for(int y = 0; y < 12; y++) { + for (int y = 0; y < 12; y++) { maxkoeLi[y] = 0.f; //9 } @@ -1784,7 +1784,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * koeLi[i] = &koeLibuffer[i * W_L * H_L]; } - for(int j = 0; j < 12; j++) //9 + for (int j = 0; j < 12; j++) //9 for (int i = 0; i < W_L * H_L; i++) { koeLi[j][i] = 0.f; } @@ -1793,17 +1793,17 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * #pragma omp parallel num_threads(wavNestedLevels) if(wavNestedLevels>1) #endif { - if(contrast != 0.f && cp.resena) { // contrast = 0.f means that all will be multiplied by 1.f, so we can skip this step + if (contrast != 0.f && cp.resena) { // contrast = 0.f means that all will be multiplied by 1.f, so we can skip this step { #ifdef _RT_NESTED_OPENMP #pragma omp for #endif for (int i = 0; i < W_L * H_L; i++) { //contrast - if(WavCoeffs_L0[i] < 32768.f) { + if (WavCoeffs_L0[i] < 32768.f) { float prov; - if( WavCoeffs_L0[i] > ave) { + if ( WavCoeffs_L0[i] > ave) { float kh = ah * (WavCoeffs_L0[i] / 327.68f) + bh; prov = WavCoeffs_L0[i]; WavCoeffs_L0[i] = ave + kh * (WavCoeffs_L0[i] - ave); @@ -1821,20 +1821,20 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * } } - if(cp.tonemap && cp.contmet == 1 && cp.resena) { + if (cp.tonemap && cp.contmet == 1 && cp.resena) { float maxp = max0 * 256.f; float minp = min0 * 256.f; #ifdef _RT_NESTED_OPENMP #pragma omp single #endif - ContrastResid(WavCoeffs_L0, 5, skip, cp, W_L, H_L, maxp, minp, ave, ah, bh, al, bl, factorx ); + ContrastResid (WavCoeffs_L0, 5, skip, cp, W_L, H_L, maxp, minp, ave, ah, bh, al, bl, factorx ); } #ifdef _RT_NESTED_OPENMP #pragma omp barrier #endif - if((cp.conres != 0.f || cp.conresH != 0.f) && cp.resena) { // cp.conres = 0.f and cp.comresH = 0.f means that all will be multiplied by 1.f, so we can skip this step + if ((cp.conres != 0.f || cp.conresH != 0.f) && cp.resena) { // cp.conres = 0.f and cp.comresH = 0.f means that all will be multiplied by 1.f, so we can skip this step #ifdef _RT_NESTED_OPENMP #pragma omp for nowait #endif @@ -1846,15 +1846,15 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * //shadow float alp = 3.f; //increase contrast sahdow in lowlights between 1 and ?? - if(cp.th > (100.f - tran)) { + if (cp.th > (100.f - tran)) { tran = 100.f - cp.th; } - if(LL100 < cp.th) { + if (LL100 < cp.th) { float aalp = (1.f - alp) / cp.th; //no changes for LL100 = cp.th float kk = aalp * LL100 + alp; WavCoeffs_L0[i] *= (1.f + kk * cp.conres / 200.f); - } else if(LL100 < cp.th + tran) { + } else if (LL100 < cp.th + tran) { float ath = -cp.conres / tran; float bth = cp.conres - ath * cp.th; WavCoeffs_L0[i] *= (1.f + (LL100 * ath + bth) / 200.f); @@ -1863,13 +1863,13 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * //highlight tran = 5.f; - if(cp.thH < (tran)) { + if (cp.thH < (tran)) { tran = cp.thH; } - if(LL100 > cp.thH) { + if (LL100 > cp.thH) { WavCoeffs_L0[i] *= (1.f + cp.conresH / 200.f); - } else if(LL100 > (cp.thH - tran)) { + } else if (LL100 > (cp.thH - tran)) { float athH = cp.conresH / tran; float bthH = cp.conresH - athH * cp.thH; WavCoeffs_L0[i] *= (1.f + (LL100 * athH + bthH) / 200.f); @@ -1892,7 +1892,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * // float eddlow=5.f + cp.edgampl/2.f;//settings->ed_low;//5 to 40 - if(cp.detectedge) { //enabled Lipschitz control...more memory..more time... + if (cp.detectedge) { //enabled Lipschitz control...more memory..more time... float *tmCBuffer = new float[H_L * W_L]; float *tmC[H_L]; @@ -1906,11 +1906,11 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * for (int lvl = 0; lvl < 4; lvl++) { for (int dir = 1; dir < 4; dir++) { - int W_L = WaveletCoeffs_L.level_W(lvl); - int H_L = WaveletCoeffs_L.level_H(lvl); + int W_L = WaveletCoeffs_L.level_W (lvl); + int H_L = WaveletCoeffs_L.level_H (lvl); - float ** WavCoeffs_LL = WaveletCoeffs_L.level_coeffs(lvl); - calckoe(WavCoeffs_LL, cp, koeLi, lvl , dir, W_L, H_L, edd, maxkoeLi, tmC); + float ** WavCoeffs_LL = WaveletCoeffs_L.level_coeffs (lvl); + calckoe (WavCoeffs_LL, cp, koeLi, lvl , dir, W_L, H_L, edd, maxkoeLi, tmC); // return convolution KoeLi and maxkoeLi of level 0 1 2 3 and Dir Horiz, Vert, Diag } } @@ -1929,25 +1929,25 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * //treatment of koeLi and maxkoeLi float interm = 0.f; - if(cp.lip3 && cp.lipp) { + if (cp.lip3 && cp.lipp) { // comparaison between pixel and neighbours const auto neigh = cp.neigh == 1; const auto kneigh = neigh ? 28.f : 38.f; const auto somm = neigh ? 40.f : 50.f; for (int dir = 1; dir < 4; dir++) { //neighbours proxi - koeLi[lvl * 3 + dir - 1][i * W_L + j] = (kneigh * koeLi[lvl * 3 + dir - 1][i * W_L + j] + 2.f * koeLi[lvl * 3 + dir - 1][(i - 1) * W_L + j] + 2.f * koeLi[lvl * 3 + dir - 1][(i + 1) * W_L + j] - + 2.f * koeLi[lvl * 3 + dir - 1][i * W_L + j + 1] + 2.f * koeLi[lvl * 3 + dir - 1][i * W_L + j - 1] + koeLi[lvl * 3 + dir - 1][(i - 1) * W_L + j - 1] - + koeLi[lvl * 3 + dir - 1][(i - 1) * W_L + j + 1] + koeLi[lvl * 3 + dir - 1][(i + 1) * W_L + j - 1] + koeLi[lvl * 3 + dir - 1][(i + 1) * W_L + j + 1]) / somm; + koeLi[lvl * 3 + dir - 1][i * W_L + j] = (kneigh * koeLi[lvl * 3 + dir - 1][i * W_L + j] + 2.f * koeLi[lvl * 3 + dir - 1][ (i - 1) * W_L + j] + 2.f * koeLi[lvl * 3 + dir - 1][ (i + 1) * W_L + j] + + 2.f * koeLi[lvl * 3 + dir - 1][i * W_L + j + 1] + 2.f * koeLi[lvl * 3 + dir - 1][i * W_L + j - 1] + koeLi[lvl * 3 + dir - 1][ (i - 1) * W_L + j - 1] + + koeLi[lvl * 3 + dir - 1][ (i - 1) * W_L + j + 1] + koeLi[lvl * 3 + dir - 1][ (i + 1) * W_L + j - 1] + koeLi[lvl * 3 + dir - 1][ (i + 1) * W_L + j + 1]) / somm; } } for (int dir = 1; dir < 4; dir++) { //here I evaluate combinaison of vert / diag / horiz...we are with multiplicators of the signal - interm += SQR(koeLi[lvl * 3 + dir - 1][i * W_L + j]); + interm += SQR (koeLi[lvl * 3 + dir - 1][i * W_L + j]); } - interm = sqrt(interm); + interm = sqrt (interm); // interm /= 1.732f;//interm = pseudo variance koeLi interm *= 0.57736721f; @@ -1968,11 +1968,11 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * //Liamp=1 for eddlipinfl //liamp > 1 for alp >eddlipinfl and alph < 1 //Liamp < 1 for alp < eddlipinfl and alph > 0 - if(alph > 1.f) { + if (alph > 1.f) { alph = 1.f / alph; } - if(beta > 1.f) { + if (beta > 1.f) { beta = 1.f / beta; } @@ -1982,18 +1982,18 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * float bet = 1.f; //if(cp.lip3) {//enhance algorithm - if(alph > eddlipinfl && beta < 0.85f * eddlipinfl) { //0.85 arbitrary value ==> eliminate from edge if H V D too different + if (alph > eddlipinfl && beta < 0.85f * eddlipinfl) { //0.85 arbitrary value ==> eliminate from edge if H V D too different bet = beta; } //} float AmpLip = 1.f; - if(alph > eddlipinfl) { + if (alph > eddlipinfl) { AmpLip = alipinfl * alph + blipinfl; //If beta low reduce kampli - kampli = SQR(bet) * AmpLip * aamp; + kampli = SQR (bet) * AmpLip * aamp; } else { - AmpLip = (1.f / eddlipinfl) * SQR(SQR(alph * bet)); //Strong Reduce if beta low + AmpLip = (1.f / eddlipinfl) * SQR (SQR (alph * bet)); //Strong Reduce if beta low kampli = AmpLip / aamp; } @@ -2009,7 +2009,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * interm *= kampli; - if(interm < cp.eddetthr / eddlow) { + if (interm < cp.eddetthr / eddlow) { interm = 0.01f; //eliminate too low values } @@ -2030,10 +2030,10 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * for (int dir = 1; dir < 4; dir++) { for (int lvl = 0; lvl < maxlvl; lvl++) { - int Wlvl_L = WaveletCoeffs_L.level_W(lvl); - int Hlvl_L = WaveletCoeffs_L.level_H(lvl); + int Wlvl_L = WaveletCoeffs_L.level_W (lvl); + int Hlvl_L = WaveletCoeffs_L.level_H (lvl); - float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs(lvl); + float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs (lvl); ContAllL (koeLi, maxkoeLi, true, maxlvl, labco, varhue, varchrom, WavCoeffs_L, WavCoeffs_L0, lvl, dir, cp, Wlvl_L, Hlvl_L, skip, mean, meanN, sigma, sigmaN, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, ChCurve, Chutili); @@ -2043,18 +2043,18 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * } //delete edge detection - if(koeLibuffer) { + if (koeLibuffer) { delete [] koeLibuffer; } } -void ImProcFunctions::WaveletAandBAllAB(LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_a, wavelet_decomposition &WaveletCoeffs_b, - struct cont_params &cp, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* hhCurve, bool hhutili) +void ImProcFunctions::WaveletAandBAllAB (LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_a, wavelet_decomposition &WaveletCoeffs_b, + struct cont_params &cp, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* hhCurve, bool hhutili) { // StopWatch Stop1("WaveletAandBAllAB"); if (hhutili && cp.resena) { // H=f(H) - int W_L = WaveletCoeffs_a.level_W(0); - int H_L = WaveletCoeffs_a.level_H(0); + int W_L = WaveletCoeffs_a.level_W (0); + int H_L = WaveletCoeffs_a.level_H (0); float * WavCoeffs_a0 = WaveletCoeffs_a.coeff0; float * WavCoeffs_b0 = WaveletCoeffs_b.coeff0; @@ -2076,17 +2076,17 @@ void ImProcFunctions::WaveletAandBAllAB(LabImage * labco, float ** varhue, float int k; for (k = 0; k < W_L - 3; k += 4) { - __m128 av = LVFU(WavCoeffs_a0[i * W_L + k]); - __m128 bv = LVFU(WavCoeffs_b0[i * W_L + k]); - __m128 huev = xatan2f(bv, av); - __m128 chrv = _mm_sqrt_ps(SQRV(av) + SQRV(bv)); - STVF(huebuffer[k], huev); - STVF(chrbuffer[k], chrv); + __m128 av = LVFU (WavCoeffs_a0[i * W_L + k]); + __m128 bv = LVFU (WavCoeffs_b0[i * W_L + k]); + __m128 huev = xatan2f (bv, av); + __m128 chrv = _mm_sqrt_ps (SQRV (av) + SQRV (bv)); + STVF (huebuffer[k], huev); + STVF (chrbuffer[k], chrv); } - for(; k < W_L; k++) { - huebuffer[k] = xatan2f(WavCoeffs_b0[i * W_L + k], WavCoeffs_a0[i * W_L + k]); - chrbuffer[k] = sqrtf(SQR(WavCoeffs_b0[i * W_L + k]) + SQR(WavCoeffs_a0[i * W_L + k])) / 327.68f; + for (; k < W_L; k++) { + huebuffer[k] = xatan2f (WavCoeffs_b0[i * W_L + k], WavCoeffs_a0[i * W_L + k]); + chrbuffer[k] = sqrtf (SQR (WavCoeffs_b0[i * W_L + k]) + SQR (WavCoeffs_a0[i * W_L + k])) / 327.68f; } #endif // __SSE2__ @@ -2097,16 +2097,16 @@ void ImProcFunctions::WaveletAandBAllAB(LabImage * labco, float ** varhue, float float hueR = huebuffer[j]; float chR = chrbuffer[j]; #else - float hueR = xatan2f(WavCoeffs_b0[i * W_L + j], WavCoeffs_a0[i * W_L + j]); - float chR = sqrtf(SQR(WavCoeffs_b0[i * W_L + j]) + SQR(WavCoeffs_a0[i * W_L + j])); + float hueR = xatan2f (WavCoeffs_b0[i * W_L + j], WavCoeffs_a0[i * W_L + j]); + float chR = sqrtf (SQR (WavCoeffs_b0[i * W_L + j]) + SQR (WavCoeffs_a0[i * W_L + j])); #endif /* if (editID == EUID_WW_HHCurve) {//H pipette float valpar =Color::huelab_to_huehsv2(hueR); editWhatever->v(i,j) = valpar; } */ - float valparam = float((hhCurve->getVal(Color::huelab_to_huehsv2(hueR)) - 0.5f) * 1.7f) + hueR; //get H=f(H) 1.7 optimisation ! - float2 sincosval = xsincosf(valparam); + float valparam = float ((hhCurve->getVal (Color::huelab_to_huehsv2 (hueR)) - 0.5f) * 1.7f) + hueR; //get H=f(H) 1.7 optimisation ! + float2 sincosval = xsincosf (valparam); WavCoeffs_a0[i * W_L + j] = chR * sincosval.y; WavCoeffs_b0[i * W_L + j] = chR * sincosval.x; } @@ -2116,13 +2116,13 @@ void ImProcFunctions::WaveletAandBAllAB(LabImage * labco, float ** varhue, float } -void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_ab, const WavOpacityCurveW & waOpacityCurveW, - struct cont_params &cp, const bool useChannelA) +void ImProcFunctions::WaveletcontAllAB (LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_ab, const WavOpacityCurveW & waOpacityCurveW, + struct cont_params &cp, const bool useChannelA) { int maxlvl = WaveletCoeffs_ab.maxlevel(); - int W_L = WaveletCoeffs_ab.level_W(0); - int H_L = WaveletCoeffs_ab.level_H(0); + int W_L = WaveletCoeffs_ab.level_W (0); + int H_L = WaveletCoeffs_ab.level_H (0); float * WavCoeffs_ab0 = WaveletCoeffs_ab.coeff0; @@ -2130,7 +2130,7 @@ void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float #pragma omp parallel num_threads(wavNestedLevels) if(wavNestedLevels>1) #endif { - if(cp.chrores != 0.f && cp.resena) { // cp.chrores == 0.f means all will be multiplied by 1.f, so we can skip the processing of residual + if (cp.chrores != 0.f && cp.resena) { // cp.chrores == 0.f means all will be multiplied by 1.f, so we can skip the processing of residual #ifdef _RT_NESTED_OPENMP #pragma omp for nowait @@ -2144,22 +2144,22 @@ void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float float modhue = varhue[ii][jj]; float scale = 1.f; - if(skyprot > 0.f) { - if((modhue < cp.t_ry && modhue > cp.t_ly)) { + if (skyprot > 0.f) { + if ((modhue < cp.t_ry && modhue > cp.t_ly)) { scale = (100.f - cp.sky) / 100.1f; - } else if((modhue >= cp.t_ry && modhue < cp.b_ry)) { + } else if ((modhue >= cp.t_ry && modhue < cp.b_ry)) { scale = (100.f - cp.sky) / 100.1f; float ar = (scale - 1.f) / (cp.t_ry - cp.b_ry); float br = scale - cp.t_ry * ar; scale = ar * modhue + br; - } else if((modhue > cp.b_ly && modhue < cp.t_ly)) { + } else if ((modhue > cp.b_ly && modhue < cp.t_ly)) { scale = (100.f - cp.sky) / 100.1f; float al = (scale - 1.f) / (-cp.b_ly + cp.t_ly); float bl = scale - cp.t_ly * al; scale = al * modhue + bl; } - } else if(skyprot < 0.f) { - if((modhue > cp.t_ry || modhue < cp.t_ly)) { + } else if (skyprot < 0.f) { + if ((modhue > cp.t_ry || modhue < cp.t_ly)) { scale = (100.f + cp.sky) / 100.1f; } @@ -2183,7 +2183,7 @@ void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float } } - if(cp.cbena && cp.resena) {//if user select Toning and color balance + if (cp.cbena && cp.resena) { //if user select Toning and color balance #ifdef _RT_NESTED_OPENMP #pragma omp for nowait @@ -2196,24 +2196,24 @@ void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float float sca = 1.f; //amplifer - reducter...about 1, but perhaps 0.6 or 1.3 - if(useChannelA) {//green red (little magenta) + if (useChannelA) { //green red (little magenta) //transition to avoid artifacts with 6 between 30 to 36 and 63 to 69 float aa = (cp.grmed - cp.grlow) / 6.f; float bb = cp.grlow - 30.f * aa; float aaa = (cp.grhigh - cp.grmed) / 6.f; float bbb = cp.grmed - 63.f * aaa; - if(LL < 30.f) { //shadows + if (LL < 30.f) { //shadows WavCoeffs_ab0[i] += cp.grlow * (sca) * 300.f; - } else if(LL >= 30.f && LL < 36.f) { //transition + } else if (LL >= 30.f && LL < 36.f) { //transition float tr = aa * LL + bb; WavCoeffs_ab0[i] += tr * (sca) * 300.f; - } else if(LL >= 36.f && LL < 63.f) { //midtones + } else if (LL >= 36.f && LL < 63.f) { //midtones WavCoeffs_ab0[i] += cp.grmed * (sca) * 300.f; - } else if(LL >= 63.f && LL < 69.f) { //transition + } else if (LL >= 63.f && LL < 69.f) { //transition float trh = aaa * LL + bbb; WavCoeffs_ab0[i] += trh * (sca) * 300.f; - } else if(LL >= 69.f) { //highlights + } else if (LL >= 69.f) { //highlights WavCoeffs_ab0[i] += cp.grhigh * (sca) * 300.f; } } else { //blue yellow @@ -2223,17 +2223,17 @@ void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float float aaa1 = (cp.blhigh - cp.blmed) / 6.f; float bbb1 = cp.blmed - 63.f * aaa1; - if(LL < 30.f) { + if (LL < 30.f) { WavCoeffs_ab0[i] += cp.bllow * (sca) * 300.f; - } else if(LL >= 30.f && LL < 36.f) { + } else if (LL >= 30.f && LL < 36.f) { float tr1 = aa1 * LL + bb1; WavCoeffs_ab0[i] += tr1 * (sca) * 300.f; - } else if(LL >= 36.f && LL < 63.f) { + } else if (LL >= 36.f && LL < 63.f) { WavCoeffs_ab0[i] += cp.blmed * (sca) * 300.f; - } else if(LL >= 63.f && LL < 69.f) { + } else if (LL >= 63.f && LL < 69.f) { float trh1 = aaa1 * LL + bbb1; WavCoeffs_ab0[i] += trh1 * (sca) * 300.f; - } else if(LL >= 69.f) { + } else if (LL >= 69.f) { WavCoeffs_ab0[i] += cp.blhigh * (sca) * 300.f; } } @@ -2247,10 +2247,10 @@ void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float for (int dir = 1; dir < 4; dir++) { for (int lvl = 0; lvl < maxlvl; lvl++) { - int Wlvl_ab = WaveletCoeffs_ab.level_W(lvl); - int Hlvl_ab = WaveletCoeffs_ab.level_H(lvl); + int Wlvl_ab = WaveletCoeffs_ab.level_W (lvl); + int Hlvl_ab = WaveletCoeffs_ab.level_H (lvl); - float ** WavCoeffs_ab = WaveletCoeffs_ab.level_coeffs(lvl); + float ** WavCoeffs_ab = WaveletCoeffs_ab.level_coeffs (lvl); ContAllAB (labco, maxlvl, varhue, varchrom, WavCoeffs_ab, WavCoeffs_ab0, lvl, dir, waOpacityCurveW, cp, Wlvl_ab, Hlvl_ab, useChannelA); } } @@ -2262,12 +2262,12 @@ void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void ImProcFunctions::calckoe(float ** WavCoeffs_LL, const struct cont_params& cp, float *koeLi[12], int level, int dir, int W_L, int H_L, float edd, float *maxkoeLi, float **tmC) +void ImProcFunctions::calckoe (float ** WavCoeffs_LL, const struct cont_params& cp, float *koeLi[12], int level, int dir, int W_L, int H_L, float edd, float *maxkoeLi, float **tmC) { int borderL = 2; // printf("cpedth=%f\n",cp.eddetthr); - if(cp.eddetthr < 30.f) { + if (cp.eddetthr < 30.f) { borderL = 1; // I calculate coefficients with r size matrix 3x3 r=1 ; 5x5 r=2; 7x7 r=3 @@ -2283,22 +2283,22 @@ void ImProcFunctions::calckoe(float ** WavCoeffs_LL, const struct cont_params& c */ for (int i = 1; i < H_L - 1; i++) { //sigma=0.55 for (int j = 1; j < W_L - 1; j++) { - tmC[i][j] = (8.94f * WavCoeffs_LL[dir][i * W_L + j] + 1.71f * (WavCoeffs_LL[dir][(i - 1) * W_L + j] + 1.71f * WavCoeffs_LL[dir][(i + 1) * W_L + j] - + 1.71f * WavCoeffs_LL[dir][i * W_L + j + 1] + 1.71f * WavCoeffs_LL[dir][i * W_L + j - 1]) + 0.33f * WavCoeffs_LL[dir][(i - 1) * W_L + j - 1] - + 0.33f * WavCoeffs_LL[dir][(i - 1) * W_L + j + 1] + 0.33f * WavCoeffs_LL[dir][(i + 1) * W_L + j - 1] + 0.33f * WavCoeffs_LL[dir][(i + 1) * W_L + j + 1]) * 0.0584795f; + tmC[i][j] = (8.94f * WavCoeffs_LL[dir][i * W_L + j] + 1.71f * (WavCoeffs_LL[dir][ (i - 1) * W_L + j] + 1.71f * WavCoeffs_LL[dir][ (i + 1) * W_L + j] + + 1.71f * WavCoeffs_LL[dir][i * W_L + j + 1] + 1.71f * WavCoeffs_LL[dir][i * W_L + j - 1]) + 0.33f * WavCoeffs_LL[dir][ (i - 1) * W_L + j - 1] + + 0.33f * WavCoeffs_LL[dir][ (i - 1) * W_L + j + 1] + 0.33f * WavCoeffs_LL[dir][ (i + 1) * W_L + j - 1] + 0.33f * WavCoeffs_LL[dir][ (i + 1) * W_L + j + 1]) * 0.0584795f; // apply to each direction Wavelet level : horizontal / vertiacle / diagonal } } - } else if(cp.eddetthr >= 30.f && cp.eddetthr < 50.f) { + } else if (cp.eddetthr >= 30.f && cp.eddetthr < 50.f) { borderL = 1; for (int i = 1; i < H_L - 1; i++) { //sigma=0.85 for (int j = 1; j < W_L - 1; j++) { - tmC[i][j] = (4.0091f * WavCoeffs_LL[dir][i * W_L + j] + 2.0068f * (WavCoeffs_LL[dir][(i - 1) * W_L + j] + 2.0068f * WavCoeffs_LL[dir][(i + 1) * W_L + j] - + 2.0068f * WavCoeffs_LL[dir][i * W_L + j + 1] + 2.0068f * WavCoeffs_LL[dir][i * W_L + j - 1]) + 1.0045f * WavCoeffs_LL[dir][(i - 1) * W_L + j - 1] - + 1.0045f * WavCoeffs_LL[dir][(i - 1) * W_L + j + 1] + 1.0045f * WavCoeffs_LL[dir][(i + 1) * W_L + j - 1] + 1.0045f * WavCoeffs_LL[dir][(i + 1) * W_L + j + 1]) * 0.062288f; + tmC[i][j] = (4.0091f * WavCoeffs_LL[dir][i * W_L + j] + 2.0068f * (WavCoeffs_LL[dir][ (i - 1) * W_L + j] + 2.0068f * WavCoeffs_LL[dir][ (i + 1) * W_L + j] + + 2.0068f * WavCoeffs_LL[dir][i * W_L + j + 1] + 2.0068f * WavCoeffs_LL[dir][i * W_L + j - 1]) + 1.0045f * WavCoeffs_LL[dir][ (i - 1) * W_L + j - 1] + + 1.0045f * WavCoeffs_LL[dir][ (i - 1) * W_L + j + 1] + 1.0045f * WavCoeffs_LL[dir][ (i + 1) * W_L + j - 1] + 1.0045f * WavCoeffs_LL[dir][ (i + 1) * W_L + j + 1]) * 0.062288f; // apply to each direction Wavelet level : horizontal / vertiacle / diagonal @@ -2307,23 +2307,23 @@ void ImProcFunctions::calckoe(float ** WavCoeffs_LL, const struct cont_params& c } - else if(cp.eddetthr >= 50.f && cp.eddetthr < 75.f) { + else if (cp.eddetthr >= 50.f && cp.eddetthr < 75.f) { borderL = 1; for (int i = 1; i < H_L - 1; i++) { for (int j = 1; j < W_L - 1; j++) { //sigma=1.1 - tmC[i][j] = (3.025f * WavCoeffs_LL[dir][i * W_L + j] + 2.001f * (WavCoeffs_LL[dir][(i - 1) * W_L + j] + 2.001f * WavCoeffs_LL[dir][(i + 1) * W_L + j] - + 2.001f * WavCoeffs_LL[dir][i * W_L + j + 1] + 2.001f * WavCoeffs_LL[dir][i * W_L + j - 1]) + 1.323f * WavCoeffs_LL[dir][(i - 1) * W_L + j - 1] - + 1.323f * WavCoeffs_LL[dir][(i - 1) * W_L + j + 1] + 1.323f * WavCoeffs_LL[dir][(i + 1) * W_L + j - 1] + 1.323f * WavCoeffs_LL[dir][(i + 1) * W_L + j + 1]) * 0.06127f; + tmC[i][j] = (3.025f * WavCoeffs_LL[dir][i * W_L + j] + 2.001f * (WavCoeffs_LL[dir][ (i - 1) * W_L + j] + 2.001f * WavCoeffs_LL[dir][ (i + 1) * W_L + j] + + 2.001f * WavCoeffs_LL[dir][i * W_L + j + 1] + 2.001f * WavCoeffs_LL[dir][i * W_L + j - 1]) + 1.323f * WavCoeffs_LL[dir][ (i - 1) * W_L + j - 1] + + 1.323f * WavCoeffs_LL[dir][ (i - 1) * W_L + j + 1] + 1.323f * WavCoeffs_LL[dir][ (i + 1) * W_L + j - 1] + 1.323f * WavCoeffs_LL[dir][ (i + 1) * W_L + j + 1]) * 0.06127f; } } } - else if(cp.eddetthr >= 75.f) { + else if (cp.eddetthr >= 75.f) { borderL = 2; //if(cp.lip3 && level > 1) { - if(level > 1) {// do not activate 5x5 if level 0 or 1 + if (level > 1) { // do not activate 5x5 if level 0 or 1 for (int i = 2; i < H_L - 2; i++) { for (int j = 2; j < W_L - 2; j++) { @@ -2341,26 +2341,26 @@ void ImProcFunctions::calckoe(float ** WavCoeffs_LL, const struct cont_params& c // 4 9 12 9 4 // 2 4 5 4 2 // divi 159 - if(cp.eddetthr < 85.f) { //sigma=1.1 - tmC[i][j] = (15.f * WavCoeffs_LL[dir][i * W_L + j] + 10.f * WavCoeffs_LL[dir][(i - 1) * W_L + j] + 10.f * WavCoeffs_LL[dir][(i + 1) * W_L + j] - + 10.f * WavCoeffs_LL[dir][i * W_L + j + 1] + 10.f * WavCoeffs_LL[dir][i * W_L + j - 1] + 7.f * WavCoeffs_LL[dir][(i - 1) * W_L + j - 1] - + 7.f * WavCoeffs_LL[dir][(i - 1) * W_L + j + 1] + 7.f * WavCoeffs_LL[dir][(i + 1) * W_L + j - 1] + 7.f * WavCoeffs_LL[dir][(i + 1) * W_L + j + 1] - + 3.f * WavCoeffs_LL[dir][(i - 2) * W_L + j] + 3.f * WavCoeffs_LL[dir][(i + 2) * W_L + j] + 3.f * WavCoeffs_LL[dir][i * W_L + j - 2] + 3.f * WavCoeffs_LL[dir][i * W_L + j + 2] - + 2.f * WavCoeffs_LL[dir][(i - 2) * W_L + j - 1] + 2.f * WavCoeffs_LL[dir][(i - 2) * W_L + j + 1] + 2.f * WavCoeffs_LL[dir][(i + 2) * W_L + j + 1] + 2.f * WavCoeffs_LL[dir][(i + 2) * W_L + j - 1] - + 2.f * WavCoeffs_LL[dir][(i - 1) * W_L + j - 2] + 2.f * WavCoeffs_LL[dir][(i - 1) * W_L + j + 2] + 2.f * WavCoeffs_LL[dir][(i + 1) * W_L + j + 2] + 2.f * WavCoeffs_LL[dir][(i + 1) * W_L + j - 2] - + 0.5f * WavCoeffs_LL[dir][(i - 2) * W_L + j - 2] + 0.5f * WavCoeffs_LL[dir][(i - 2) * W_L + j + 2] + 0.5f * WavCoeffs_LL[dir][(i + 2) * W_L + j - 2] + 0.5f * WavCoeffs_LL[dir][(i + 2) * W_L + j + 2] + if (cp.eddetthr < 85.f) { //sigma=1.1 + tmC[i][j] = (15.f * WavCoeffs_LL[dir][i * W_L + j] + 10.f * WavCoeffs_LL[dir][ (i - 1) * W_L + j] + 10.f * WavCoeffs_LL[dir][ (i + 1) * W_L + j] + + 10.f * WavCoeffs_LL[dir][i * W_L + j + 1] + 10.f * WavCoeffs_LL[dir][i * W_L + j - 1] + 7.f * WavCoeffs_LL[dir][ (i - 1) * W_L + j - 1] + + 7.f * WavCoeffs_LL[dir][ (i - 1) * W_L + j + 1] + 7.f * WavCoeffs_LL[dir][ (i + 1) * W_L + j - 1] + 7.f * WavCoeffs_LL[dir][ (i + 1) * W_L + j + 1] + + 3.f * WavCoeffs_LL[dir][ (i - 2) * W_L + j] + 3.f * WavCoeffs_LL[dir][ (i + 2) * W_L + j] + 3.f * WavCoeffs_LL[dir][i * W_L + j - 2] + 3.f * WavCoeffs_LL[dir][i * W_L + j + 2] + + 2.f * WavCoeffs_LL[dir][ (i - 2) * W_L + j - 1] + 2.f * WavCoeffs_LL[dir][ (i - 2) * W_L + j + 1] + 2.f * WavCoeffs_LL[dir][ (i + 2) * W_L + j + 1] + 2.f * WavCoeffs_LL[dir][ (i + 2) * W_L + j - 1] + + 2.f * WavCoeffs_LL[dir][ (i - 1) * W_L + j - 2] + 2.f * WavCoeffs_LL[dir][ (i - 1) * W_L + j + 2] + 2.f * WavCoeffs_LL[dir][ (i + 1) * W_L + j + 2] + 2.f * WavCoeffs_LL[dir][ (i + 1) * W_L + j - 2] + + 0.5f * WavCoeffs_LL[dir][ (i - 2) * W_L + j - 2] + 0.5f * WavCoeffs_LL[dir][ (i - 2) * W_L + j + 2] + 0.5f * WavCoeffs_LL[dir][ (i + 2) * W_L + j - 2] + 0.5f * WavCoeffs_LL[dir][ (i + 2) * W_L + j + 2] ) * 0.0088495f; } else {//sigma=1.4 - tmC[i][j] = (15.f * WavCoeffs_LL[dir][i * W_L + j] + 12.f * WavCoeffs_LL[dir][(i - 1) * W_L + j] + 12.f * WavCoeffs_LL[dir][(i + 1) * W_L + j] - + 12.f * WavCoeffs_LL[dir][i * W_L + j + 1] + 12.f * WavCoeffs_LL[dir][i * W_L + j - 1] + 9.f * WavCoeffs_LL[dir][(i - 1) * W_L + j - 1] - + 9.f * WavCoeffs_LL[dir][(i - 1) * W_L + j + 1] + 9.f * WavCoeffs_LL[dir][(i + 1) * W_L + j - 1] + 9.f * WavCoeffs_LL[dir][(i + 1) * W_L + j + 1] - + 5.f * WavCoeffs_LL[dir][(i - 2) * W_L + j] + 5.f * WavCoeffs_LL[dir][(i + 2) * W_L + j] + 5.f * WavCoeffs_LL[dir][i * W_L + j - 2] + 5.f * WavCoeffs_LL[dir][i * W_L + j + 2] - + 4.f * WavCoeffs_LL[dir][(i - 2) * W_L + j - 1] + 4.f * WavCoeffs_LL[dir][(i - 2) * W_L + j + 1] + 4.f * WavCoeffs_LL[dir][(i + 2) * W_L + j + 1] + 4.f * WavCoeffs_LL[dir][(i + 2) * W_L + j - 1] - + 4.f * WavCoeffs_LL[dir][(i - 1) * W_L + j - 2] + 4.f * WavCoeffs_LL[dir][(i - 1) * W_L + j + 2] + 4.f * WavCoeffs_LL[dir][(i + 1) * W_L + j + 2] + 4.f * WavCoeffs_LL[dir][(i + 1) * W_L + j - 2] - + 2.f * WavCoeffs_LL[dir][(i - 2) * W_L + j - 2] + 2.f * WavCoeffs_LL[dir][(i - 2) * W_L + j + 2] + 2.f * WavCoeffs_LL[dir][(i + 2) * W_L + j - 2] + 2.f * WavCoeffs_LL[dir][(i + 2) * W_L + j + 2] + tmC[i][j] = (15.f * WavCoeffs_LL[dir][i * W_L + j] + 12.f * WavCoeffs_LL[dir][ (i - 1) * W_L + j] + 12.f * WavCoeffs_LL[dir][ (i + 1) * W_L + j] + + 12.f * WavCoeffs_LL[dir][i * W_L + j + 1] + 12.f * WavCoeffs_LL[dir][i * W_L + j - 1] + 9.f * WavCoeffs_LL[dir][ (i - 1) * W_L + j - 1] + + 9.f * WavCoeffs_LL[dir][ (i - 1) * W_L + j + 1] + 9.f * WavCoeffs_LL[dir][ (i + 1) * W_L + j - 1] + 9.f * WavCoeffs_LL[dir][ (i + 1) * W_L + j + 1] + + 5.f * WavCoeffs_LL[dir][ (i - 2) * W_L + j] + 5.f * WavCoeffs_LL[dir][ (i + 2) * W_L + j] + 5.f * WavCoeffs_LL[dir][i * W_L + j - 2] + 5.f * WavCoeffs_LL[dir][i * W_L + j + 2] + + 4.f * WavCoeffs_LL[dir][ (i - 2) * W_L + j - 1] + 4.f * WavCoeffs_LL[dir][ (i - 2) * W_L + j + 1] + 4.f * WavCoeffs_LL[dir][ (i + 2) * W_L + j + 1] + 4.f * WavCoeffs_LL[dir][ (i + 2) * W_L + j - 1] + + 4.f * WavCoeffs_LL[dir][ (i - 1) * W_L + j - 2] + 4.f * WavCoeffs_LL[dir][ (i - 1) * W_L + j + 2] + 4.f * WavCoeffs_LL[dir][ (i + 1) * W_L + j + 2] + 4.f * WavCoeffs_LL[dir][ (i + 1) * W_L + j - 2] + + 2.f * WavCoeffs_LL[dir][ (i - 2) * W_L + j - 2] + 2.f * WavCoeffs_LL[dir][ (i - 2) * W_L + j + 2] + 2.f * WavCoeffs_LL[dir][ (i + 2) * W_L + j - 2] + 2.f * WavCoeffs_LL[dir][ (i + 2) * W_L + j + 2] ) * 0.0062893f; } @@ -2392,24 +2392,24 @@ void ImProcFunctions::calckoe(float ** WavCoeffs_LL, const struct cont_params& c thr2 += cp.eddet / 30.f; //to test float diffFactor = (cp.eddet / 100.f); - for(int i = 0; i < H_L; i++ ) { - for(int j = 0; j < W_L; j++) { + for (int i = 0; i < H_L; i++ ) { + for (int j = 0; j < W_L; j++) { koeLi[level * 3 + dir - 1][i * W_L + j] = 1.f; } } - for(int i = borderL; i < H_L - borderL; i++ ) { - for(int j = borderL; j < W_L - borderL; j++) { + for (int i = borderL; i < H_L - borderL; i++ ) { + for (int j = borderL; j < W_L - borderL; j++) { // my own algo : probably a little false, but simpler as Lipschitz ! // Thr2 = maximum of the function ==> Lipsitch says = probably edge // float temp = WavCoeffs_LL[dir][i*W_L + j]; // if(temp>=0.f && temp < thr) temp = thr; // if(temp < 0.f && temp > -thr) temp = -thr; - float temp = max(fabsf(WavCoeffs_LL[dir][i * W_L + j]), thr ); - koeLi[level * 3 + dir - 1][i * W_L + j] = min(thr2, fabs(tmC[i][j] / temp)); // limit maxi + float temp = max (fabsf (WavCoeffs_LL[dir][i * W_L + j]), thr ); + koeLi[level * 3 + dir - 1][i * W_L + j] = min (thr2, fabs (tmC[i][j] / temp)); // limit maxi //it will be more complicated to calculate both Wh and Wv, but we have also Wd==> pseudo Lipschitz - if(koeLi[level * 3 + dir - 1][i * W_L + j] > maxkoeLi[level * 3 + dir - 1]) { + if (koeLi[level * 3 + dir - 1][i * W_L + j] > maxkoeLi[level * 3 + dir - 1]) { maxkoeLi[level * 3 + dir - 1] = koeLi[level * 3 + dir - 1][i * W_L + j]; } @@ -2424,12 +2424,12 @@ void ImProcFunctions::calckoe(float ** WavCoeffs_LL, const struct cont_params& c void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp, int W_L, int H_L, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL) { - if(cp.diagcurv && cp.finena && MaxP[level] > 0.f && mean[level] != 0.f && sigma[level] != 0.f ) { //curve + if (cp.diagcurv && cp.finena && MaxP[level] > 0.f && mean[level] != 0.f && sigma[level] != 0.f ) { //curve float insigma = 0.666f; //SD - float logmax = log(MaxP[level]); //log Max + float logmax = log (MaxP[level]); //log Max float rapX = (mean[level] + sigma[level]) / MaxP[level]; //rapport between sD / max - float inx = log(insigma); - float iny = log(rapX); + float inx = log (insigma); + float iny = log (rapX); float rap = inx / iny; //koef float asig = 0.166f / sigma[level]; float bsig = 0.5f - asig * mean[level]; @@ -2442,15 +2442,15 @@ void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, for (int i = 0; i < W_L * H_L; i++) { float absciss; - if(fabsf(WavCoeffs_L[dir][i]) >= (mean[level] + sigma[level])) { //for max - float valcour = xlogf(fabsf(WavCoeffs_L[dir][i])); + if (fabsf (WavCoeffs_L[dir][i]) >= (mean[level] + sigma[level])) { //for max + float valcour = xlogf (fabsf (WavCoeffs_L[dir][i])); float valc = valcour - logmax; float vald = valc * rap; - absciss = xexpf(vald); - } else if(fabsf(WavCoeffs_L[dir][i]) >= mean[level]) { - absciss = asig * fabsf(WavCoeffs_L[dir][i]) + bsig; + absciss = xexpf (vald); + } else if (fabsf (WavCoeffs_L[dir][i]) >= mean[level]) { + absciss = asig * fabsf (WavCoeffs_L[dir][i]) + bsig; } else { - absciss = amean * fabsf(WavCoeffs_L[dir][i]); + absciss = amean * fabsf (WavCoeffs_L[dir][i]); } float kc = waOpacityCurveWL[absciss * 500.f] - 0.5f; @@ -2463,39 +2463,39 @@ void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, } } - int choicelevel = atoi(params->wavelet.Lmethod.data()) - 1; + int choicelevel = atoi (params->wavelet.Lmethod.data()) - 1; choicelevel = choicelevel == -1 ? 4 : choicelevel; int choiceClevel = 0; - if(params->wavelet.CLmethod == "one") { + if (params->wavelet.CLmethod == "one") { choiceClevel = 0; - } else if(params->wavelet.CLmethod == "inf") { + } else if (params->wavelet.CLmethod == "inf") { choiceClevel = 1; - } else if(params->wavelet.CLmethod == "sup") { + } else if (params->wavelet.CLmethod == "sup") { choiceClevel = 2; - } else if(params->wavelet.CLmethod == "all") { + } else if (params->wavelet.CLmethod == "all") { choiceClevel = 3; } int choiceDir = 0; - if(params->wavelet.Dirmethod == "one") { + if (params->wavelet.Dirmethod == "one") { choiceDir = 1; - } else if(params->wavelet.Dirmethod == "two") { + } else if (params->wavelet.Dirmethod == "two") { choiceDir = 2; - } else if(params->wavelet.Dirmethod == "thr") { + } else if (params->wavelet.Dirmethod == "thr") { choiceDir = 3; - } else if(params->wavelet.Dirmethod == "all") { + } else if (params->wavelet.Dirmethod == "all") { choiceDir = 0; } int dir1 = (choiceDir == 2) ? 1 : 2; int dir2 = (choiceDir == 3) ? 1 : 3; - if(choiceClevel < 3) { // not all levels visible, paint residual - if(level == 0) { - if(cp.backm != 2) { // nothing to change when residual is used as background + if (choiceClevel < 3) { // not all levels visible, paint residual + if (level == 0) { + if (cp.backm != 2) { // nothing to change when residual is used as background float backGroundColor = (cp.backm == 1) ? 12000.f : 0.f; for (int i = 0; i < W_L * H_L; i++) { @@ -2505,10 +2505,10 @@ void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, } } - if(choiceClevel == 0) { // Only one level + if (choiceClevel == 0) { // Only one level - if(choiceDir == 0) { // All directions - if(level != choicelevel) { // zero all for the levels != choicelevel + if (choiceDir == 0) { // All directions + if (level != choicelevel) { // zero all for the levels != choicelevel for (int dir = 1; dir < 4; dir++) { for (int i = 0; i < W_L * H_L; i++) { WavCoeffs_L[dir][i] = 0.f; @@ -2517,21 +2517,21 @@ void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, } } else { // zero the unwanted directions for level == choicelevel - if(choicelevel >= cp.maxilev) { + if (choicelevel >= cp.maxilev) { for (int dir = 1; dir < 4; dir++) { for (int i = 0; i < W_L * H_L; i++) { WavCoeffs_L[dir][i] = 0.f; } } - } else if(level != choicelevel) { // zero all for the levels != choicelevel + } else if (level != choicelevel) { // zero all for the levels != choicelevel for (int i = 0; i < W_L * H_L; i++) { WavCoeffs_L[dir1][i] = WavCoeffs_L[dir2][i] = 0.f; } } } - } else if(choiceClevel == 1) { // Only below level - if(choiceDir == 0) { // All directions - if(level > choicelevel) { + } else if (choiceClevel == 1) { // Only below level + if (choiceDir == 0) { // All directions + if (level > choicelevel) { for (int dir = 1; dir < 4; dir++) { for (int i = 0; i < W_L * H_L; i++) { WavCoeffs_L[dir][i] = 0.f; @@ -2539,15 +2539,15 @@ void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, } } } else { // zero the unwanted directions for level >= choicelevel - if(level > choicelevel) { + if (level > choicelevel) { for (int i = 0; i < W_L * H_L; i++) { WavCoeffs_L[dir1][i] = WavCoeffs_L[dir2][i] = 0.f; } } } - } else if(choiceClevel == 2) { // Only above level - if(choiceDir == 0) { // All directions - if(level <= choicelevel) { + } else if (choiceClevel == 2) { // Only above level + if (choiceDir == 0) { // All directions + if (level <= choicelevel) { for (int dir = 1; dir < 4; dir++) { for (int i = 0; i < W_L * H_L; i++) { WavCoeffs_L[dir][i] = 0.f; @@ -2555,7 +2555,7 @@ void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, } } } else { // zero the unwanted directions for level >= choicelevel - if(choicelevel >= cp.maxilev) { + if (choicelevel >= cp.maxilev) { for (int dir = 1; dir < 4; dir++) { for (int i = 0; i < W_L * H_L; i++) { WavCoeffs_L[dir][i] = 0.f; @@ -2564,7 +2564,7 @@ void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, } - else if(level <= choicelevel) { + else if (level <= choicelevel) { for (int i = 0; i < W_L * H_L; i++) { WavCoeffs_L[dir1][i] = WavCoeffs_L[dir2][i] = 0.f; } @@ -2584,7 +2584,7 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit static const float scales[10] = {1.f, 2.f, 4.f, 8.f, 16.f, 32.f, 64.f, 128.f, 256.f, 512.f}; float scaleskip[10]; - for(int sc = 0; sc < 10; sc++) { + for (int sc = 0; sc < 10; sc++) { scaleskip[sc] = scales[sc] / skip; } @@ -2596,11 +2596,11 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float aedstr = (eddstrength - 1.f) / 90.f; float bedstr = 1.f - 10.f * aedstr; - if(cp.val > 0 && cp.edgeena) { + if (cp.val > 0 && cp.edgeena) { float * koe = nullptr; float maxkoe = 0.f; - if(!lipschitz) { + if (!lipschitz) { koe = new float [H_L * W_L]; for (int i = 0; i < W_L * H_L; i++) { @@ -2609,7 +2609,7 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit maxkoe = 0.f; - if(cp.detectedge) { + if (cp.detectedge) { float** tmC; int borderL = 1; tmC = new float*[H_L]; @@ -2623,9 +2623,9 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit for (int j = 1; j < W_L - 1; j++) { //edge detection wavelet TMC Canny // also possible to detect noise with 5x5 instead of 3x3 - tmC[i][j] = (4.f * WavCoeffs_L[dir][i * W_L + j] + 2.f * WavCoeffs_L[dir][(i - 1) * W_L + j] + 2.f * WavCoeffs_L[dir][(i + 1) * W_L + j] - + 2.f * WavCoeffs_L[dir][i * W_L + j + 1] + 2.f * WavCoeffs_L[dir][i * W_L + j - 1] + WavCoeffs_L[dir][(i - 1) * W_L + j - 1] - + WavCoeffs_L[dir][(i - 1) * W_L + j + 1] + WavCoeffs_L[dir][(i + 1) * W_L + j - 1] + WavCoeffs_L[dir][(i + 1) * W_L + j + 1]) / 16.f; + tmC[i][j] = (4.f * WavCoeffs_L[dir][i * W_L + j] + 2.f * WavCoeffs_L[dir][ (i - 1) * W_L + j] + 2.f * WavCoeffs_L[dir][ (i + 1) * W_L + j] + + 2.f * WavCoeffs_L[dir][i * W_L + j + 1] + 2.f * WavCoeffs_L[dir][i * W_L + j - 1] + WavCoeffs_L[dir][ (i - 1) * W_L + j - 1] + + WavCoeffs_L[dir][ (i - 1) * W_L + j + 1] + WavCoeffs_L[dir][ (i + 1) * W_L + j - 1] + WavCoeffs_L[dir][ (i + 1) * W_L + j + 1]) / 16.f; // apply to each direction Wavelet level : horizontal / vertiacle / diagonal } @@ -2635,25 +2635,25 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit - for(int i = borderL; i < H_L - borderL; i++ ) { - for(int j = borderL; j < W_L - borderL; j++) { + for (int i = borderL; i < H_L - borderL; i++ ) { + for (int j = borderL; j < W_L - borderL; j++) { // my own algo : probably a little false, but simpler as Lipschitz ! float thr = 40.f; //avoid artifact eg. noise...to test float thr2 = edd; //edd can be modified in option ed_detect thr2 += cp.eddet / 30.f; //to test float temp = WavCoeffs_L[dir][i * W_L + j]; - if(temp >= 0.f && temp < thr) { + if (temp >= 0.f && temp < thr) { temp = thr; } - if(temp < 0.f && temp > -thr) { + if (temp < 0.f && temp > -thr) { temp = -thr; } - koe[i * W_L + j] = min(thr2, fabs(tmC[i][j] / temp)); + koe[i * W_L + j] = min (thr2, fabs (tmC[i][j] / temp)); - if(koe[i * W_L + j] > maxkoe) { + if (koe[i * W_L + j] > maxkoe) { maxkoe = koe[i * W_L + j]; } @@ -2661,7 +2661,7 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit diff *= (cp.eddet / 100.f); float interm = maxkoe - diff; - if(interm < cp.eddetthr / 30.f) { + if (interm < cp.eddetthr / 30.f) { interm = 0.01f; } @@ -2694,18 +2694,18 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float repart = (float)cp.til; float brepart; - if(cp.reinforce == 1) { + if (cp.reinforce == 1) { brepart = 3.f; } - if(cp.reinforce == 3) { + if (cp.reinforce == 3) { brepart = 0.5f; //arbitrary value to increase / decrease repart, between 1 and 0 } - float arepart = -(brepart - 1.f) / (lim0 / 60.f); + float arepart = - (brepart - 1.f) / (lim0 / 60.f); if (cp.reinforce != 2) { - if(rad < lim0 / 60.f) { + if (rad < lim0 / 60.f) { repart *= (arepart * rad + brepart); //linear repartition of repart } } @@ -2713,19 +2713,19 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float al0 = 1.f + (repart) / 50.f; float al10 = 1.0f; //arbitrary value ==> less = take into account high levels // float ak =-(al0-al10)/10.f;//10 = maximum levels - float ak = -(al0 - al10) / 10.f; //10 = maximum levels + float ak = - (al0 - al10) / 10.f; //10 = maximum levels float bk = al0; float koef = ak * level + bk; //modulate for levels : more levels high, more koef low ==> concentrated action on low levels, without or near for high levels - float expkoef = -pow(fabs(rad - lev), koef); //reduce effect for high levels + float expkoef = -pow (fabs (rad - lev), koef); //reduce effect for high levels if (cp.reinforce == 3) { - if(rad < lim0 / 60.f && level == 0) { - expkoef *= abs(repart); //reduce effect for low values of rad and level=0==> quasi only level 1 is effective + if (rad < lim0 / 60.f && level == 0) { + expkoef *= abs (repart); //reduce effect for low values of rad and level=0==> quasi only level 1 is effective } } if (cp.reinforce == 1) { - if(rad < lim0 / 60.f && level == 1) { + if (rad < lim0 / 60.f && level == 1) { expkoef /= repart; //increase effect for low values of rad and level=1==> quasi only level 0 is effective } } @@ -2733,21 +2733,21 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit //take into account local contrast float refin = value * exp (expkoef); - if(cp.link && cp.noiseena) { //combi + if (cp.link && cp.noiseena) { //combi { - if(level == 0) { + if (level == 0) { refin *= (1.f + cp.lev0s / 50.f); // we can change this sensibility! } - if(level == 1) { + if (level == 1) { refin *= (1.f + cp.lev1s / 50.f); } - if(level == 2) { + if (level == 2) { refin *= (1.f + cp.lev2s / 50.f); } - if(level == 3) { + if (level == 3) { refin *= (1.f + cp.lev3s / 50.f); } } @@ -2755,13 +2755,13 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float edgePrecalc = 1.f + refin; //estimate edge "pseudo variance" - if(cp.EDmet == 2) { //curve + if (cp.EDmet == 2) { //curve // if(exa) {//curve float insigma = 0.666f; //SD - float logmax = log(MaxP[level]); //log Max + float logmax = log (MaxP[level]); //log Max float rapX = (mean[level] + sigma[level]) / MaxP[level]; //rapport between sD / max - float inx = log(insigma); - float iny = log(rapX); + float inx = log (insigma); + float iny = log (rapX); float rap = inx / iny; //koef float asig = 0.166f / sigma[level]; float bsig = 0.5f - asig * mean[level]; @@ -2771,21 +2771,21 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float kmul; int borderL = 1; - for(int i = borderL; i < H_L - borderL; i++ ) { - for(int j = borderL; j < W_L - borderL; j++) { + for (int i = borderL; i < H_L - borderL; i++ ) { + for (int j = borderL; j < W_L - borderL; j++) { int k = i * W_L + j; - if(cp.detectedge) { - if(!lipschitz) { - if(cp.eddet > 10.f) { + if (cp.detectedge) { + if (!lipschitz) { + if (cp.eddet > 10.f) { edge = (aedstr * cp.eddet + bedstr) * (edgePrecalc * (1.f + koe[k])) / (1.f + 0.9f * maxkoe); } else { edge = (edgePrecalc * (1.f + koe[k])) / (1.f + 0.9f * maxkoe); } } - if(lipschitz) { - if(level < 4) { + if (lipschitz) { + if (level < 4) { edge = 1.f + (edgePrecalc - 1.f) * (koeLi[level * 3][k]) / (1.f + 0.9f * maxkoeLi[level * 3 + dir - 1]); } else { edge = edgePrecalc; @@ -2795,17 +2795,17 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit edge = edgePrecalc; } - if(cp.edgcurv) { - if(fabs(WavCoeffs_L[dir][k]) >= (mean[level] + sigma[level])) { //for max - float valcour = log(fabs(WavCoeffs_L[dir][k])); + if (cp.edgcurv) { + if (fabs (WavCoeffs_L[dir][k]) >= (mean[level] + sigma[level])) { //for max + float valcour = log (fabs (WavCoeffs_L[dir][k])); float valc = valcour - logmax; float vald = valc * rap; - absciss = exp(vald); + absciss = exp (vald); - } else if(fabs(WavCoeffs_L[dir][k]) >= mean[level] && fabs(WavCoeffs_L[dir][k]) < (mean[level] + sigma[level])) { - absciss = asig * fabs(WavCoeffs_L[dir][k]) + bsig; - } else if(fabs(WavCoeffs_L[dir][k]) < mean[level]) { - absciss = amean * fabs(WavCoeffs_L[dir][k]); + } else if (fabs (WavCoeffs_L[dir][k]) >= mean[level] && fabs (WavCoeffs_L[dir][k]) < (mean[level] + sigma[level])) { + absciss = asig * fabs (WavCoeffs_L[dir][k]) + bsig; + } else if (fabs (WavCoeffs_L[dir][k]) < mean[level]) { + absciss = amean * fabs (WavCoeffs_L[dir][k]); } // Threshold adjuster settings==> approximative for curve @@ -2826,7 +2826,7 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float am = (abssd - bbssd) / 0.666f; float kmuld = 0.f; - if(absciss > 0.666f && absciss < 1.f) { + if (absciss > 0.666f && absciss < 1.f) { kmul = a_abssd * absciss + b_abssd; //about max ==> kinterm kmuld = da_abssd * absciss + db_abssd; } else { @@ -2837,20 +2837,20 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float kc = kmul * (wavCLVCcurve[absciss * 500.f] - 0.5f); float kcd = kmuld * (wavCLVCcurve[absciss * 500.f] - 0.5f); - if(kc >= 0.f) { + if (kc >= 0.f) { float reduceeffect = 0.6f; kinterm = 1.f + reduceeffect * kmul * (wavCLVCcurve[absciss * 500.f] - 0.5f); //about 1 to 3 general and big amplification for max (under 0) } else { - kinterm = 1.f - (SQR(kcd)) / 10.f; + kinterm = 1.f - (SQR (kcd)) / 10.f; } - if(kinterm < 0.f) { + if (kinterm < 0.f) { kinterm = 0.01f; } edge *= kinterm; - if(edge < 1.f) { + if (edge < 1.f) { edge = 1.f; } } @@ -2858,44 +2858,44 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit WavCoeffs_L[dir][k] *= edge; } } - } else if(cp.EDmet == 1) { //threshold adjuster - float MaxPCompare = MaxP[level] * SQR(cp.edg_max / 100.f); //100 instead of b_r...case if b_r < 100 - float MaxNCompare = MaxN[level] * SQR(cp.edg_max / 100.f); //always rduce a little edge for near max values - float edgeSdCompare = (mean[level] + 1.5f * sigma[level]) * SQR(cp.edg_sd / t_r); // 1.5 standard deviation #80% range between mean 50% and 80% - float edgeMeanCompare = mean[level] * SQR(cp.edg_mean / t_l); - float edgeLowCompare = (5.f + SQR(cp.edg_low)); - float edgeMeanFactor = cbrt(cp.edg_mean / t_l); + } else if (cp.EDmet == 1) { //threshold adjuster + float MaxPCompare = MaxP[level] * SQR (cp.edg_max / 100.f); //100 instead of b_r...case if b_r < 100 + float MaxNCompare = MaxN[level] * SQR (cp.edg_max / 100.f); //always rduce a little edge for near max values + float edgeSdCompare = (mean[level] + 1.5f * sigma[level]) * SQR (cp.edg_sd / t_r); // 1.5 standard deviation #80% range between mean 50% and 80% + float edgeMeanCompare = mean[level] * SQR (cp.edg_mean / t_l); + float edgeLowCompare = (5.f + SQR (cp.edg_low)); + float edgeMeanFactor = cbrt (cp.edg_mean / t_l); float interm; - if(cp.edg_low < 10.f) { - interm = cbrt((5.f + cp.edg_low) / 5.f); + if (cp.edg_low < 10.f) { + interm = cbrt ((5.f + cp.edg_low) / 5.f); } else { interm = 1.437f; //cbrt(3); } float edgeLowFactor = interm; float edgeSdFactor = cp.edg_sd / t_r; - float edgeMaxFactor = SQR(cp.edg_max / b_r); + float edgeMaxFactor = SQR (cp.edg_max / b_r); float edgMaxFsup = (cp.edg_max / b_r); //reduce increase of effect for high values contrast..if slider > b_r //for (int i=0; i 10.f) { + if (cp.detectedge) { + if (!lipschitz) { + if (cp.eddet > 10.f) { edge = (aedstr * cp.eddet + bedstr) * (edgePrecalc * (1.f + koe[k])) / (1.f + 0.9f * maxkoe); } else { edge = (edgePrecalc * (1.f + koe[k])) / (1.f + 0.9f * maxkoe); } } - if(lipschitz) { - if(level < 4) { + if (lipschitz) { + if (level < 4) { edge = 1.f + (edgePrecalc - 1.f) * (koeLi[level * 3][k]) / (1.f + 0.9f * maxkoeLi[level * 3 + dir - 1]); } else { edge = edgePrecalc; @@ -2915,17 +2915,17 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit // If we move sliders to the left, local contrast is reduced // if we move sliders to the right local contrast is increased // MaxP, MaxN, mean, sigma are calculated if necessary (val > 0) by evaluate2(), eval2(), aver() , sigma() - if(b_r < 100.f && cp.edg_max / b_r > 1.f) { //in case of b_r < 100 and slider move to right + if (b_r < 100.f && cp.edg_max / b_r > 1.f) { //in case of b_r < 100 and slider move to right if (WavCoeffs_L[dir][k] > MaxPCompare * cp.edg_max / b_r) { edge *= edgMaxFsup; - if(edge < 1.f) { + if (edge < 1.f) { edge = 1.f; } } else if (WavCoeffs_L[dir][k] < MaxNCompare * cp.edg_max / b_r) { edge *= edgMaxFsup; - if(edge < 1.f) { + if (edge < 1.f) { edge = 1.f; } } @@ -2934,39 +2934,39 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit if (WavCoeffs_L[dir][k] > MaxPCompare) { edge *= edgeMaxFactor; - if(edge < 1.f) { + if (edge < 1.f) { edge = 1.f; } }//reduce edge if > new max else if (WavCoeffs_L[dir][k] < MaxNCompare) { edge *= edgeMaxFactor; - if(edge < 1.f) { + if (edge < 1.f) { edge = 1.f; } } - if (fabs(WavCoeffs_L[dir][k]) >= edgeMeanCompare && fabs(WavCoeffs_L[dir][k]) < edgeSdCompare) { + if (fabs (WavCoeffs_L[dir][k]) >= edgeMeanCompare && fabs (WavCoeffs_L[dir][k]) < edgeSdCompare) { //if (fabs(WavCoeffs_L[dir][i]) > edgeSdCompare) { edge *= edgeSdFactor; - if(edge < 1.f) { + if (edge < 1.f) { edge = 1.f; } }//mofify effect if sd change - if (fabs(WavCoeffs_L[dir][k]) < edgeMeanCompare) { + if (fabs (WavCoeffs_L[dir][k]) < edgeMeanCompare) { edge *= edgeMeanFactor; - if(edge < 1.f) { + if (edge < 1.f) { edge = 1.f; } } // modify effect if mean change - if (fabs(WavCoeffs_L[dir][k]) < edgeLowCompare) { + if (fabs (WavCoeffs_L[dir][k]) < edgeLowCompare) { edge *= edgeLowFactor; - if(edge < 1.f) { + if (edge < 1.f) { edge = 1.f; } } @@ -2976,29 +2976,29 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit } } - if(!lipschitz) { + if (!lipschitz) { delete [] koe; } } - if(!cp.link && cp.noiseena) { //used both with denoise 1 2 3 + if (!cp.link && cp.noiseena) { //used both with denoise 1 2 3 float refine = 0.f; for (int i = 0; i < W_L * H_L; i++) { - if(level == 0) { + if (level == 0) { refine = cp.lev0s / 40.f; } - if(level == 1) { + if (level == 1) { refine = cp.lev1s / 40.f; } - if(level == 2) { + if (level == 2) { refine = cp.lev2s / 40.f; } - if(level == 3) { + if (level == 3) { refine = cp.lev3s / 40.f; } @@ -3009,7 +3009,7 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float cpMul = cp.mul[level]; - if(cpMul != 0.f && cp.contena) { // cpMul == 0.f means all will be multiplied by 1.f, so we can skip this + if (cpMul != 0.f && cp.contena) { // cpMul == 0.f means all will be multiplied by 1.f, so we can skip this const float skinprot = params->wavelet.skinprotect; const float skinprotneg = -skinprot; @@ -3036,30 +3036,30 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit for (int i = 0; i < W_L * H_L; i++) { float kLlev = 1.f; - if(cpMul < 0.f) { + if (cpMul < 0.f) { beta = 1.f; // disabled for negatives values "less contrast" } else { - float WavCL = fabsf(WavCoeffs_L[dir][i]); + float WavCL = fabsf (WavCoeffs_L[dir][i]); //reduction amplification: max action between mean / 2 and mean + sigma // arbitrary coefficient, we can add a slider !! - if(WavCL < mea[0]) { + if (WavCL < mea[0]) { beta = 0.6f; //preserve very low contrast (sky...) - } else if(WavCL < mea[1]) { + } else if (WavCL < mea[1]) { beta = 0.8f; - } else if(WavCL < mea[2]) { + } else if (WavCL < mea[2]) { beta = 1.f; //standard - } else if(WavCL < mea[3]) { + } else if (WavCL < mea[3]) { beta = 1.f; - } else if(WavCL < mea[4]) { + } else if (WavCL < mea[4]) { beta = 0.8f; //+sigma - } else if(WavCL < mea[5]) { + } else if (WavCL < mea[5]) { beta = 0.6f; - } else if(WavCL < mea[6]) { + } else if (WavCL < mea[6]) { beta = 0.4f; - } else if(WavCL < mea[7]) { + } else if (WavCL < mea[7]) { beta = 0.2f; // + 2 sigma - } else if(WavCL < mea[8]) { + } else if (WavCL < mea[8]) { beta = 0.1f; } else { beta = 0.0f; @@ -3076,10 +3076,10 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float LL = labco->L[ii * 2][jj * 2]; LL100 = LL100init = LL / 327.68f; LL100res = WavCoeffs_L0[i] / 327.68f; - float delta = fabs(LL100init - LL100res) / (maxlvl / 2); + float delta = fabs (LL100init - LL100res) / (maxlvl / 2); - for(int ml = 0; ml < maxlvl; ml++) { - if(ml < maxlvl / 2) { + for (int ml = 0; ml < maxlvl; ml++) { + if (ml < maxlvl / 2) { kH[ml] = (LL100res + ml * delta) / LL100res; // fixed a priori max to level middle } else { kH[ml] = (LL100init - ml * delta) / LL100res; @@ -3087,15 +3087,15 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit } - if(useChromAndHue) { + if (useChromAndHue) { float modhue = varhue[ii][jj]; modchro = varchrom[ii * 2][jj * 2]; // hue chroma skin with initial lab datas scale = 1.f; - if(skinprot > 0.f) { + if (skinprot > 0.f) { Color::SkinSatCbdl2 (LL100, modhue, modchro, skinprot, scale, true, cp.b_l, cp.t_l, cp.t_r, cp.b_r, 0); //0 for skin and extand - } else if(skinprot < 0.f) { + } else if (skinprot < 0.f) { Color::SkinSatCbdl2 (LL100, modhue, modchro, skinprotneg, scale, false, cp.b_l, cp.t_l, cp.t_r, cp.b_r, 0); if (scale == 1.f) { @@ -3107,14 +3107,14 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit } - if(Chutili) { + if (Chutili) { int i_i = i / W_L; int j_j = i - i_i * W_L; double lr; float modhue2 = varhue[i_i][j_j]; - float valparam = float((ChCurve->getVal(lr = Color::huelab_to_huehsv2(modhue2)) - 0.5f)); //get valparam=f(H) + float valparam = float ((ChCurve->getVal (lr = Color::huelab_to_huehsv2 (modhue2)) - 0.5f)); //get valparam=f(H) - if(valparam > 0.f) { + if (valparam > 0.f) { scale2 = 1.f + 3.f * valparam; //arbitrary value } else { scale2 = 1.f + 1.9f * valparam; //near 0 but not zero if curve # 0 @@ -3125,7 +3125,7 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float diagacc = 1.f; float alpha = (1024.f + 15.f * (float) cpMul * scale * scale2 * beta * diagacc) / 1024.f ; - if(cp.HSmet && cp.contena) { + if (cp.HSmet && cp.contena) { float aaal = (1.f - alpha) / ((cp.b_lhl - cp.t_lhl) * kH[level]); float bbal = 1.f - aaal * cp.b_lhl * kH[level]; float aaar = (alpha - 1.f) / (cp.t_rhl - cp.b_rhl) * kH[level]; @@ -3136,24 +3136,24 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float aaarS = (alpha - 1.f) / (cp.t_rsl - cp.b_rsl); float bbbrS = 1.f - cp.b_rsl * aaarS; - if(level <= cp.numlevH) { //in function of levels - if((LL100 > cp.t_lhl * kH[level] && LL100 < cp.t_rhl * kH[level])) { + if (level <= cp.numlevH) { //in function of levels + if ((LL100 > cp.t_lhl * kH[level] && LL100 < cp.t_rhl * kH[level])) { kLlev = alpha; - } else if((LL100 > cp.b_lhl * kH[level] && LL100 <= cp.t_lhl * kH[level])) { + } else if ((LL100 > cp.b_lhl * kH[level] && LL100 <= cp.t_lhl * kH[level])) { kLlev = aaal * LL100 + bbal; - } else if((LL100 > cp.t_rhl * kH[level] && LL100 <= cp.b_rhl * kH[level])) { + } else if ((LL100 > cp.t_rhl * kH[level] && LL100 <= cp.b_rhl * kH[level])) { kLlev = aaar * LL100 + bbbr; } else { kLlev = 1.f; } } - if(level >= (9 - cp.numlevS)) { - if((LL100 > cp.t_lsl && LL100 < cp.t_rsl)) { + if (level >= (9 - cp.numlevS)) { + if ((LL100 > cp.t_lsl && LL100 < cp.t_rsl)) { kLlev = alpha; - } else if((LL100 > cp.b_lsl && LL100 <= cp.t_lsl)) { + } else if ((LL100 > cp.b_lsl && LL100 <= cp.t_lsl)) { kLlev = aaalS * LL100 + bbalS; - } else if((LL100 > cp.t_rsl && LL100 <= cp.b_rsl)) { + } else if ((LL100 > cp.t_rsl && LL100 <= cp.b_rsl)) { kLlev = aaarS * LL100 + bbbrS; } else { kLlev = 1.f; @@ -3168,27 +3168,27 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit } } - if(waOpacityCurveW) { + if (waOpacityCurveW) { cp.opaW = true; } - if(cp.bam && cp.finena) { - if(cp.opaW && cp.BAmet == 2) { + if (cp.bam && cp.finena) { + if (cp.opaW && cp.BAmet == 2) { int iteration = cp.ite; int itplus = 7 + iteration; int itmoins = 7 - iteration; int med = maxlvl / 2; int it; - if(level < med) { + if (level < med) { it = itmoins; - } else if(level == med) { + } else if (level == med) { it = 7; - } else /*if(level > med)*/ { + } else { /*if(level > med)*/ it = itplus; } - for(int j = 0; j < it; j++) { + for (int j = 0; j < it; j++) { //float bal = cp.balan;//-100 +100 float kba = 1.f; @@ -3201,11 +3201,11 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float k1 = 0.3f * (waOpacityCurveW[6.f * LL100] - 0.5f); //k1 between 0 and 0.5 0.5==> 1/6=0.16 float k2 = k1 * 2.f; - if(dir < 3) { + if (dir < 3) { kba = 1.f + k1; } - if(dir == 3) { + if (dir == 3) { kba = 1.f - k2; } @@ -3214,22 +3214,22 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit } } - if(cp.BAmet == 1) { + if (cp.BAmet == 1) { int iteration = cp.ite; int itplus = 7 + iteration; int itmoins = 7 - iteration; int med = maxlvl / 2; int it; - if(level < med) { + if (level < med) { it = itmoins; - } else if(level == med) { + } else if (level == med) { it = 7; - } else /*if(level > med)*/ { + } else { /*if(level > med)*/ it = itplus; } - for(int j = 0; j < it; j++) { + for (int j = 0; j < it; j++) { float bal = cp.balan;//-100 +100 float kba = 1.f; @@ -3246,12 +3246,12 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit float b0 = 100000.f; float a0 = -4970.f; - if(LL100 > 80.f) { + if (LL100 > 80.f) { k1 = aa * LL100 + bb; k2 = 0.5f * k1; } - if(LL100 < 20.f) { + if (LL100 < 20.f) { k1 = a0 * LL100 + b0; k2 = 0.5f * k1; } @@ -3260,11 +3260,11 @@ void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschit //k2=300.f; //k1=0.3f*(waOpacityCurveW[6.f*LL100]-0.5f);//k1 between 0 and 0.5 0.5==> 1/6=0.16 //k2=k1*2.f; - if(dir < 3) { + if (dir < 3) { kba = 1.f + bal / k1; } - if(dir == 3) { + if (dir == 3) { kba = 1.f - bal / k2; } @@ -3276,7 +3276,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 = atoi (params->wavelet.Lmethod.data()) - 1; choicelevel = choicelevel == -1 ? 4 : choicelevel; } @@ -3285,7 +3285,7 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, { float cpMul = cp.mul[level]; - if(cpMul != 0.f && cp.CHmet == 2 && cp.chro != 0.f && cp.chromena) { // cpMul == 0.f or cp.chro = 0.f means all will be multiplied by 1.f, so we can skip this + if (cpMul != 0.f && cp.CHmet == 2 && cp.chro != 0.f && cp.chromena) { // cpMul == 0.f or cp.chro = 0.f means all will be multiplied by 1.f, so we can skip this const float skinprot = params->wavelet.skinprotect; const float skinprotneg = -skinprot; const float factorHard = (1.f - skinprotneg / 100.f); @@ -3296,7 +3296,7 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, float alphaC = (1024.f + 15.f * cpMul * cpChrom / 50.f) / 1024.f ; for (int i = 0; i < W_ab * H_ab; i++) { - if(useSkinControl) { + if (useSkinControl) { int ii = i / W_ab; int jj = i - ii * W_ab; float LL100 = labco->L[ii * 2][jj * 2] / 327.68f; @@ -3305,9 +3305,9 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, // hue chroma skin with initial lab datas float scale = 1.f; - if(skinprot > 0.f) { + if (skinprot > 0.f) { Color::SkinSatCbdl2 (LL100, modhue, modchro, skinprot, scale, true, cp.b_l, cp.t_l, cp.t_r, cp.b_r, 0); //0 for skin and extand - } else if(skinprot < 0.f) { + } else if (skinprot < 0.f) { Color::SkinSatCbdl2 (LL100, modhue, modchro, skinprotneg, scale, false, cp.b_l, cp.t_l, cp.t_r, cp.b_r, 0); scale = (scale == 1.f) ? factorHard : 1.f; } @@ -3324,7 +3324,7 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, float cpMulC = cp.mulC[level]; // if( (cp.curv || cp.CHSLmet==1) && cp.CHmet!=2 && level < 9 && cpMulC != 0.f) { // cpMulC == 0.f means all will be multiplied by 1.f, so we can skip - if( cp.CHmet != 2 && level < 9 && cpMulC != 0.f && cp.chromena) { // cpMulC == 0.f means all will be multiplied by 1.f, so we can skip + if ( cp.CHmet != 2 && level < 9 && cpMulC != 0.f && cp.chromena) { // cpMulC == 0.f means all will be multiplied by 1.f, so we can skip const float skinprot = params->wavelet.skinprotect; const float skinprotneg = -skinprot; const float factorHard = (1.f - skinprotneg / 100.f); @@ -3337,14 +3337,14 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, float scale = 1.f; float modchro = varchrom[ii * 2][jj * 2]; - if(useSkinControl) { + if (useSkinControl) { // hue chroma skin with initial lab datas float LL100 = labco->L[ii * 2][jj * 2] / 327.68f; float modhue = varhue[ii][jj]; - if(skinprot > 0.f) { + if (skinprot > 0.f) { Color::SkinSatCbdl2 (LL100, modhue, modchro, skinprot, scale, true, cp.b_l, cp.t_l, cp.t_r, cp.b_r, 1); //1 for curve - } else if(skinprot < 0.f) { + } else if (skinprot < 0.f) { Color::SkinSatCbdl2 (LL100, modhue, modchro, skinprotneg, scale, false, cp.b_l, cp.t_l, cp.t_r, cp.b_r, 1); scale = (scale == 1.f) ? factorHard : 1.f; } @@ -3352,22 +3352,22 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, float beta = (1024.f + 20.f * cpMulC * scale) / 1024.f ; - if(beta < 0.02f) { + if (beta < 0.02f) { beta = 0.02f; } float kClev = beta; - if(cp.CHmet == 1) { - if(level < cp.chrom) { + if (cp.CHmet == 1) { + if (level < cp.chrom) { //linear for saturated - if((modchro > cp.t_lsat && modchro < cp.t_rsat)) { + if ((modchro > cp.t_lsat && modchro < cp.t_rsat)) { kClev = beta; - } else if((modchro > cp.b_lsat && modchro <= cp.t_lsat)) { + } else if ((modchro > cp.b_lsat && modchro <= cp.t_lsat)) { float aaal = (1.f - beta) / (cp.b_lsat - cp.t_lsat); float bbal = 1.f - aaal * cp.b_lsat; kClev = aaal * modchro + bbal; - } else if((modchro > cp.t_rsat && modchro <= cp.b_rsat)) { + } else if ((modchro > cp.t_rsat && modchro <= cp.b_rsat)) { float aaar = (beta - 1.f) / (cp.t_rsat - cp.b_rsat); float bbbr = 1.f - cp.b_rsat * aaar; kClev = aaar * modchro + bbbr; @@ -3376,13 +3376,13 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, } } else { //linear for pastel - if((modchro > cp.t_lpast && modchro < cp.t_rpast)) { + if ((modchro > cp.t_lpast && modchro < cp.t_rpast)) { kClev = beta; - } else if((modchro > cp.b_lpast && modchro <= cp.t_lpast)) { + } else if ((modchro > cp.b_lpast && modchro <= cp.t_lpast)) { float aaalS = (1.f - beta) / (cp.b_lpast - cp.t_lpast); float bbalS = 1.f - aaalS * cp.b_lpast; kClev = aaalS * modchro + bbalS; - } else if((modchro > cp.t_rpast && modchro <= cp.b_rpast)) { + } else if ((modchro > cp.t_rpast && modchro <= cp.b_rpast)) { float aaarS = (beta - 1.f) / (cp.t_rpast - cp.b_rpast); float bbbrS = 1.f - cp.b_rpast * aaarS; kClev = aaarS * modchro + bbbrS; @@ -3390,7 +3390,7 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, kClev = 1.f; } } - } else if(cp.CHmet == 0) { + } else if (cp.CHmet == 0) { kClev = beta; } @@ -3401,7 +3401,7 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, bool useOpacity; float mulOpacity; - if(useChannelA) { + if (useChannelA) { useOpacity = cp.opaRG; mulOpacity = cp.mulopaRG[level]; } else { @@ -3409,7 +3409,7 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, mulOpacity = cp.mulopaBY[level]; } - if((useOpacity && level < 9 && mulOpacity != 0.f) && cp.toningena) { //toning + if ((useOpacity && level < 9 && mulOpacity != 0.f) && cp.toningena) { //toning float beta = (1024.f + 20.f * mulOpacity) / 1024.f ; @@ -3421,28 +3421,28 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, // WavCoeffs_ab[dir][i] += beta; } - if(waOpacityCurveW) { + if (waOpacityCurveW) { cp.opaW = true; } - if(cp.bam && cp.diag) { + if (cp.bam && cp.diag) { //printf("OK Chroma\n"); - if(cp.opaW && cp.BAmet == 2) { + if (cp.opaW && cp.BAmet == 2) { int iteration = cp.ite; int itplus = 7 + iteration; int itmoins = 7 - iteration; int med = maxlvl / 2; int it; - if(level < med) { + if (level < med) { it = itmoins; - } else if(level == med) { + } else if (level == med) { it = 7; - } else /*if(level > med)*/ { + } else { /*if(level > med)*/ it = itplus; } - for(int j = 0; j < it; j++) { + for (int j = 0; j < it; j++) { //float bal = cp.balan;//-100 +100 float kba = 1.f; @@ -3455,11 +3455,11 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, float k1 = 0.3f * (waOpacityCurveW[6.f * LL100] - 0.5f); //k1 between 0 and 0.5 0.5==> 1/6=0.16 float k2 = k1 * 2.f; - if(dir < 3) { + if (dir < 3) { kba = 1.f + k1; } - if(dir == 3) { + if (dir == 3) { kba = 1.f - k2; } @@ -3468,22 +3468,22 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, } } - if(cp.BAmet == 1) { + if (cp.BAmet == 1) { int iteration = cp.ite; int itplus = 7 + iteration; int itmoins = 7 - iteration; int med = maxlvl / 2; int it; - if(level < med) { + if (level < med) { it = itmoins; - } else if(level == med) { + } else if (level == med) { it = 7; - } else /*if(level > med)*/ { + } else { /*if(level > med)*/ it = itplus; } - for(int j = 0; j < it; j++) { + for (int j = 0; j < it; j++) { float bal = cp.balan;//-100 +100 float kba = 1.f; @@ -3500,12 +3500,12 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, float b0 = 100000.f; float a0 = -4970.f; - if(LL100 > 80.f) { + if (LL100 > 80.f) { k1 = aa * LL100 + bb; k2 = 0.5f * k1; } - if(LL100 < 20.f) { + if (LL100 < 20.f) { k1 = a0 * LL100 + b0; k2 = 0.5f * k1; } @@ -3514,11 +3514,11 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, //k2=300.f; //k1=0.3f*(waOpacityCurveW[6.f*LL100]-0.5f);//k1 between 0 and 0.5 0.5==> 1/6=0.16 //k2=k1*2.f; - if(dir < 3) { + if (dir < 3) { kba = 1.f + bal / k1; } - if(dir == 3) { + if (dir == 3) { kba = 1.f - bal / k2; } @@ -3530,38 +3530,38 @@ 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 = atoi (params->wavelet.Lmethod.data()) - 1; choicelevel = choicelevel == -1 ? 4 : choicelevel; int choiceClevel = 0; - if(params->wavelet.CLmethod == "one") { + if (params->wavelet.CLmethod == "one") { choiceClevel = 0; - } else if(params->wavelet.CLmethod == "inf") { + } else if (params->wavelet.CLmethod == "inf") { choiceClevel = 1; - } else if(params->wavelet.CLmethod == "sup") { + } else if (params->wavelet.CLmethod == "sup") { choiceClevel = 2; - } else if(params->wavelet.CLmethod == "all") { + } else if (params->wavelet.CLmethod == "all") { choiceClevel = 3; } int choiceDir = 0; - if(params->wavelet.Dirmethod == "one") { + if (params->wavelet.Dirmethod == "one") { choiceDir = 1; - } else if(params->wavelet.Dirmethod == "two") { + } else if (params->wavelet.Dirmethod == "two") { choiceDir = 2; - } else if(params->wavelet.Dirmethod == "thr") { + } else if (params->wavelet.Dirmethod == "thr") { choiceDir = 3; - } else if(params->wavelet.Dirmethod == "all") { + } else if (params->wavelet.Dirmethod == "all") { choiceDir = 0; } int dir1 = (choiceDir == 2) ? 1 : 2; int dir2 = (choiceDir == 3) ? 1 : 3; - if(choiceClevel < 3) { // not all levels visible, paint residual - if(level == 0) { - if(cp.backm != 2) { // nothing to change when residual is used as background + if (choiceClevel < 3) { // not all levels visible, paint residual + if (level == 0) { + if (cp.backm != 2) { // nothing to change when residual is used as background for (int i = 0; i < W_ab * H_ab; i++) { WavCoeffs_ab0[i] = 0.f; } @@ -3569,9 +3569,9 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, } } - if(choiceClevel == 0) { // Only one level - if(choiceDir == 0) { // All directions - if(level != choicelevel) { // zero all for the levels != choicelevel + if (choiceClevel == 0) { // Only one level + if (choiceDir == 0) { // All directions + if (level != choicelevel) { // zero all for the levels != choicelevel for (int dir = 1; dir < 4; dir++) { for (int i = 0; i < W_ab * H_ab; i++) { WavCoeffs_ab[dir][i] = 0.f; @@ -3579,21 +3579,21 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, } } } else { // zero the unwanted directions for level == choicelevel - if(choicelevel >= cp.maxilev) { + if (choicelevel >= cp.maxilev) { for (int dir = 1; dir < 4; dir++) { for (int i = 0; i < W_ab * H_ab; i++) { WavCoeffs_ab[dir][i] = 0.f; } } - } else if(level != choicelevel) { // zero all for the levels != choicelevel + } else if (level != choicelevel) { // zero all for the levels != choicelevel for (int i = 0; i < W_ab * H_ab; i++) { WavCoeffs_ab[dir1][i] = WavCoeffs_ab[dir2][i] = 0.f; } } } - } else if(choiceClevel == 1) { // Only below level - if(choiceDir == 0) { // All directions - if(level > choicelevel) { + } else if (choiceClevel == 1) { // Only below level + if (choiceDir == 0) { // All directions + if (level > choicelevel) { for (int dir = 1; dir < 4; dir++) { for (int i = 0; i < W_ab * H_ab; i++) { WavCoeffs_ab[dir][i] = 0.f; @@ -3601,15 +3601,15 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, } } } else { // zero the unwanted directions for level >= choicelevel - if(level > choicelevel) { + if (level > choicelevel) { for (int i = 0; i < W_ab * H_ab; i++) { WavCoeffs_ab[dir1][i] = WavCoeffs_ab[dir2][i] = 0.f; } } } - } else if(choiceClevel == 2) { // Only above level - if(choiceDir == 0) { // All directions - if(level <= choicelevel) { + } else if (choiceClevel == 2) { // Only above level + if (choiceDir == 0) { // All directions + if (level <= choicelevel) { for (int dir = 1; dir < 4; dir++) { for (int i = 0; i < W_ab * H_ab; i++) { WavCoeffs_ab[dir][i] = 0.f; @@ -3617,13 +3617,13 @@ void ImProcFunctions::ContAllAB (LabImage * labco, int maxlvl, float ** varhue, } } } else { // zero the unwanted directions for level >= choicelevel - if(choicelevel >= cp.maxilev) { + if (choicelevel >= cp.maxilev) { for (int dir = 1; dir < 4; dir++) { for (int i = 0; i < W_ab * H_ab; i++) { WavCoeffs_ab[dir][i] = 0.f; } } - } else if(level <= choicelevel) { + } else if (level <= choicelevel) { for (int i = 0; i < W_ab * H_ab; i++) { WavCoeffs_ab[dir1][i] = WavCoeffs_ab[dir2][i] = 0.f; } diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index fdf46270f..d2d18b7d8 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -198,24 +198,52 @@ LCPMapper::LCPMapper(LCPProfile* pProf, float focalLength, float focalLength35mm } enableCA = !vignette && focusDist > 0; + isFisheye = pProf->isFisheye; } -void LCPMapper::correctDistortion(double& x, double& y) const +void LCPMapper::correctDistortion(double& x, double& y, double scale) const { - double xd = (x - mc.x0) / mc.fx, yd = (y - mc.y0) / mc.fy; + if (isFisheye) { + double u = x * scale; + double v = y * scale; + double u0 = mc.x0 * scale; + double v0 = mc.y0 * scale; + double du = (u - u0); + double dv = (v - v0); + double fx = mc.fx; + double fy = mc.fy; + double k1 = mc.param[0]; + double k2 = mc.param[1]; + double r = sqrt(du * du + dv * dv); + double f = sqrt(fx*fy / (scale * scale)); + double th = atan2(r, f); + double th2 = th * th; + double cfact = (((k2 * th2 + k1) * th2 + 1) * th) / r; + double ud = cfact * fx * du + u0; + double vd = cfact * fy * dv + v0; - const LCPModelCommon::Param aDist = mc.param; - double rsqr = xd * xd + yd * yd; - double xfac = aDist[swapXY ? 3 : 4], yfac = aDist[swapXY ? 4 : 3]; + x = ud; + y = vd; + } else { + x *= scale; + y *= scale; + double x0 = mc.x0 * scale; + double y0 = mc.y0 * scale; + double xd = (x - x0) / mc.fx, yd = (y - y0) / mc.fy; - double commonFac = (((aDist[2] * rsqr + aDist[1]) * rsqr + aDist[0]) * rsqr + 1.) - + 2. * (yfac * yd + xfac * xd); + const LCPModelCommon::Param aDist = mc.param; + double rsqr = xd * xd + yd * yd; + double xfac = aDist[swapXY ? 3 : 4], yfac = aDist[swapXY ? 4 : 3]; - double xnew = xd * commonFac + xfac * rsqr; - double ynew = yd * commonFac + yfac * rsqr; + double commonFac = (((aDist[2] * rsqr + aDist[1]) * rsqr + aDist[0]) * rsqr + 1.) + + 2. * (yfac * yd + xfac * xd); - x = xnew * mc.fx + mc.x0; - y = ynew * mc.fy + mc.y0; + double xnew = xd * commonFac + xfac * rsqr; + double ynew = yd * commonFac + yfac * rsqr; + + x = xnew * mc.fx + x0; + y = ynew * mc.fy + y0; + } } void LCPMapper::correctCA(double& x, double& y, int channel) const diff --git a/rtengine/lcp.h b/rtengine/lcp.h index e108e61b7..8cfcd5694 100644 --- a/rtengine/lcp.h +++ b/rtengine/lcp.h @@ -142,6 +142,7 @@ class LCPMapper bool swapXY; LCPModelCommon mc; LCPModelCommon chrom[3]; // in order RedGreen/Green/BlueGreen + bool isFisheye; public: bool enableCA; // is the mapper capable if CA correction? @@ -150,7 +151,7 @@ public: LCPMapper(LCPProfile* pProf, float focalLength, float focalLength35mm, float focusDist, float aperture, bool vignette, bool useCADistP, int fullWidth, int fullHeight, const CoarseTransformParams& coarse, int rawRotationDeg); - void correctDistortion(double& x, double& y) const; // MUST be the first stage + void correctDistortion(double& x, double& y, double scale) const; // MUST be the first stage void correctCA(double& x, double& y, int channel) const; void processVignetteLine(int width, int y, float *line) const; void processVignetteLine3Channels(int width, int y, float *line) const; diff --git a/rtengine/pipettebuffer.cc b/rtengine/pipettebuffer.cc index 6f6d9dcef..8981b6480 100644 --- a/rtengine/pipettebuffer.cc +++ b/rtengine/pipettebuffer.cc @@ -28,12 +28,6 @@ PipetteBuffer::PipetteBuffer(::EditDataProvider *dataProvider) : PipetteBuffer::~PipetteBuffer() { flush(); -#ifndef NDEBUG - imgFloatBuffer = (Imagefloat*)(0xbaadf00d); -#endif -#ifndef NDEBUG - LabBuffer = (LabImage*)(0xbaadf00d); -#endif } void PipetteBuffer::createBuffer(int width, int height) diff --git a/rtengine/pixelshift.cc b/rtengine/pixelshift.cc index 744950ba8..0a6d24688 100644 --- a/rtengine/pixelshift.cc +++ b/rtengine/pixelshift.cc @@ -994,10 +994,11 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA #ifdef PIXELSHIFTDEV if(detectMotion || (adaptive && checkGreen)) { bool skipNext = false; + float gridMax = 0.f; #else if(adaptive && checkGreen) { -#endif float gridMax; +#endif #ifdef PIXELSHIFTDEV diff --git a/rtengine/previewimage.cc b/rtengine/previewimage.cc index 1bf11dc17..29b319d2c 100644 --- a/rtengine/previewimage.cc +++ b/rtengine/previewimage.cc @@ -76,23 +76,17 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext previewImage = Cairo::ImageSurface::create(Cairo::FORMAT_RGB24, w, h); previewImage->flush(); - #pragma omp parallel - { - const unsigned char *src; - unsigned char *dst; - #pragma omp for schedule(static,10) + #pragma omp parallel for + for (unsigned int i = 0; i < (unsigned int)(h); ++i) { + const unsigned char *src = data + i * w * 3; + unsigned char *dst = previewImage->get_data() + i * w * 4; - for (unsigned int i = 0; i < (unsigned int)(h); ++i) { - src = data + i * w * 3; - dst = previewImage->get_data() + i * w * 4; + for (unsigned int j = 0; j < (unsigned int)(w); ++j) { + unsigned char r = *(src++); + unsigned char g = *(src++); + unsigned char b = *(src++); - for (unsigned int j = 0; j < (unsigned int)(w); ++j) { - unsigned char r = *(src++); - unsigned char g = *(src++); - unsigned char b = *(src++); - - poke255_uc(dst, r, g, b); - } + poke255_uc(dst, r, g, b); } } previewImage->mark_dirty(); @@ -139,29 +133,22 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext if (data) { int w, h; - // double scale = 1.; w = output->getWidth(); h = output->getHeight(); previewImage = Cairo::ImageSurface::create(Cairo::FORMAT_RGB24, w, h); previewImage->flush(); - #pragma omp parallel - { - const unsigned char *src; - unsigned char *dst; - #pragma omp for schedule(static,10) + #pragma omp parallel for + for (unsigned int i = 0; i < (unsigned int)(h); i++) { + const unsigned char *src = data + i * w * 3; + unsigned char *dst = previewImage->get_data() + i * w * 4; - for (unsigned int i = 0; i < (unsigned int)(h); i++) { - src = data + i * w * 3; - dst = previewImage->get_data() + i * w * 4; + for (unsigned int j = 0; j < (unsigned int)(w); j++) { + unsigned char r = *(src++); + unsigned char g = *(src++); + unsigned char b = *(src++); - for (unsigned int j = 0; j < (unsigned int)(w); j++) { - unsigned char r = *(src++); - unsigned char g = *(src++); - unsigned char b = *(src++); - - poke255_uc(dst, r, g, b); - } + poke255_uc(dst, r, g, b); } } diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index b9969ba8d..ae1ec9ba8 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -9496,7 +9496,6 @@ bool ProcParams::operator== (const ProcParams& other) && wavelet.sup == other.wavelet.sup && wavelet.sky == other.wavelet.sky && wavelet.thres == other.wavelet.thres - && wavelet.threshold == other.wavelet.threshold && wavelet.chroma == other.wavelet.chroma && wavelet.chro == other.wavelet.chro && wavelet.tmr == other.wavelet.tmr diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 551701c73..a84915ed3 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -501,7 +501,7 @@ RawImageSource::~RawImageSource () //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::transformRect (PreviewProps pp, int tran, int &ssx1, int &ssy1, int &width, int &height, int &fw) +void RawImageSource::transformRect (const PreviewProps &pp, int tran, int &ssx1, int &ssy1, int &width, int &height, int &fw) { int pp_x = pp.getX() + border; int pp_y = pp.getY() + border; @@ -1491,7 +1491,7 @@ void RawImageSource::getFullSize (int& w, int& h, int tr) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::getSize (PreviewProps pp, int& w, int& h) +void RawImageSource::getSize (const PreviewProps &pp, int& w, int& h) { w = pp.getWidth() / pp.getSkip() + (pp.getWidth() % pp.getSkip() > 0); h = pp.getHeight() / pp.getSkip() + (pp.getHeight() % pp.getSkip() > 0); @@ -2306,7 +2306,7 @@ void RawImageSource::retinexPrepareBuffers (ColorManagementParams cmp, RetinexPa } } else { TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix (cmp.working); - float wp[3][3] = { + const float wp[3][3] = { {static_cast (wprof[0][0]), static_cast (wprof[0][1]), static_cast (wprof[0][2])}, {static_cast (wprof[1][0]), static_cast (wprof[1][1]), static_cast (wprof[1][2])}, {static_cast (wprof[2][0]), static_cast (wprof[2][1]), static_cast (wprof[2][2])} diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index cfcda8477..2c0ac6f19 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -97,7 +97,7 @@ protected: void hphd_green (float** hpmap); void processFalseColorCorrectionThread (Imagefloat* im, array2D &rbconv_Y, array2D &rbconv_I, array2D &rbconv_Q, array2D &rbout_I, array2D &rbout_Q, const int row_from, const int row_to); void hlRecovery (const std::string &method, float* red, float* green, float* blue, int width, float* hlmax); - void transformRect (PreviewProps pp, int tran, int &sx1, int &sy1, int &width, int &height, int &fw); + void transformRect (const PreviewProps &pp, int tran, int &sx1, int &sy1, int &width, int &height, int &fw); void transformPosition (int x, int y, int tran, int& tx, int& ty); unsigned FC(int row, int col) @@ -156,7 +156,7 @@ public: } void getFullSize (int& w, int& h, int tr = TR_NONE); - void getSize (PreviewProps pp, int& w, int& h); + void getSize (const PreviewProps &pp, int& w, int& h); int getRotateDegree() const { return ri->get_rotateDegree(); diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index f7f899bd6..2c4067c1b 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -964,7 +964,6 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei gm = camwbGreen / gm; bm = camwbBlue / bm; double mul_lum = 0.299 * rm + 0.587 * gm + 0.114 * bm; - double logDefGain = 0.0; float rmi, gmi, bmi; rmi = rm * defGain / mul_lum; @@ -1083,6 +1082,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei int hlcomprthresh = params.toneCurve.hlcomprthresh; if (params.toneCurve.autoexp && aeHistogram) { + double logDefGain = 0.0; ipf.getAutoExp (aeHistogram, aeHistCompression, logDefGain, params.toneCurve.clip, expcomp, bright, contr, black, hlcompr, hlcomprthresh); } @@ -1488,7 +1488,7 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width) // to utilize the 8 bit color range of the thumbnail we brighten it and apply gamma correction unsigned char* tmpdata = new unsigned char[thumbImg->getHeight() * trim_width]; - int ix = 0, max; + int ix = 0; if (gammaCorrected) { // if it's gamma correct (usually a RAW), we have the problem that there is a lot noise etc. that makes the maximum way too high. @@ -1572,7 +1572,7 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width) } } else { // If it's not gamma corrected (usually a JPG) we take the normal maximum - max = 0; + int max = 0; if (thumbImg->getType() == sImage8) { Image8 *image = static_cast(thumbImg); diff --git a/rtengine/stdimagesource.cc b/rtengine/stdimagesource.cc index 5e7001028..87f25a497 100644 --- a/rtengine/stdimagesource.cc +++ b/rtengine/stdimagesource.cc @@ -285,7 +285,7 @@ void StdImageSource::getFullSize (int& w, int& h, int tr) } } -void StdImageSource::getSize (PreviewProps pp, int& w, int& h) +void StdImageSource::getSize (const PreviewProps &pp, int& w, int& h) { w = pp.getWidth() / pp.getSkip() + (pp.getWidth() % pp.getSkip() > 0); h = pp.getHeight() / pp.getSkip() + (pp.getHeight() % pp.getSkip() > 0); diff --git a/rtengine/stdimagesource.h b/rtengine/stdimagesource.h index baff5559d..330c08244 100644 --- a/rtengine/stdimagesource.h +++ b/rtengine/stdimagesource.h @@ -66,7 +66,7 @@ public: } void getFullSize (int& w, int& h, int tr = TR_NONE); - void getSize (PreviewProps pp, int& w, int& h); + void getSize (const PreviewProps &pp, int& w, int& h); ImageData* getImageData () { diff --git a/rtgui/batchqueue.cc b/rtgui/batchqueue.cc index 1dae99cc1..f1d29c4d6 100644 --- a/rtgui/batchqueue.cc +++ b/rtgui/batchqueue.cc @@ -62,7 +62,6 @@ BatchQueue::BatchQueue (FileCatalog* aFileCatalog) : processing(nullptr), fileCa p++; pmenu.attach (*Gtk::manage(cancel = new MyImageMenuItem (M("FILEBROWSER_POPUPCANCELJOB"), "gtk-close.png")), 0, 1, p, p + 1); - p++; pmenu.show_all (); diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 587d93987..829486ac0 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -2110,12 +2110,6 @@ void EditorPanel::updateHistogramPosition (int oldPosition, int newPosition) // No histogram if (!oldPosition) { // An histogram actually exist, we delete it - if (oldPosition == 1) { - removeIfThere (leftbox, histogramPanel, false); - } else if (oldPosition == 2) { - removeIfThere (vboxright, histogramPanel, false); - } - delete histogramPanel; histogramPanel = nullptr; } diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index a7751ea7a..d96a89d09 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -375,7 +375,6 @@ FileBrowser::FileBrowser () pmenu->attach (*Gtk::manage(new Gtk::SeparatorMenuItem ()), 0, 1, p, p + 1); p++; pmenu->attach (*Gtk::manage(cachemenu = new Gtk::MenuItem (M("FILEBROWSER_CACHE"))), 0, 1, p, p + 1); - p++; pmenu->show_all (); diff --git a/rtgui/guiutils.cc b/rtgui/guiutils.cc index c37306959..8e4ae3613 100644 --- a/rtgui/guiutils.cc +++ b/rtgui/guiutils.cc @@ -1454,8 +1454,6 @@ bool BackBuffer::setDrawRectangle(Cairo::Format format, int newX, int newY, int */ void BackBuffer::copyRGBCharData(const unsigned char *srcData, int srcX, int srcY, int srcW, int srcH, int srcRowStride, int dstX, int dstY) { - const unsigned char *src; - unsigned char *dst; unsigned char r, g, b; if (!surface) { @@ -1477,8 +1475,8 @@ void BackBuffer::copyRGBCharData(const unsigned char *srcData, int srcX, int src break; } - src = srcData + i * srcRowStride; - dst = dstData + ((dstY + i) * surfW + dstX) * 4; + const unsigned char *src = srcData + i * srcRowStride; + unsigned char *dst = dstData + ((dstY + i) * surfW + dstX) * 4; for (int j = 0; j < srcW; ++j) { if (dstX + j >= surfW) { diff --git a/rtgui/guiutils.h b/rtgui/guiutils.h index 3a78baef9..b2ebaa80a 100644 --- a/rtgui/guiutils.h +++ b/rtgui/guiutils.h @@ -320,7 +320,7 @@ class MyComboBoxText : public Gtk::ComboBoxText void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const; public: - MyComboBoxText (bool has_entry = false); + explicit MyComboBoxText (bool has_entry = false); void setPreferredWidth (int minimum_width, int natural_width); void connect(const sigc::connection &connection) { myConnection = connection; } @@ -437,7 +437,7 @@ private: void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const; public: - MyProgressBar(int width); + explicit MyProgressBar(int width); MyProgressBar(); void setPreferredWidth(int width); diff --git a/rtgui/inspector.cc b/rtgui/inspector.cc index 6de56e81b..79839b5f9 100644 --- a/rtgui/inspector.cc +++ b/rtgui/inspector.cc @@ -56,30 +56,30 @@ InspectorBuffer::~InspectorBuffer() { } */ -int InspectorBuffer::infoFromImage (const Glib::ustring& fname) -{ - - rtengine::ImageMetaData* idata = rtengine::ImageMetaData::fromFile (fname, nullptr); - - if (!idata) { - return 0; - } - - int deg = 0; - - if (idata->hasExif()) { - if (idata->getOrientation() == "Rotate 90 CW" ) { - deg = 90; - } else if (idata->getOrientation() == "Rotate 180" ) { - deg = 180; - } else if (idata->getOrientation() == "Rotate 270 CW") { - deg = 270; - } - } - - delete idata; - return deg; -} +//int InspectorBuffer::infoFromImage (const Glib::ustring& fname) +//{ +// +// rtengine::ImageMetaData* idata = rtengine::ImageMetaData::fromFile (fname, nullptr); +// +// if (!idata) { +// return 0; +// } +// +// int deg = 0; +// +// if (idata->hasExif()) { +// if (idata->getOrientation() == "Rotate 90 CW" ) { +// deg = 90; +// } else if (idata->getOrientation() == "Rotate 180" ) { +// deg = 180; +// } else if (idata->getOrientation() == "Rotate 270 CW") { +// deg = 270; +// } +// } +// +// delete idata; +// return deg; +//} Inspector::Inspector () : currImage(nullptr), zoom(0.0), active(false) { diff --git a/rtgui/inspector.h b/rtgui/inspector.h index 305558817..f68912dc1 100644 --- a/rtgui/inspector.h +++ b/rtgui/inspector.h @@ -25,8 +25,8 @@ class InspectorBuffer { -private: - int infoFromImage (const Glib::ustring& fname); +//private: +// int infoFromImage (const Glib::ustring& fname); public: BackBuffer imgBuffer; diff --git a/rtgui/myflatcurve.cc b/rtgui/myflatcurve.cc index c98268683..210fb42f2 100644 --- a/rtgui/myflatcurve.cc +++ b/rtgui/myflatcurve.cc @@ -1194,6 +1194,7 @@ void MyFlatCurve::pipetteMouseOver (CurveEditor *ce, EditDataProvider *provider, // occurs when leaving the preview area -> cleanup the curve editor pipetteR = pipetteG = pipetteB = -1.f; lit_point = -1; + editedHandle = FCT_EditedHandle_None; return; } diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index a37a12a49..26679f400 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -1580,10 +1580,9 @@ void Preferences::parseThemeDir (Glib::ustring dirname) Glib::ustring fname = Glib::build_filename (dirname, *i); Glib::ustring sname = *i; - bool keepIt = false; - // ignore directories and filter out unsupported theme if (regex->match (sname, matchInfo) && !Glib::file_test (fname, Glib::FILE_TEST_IS_DIR) && sname.size() >= 4) { + bool keepIt = false; Glib::ustring fname2 = matchInfo.fetch (1); Glib::ustring minMinor = matchInfo.fetch (2); Glib::ustring maxMinor = matchInfo.fetch (3); @@ -2159,8 +2158,8 @@ void Preferences::okPressed () void Preferences::cancelPressed () { // set the initial theme back - if (themeFNames.at(theme->get_active_row_number ()).longFName != options.theme) { - rtengine::setPaths(options); + if (themeFNames.at (theme->get_active_row_number ()).longFName != options.theme) { + rtengine::setPaths (options); RTImage::updateImages(); switchThemeTo (options.theme); } @@ -2217,8 +2216,8 @@ void Preferences::aboutPressed () void Preferences::themeChanged () { - moptions.theme = themeFNames.at(theme->get_active_row_number ()).longFName; - rtengine::setPaths(moptions); + moptions.theme = themeFNames.at (theme->get_active_row_number ()).longFName; + rtengine::setPaths (moptions); RTImage::updateImages(); switchThemeTo (moptions.theme); } diff --git a/tools/osx/executable_loader.in b/tools/osx/executable_loader.in index 5f1911edb..535d37ec1 100644 --- a/tools/osx/executable_loader.in +++ b/tools/osx/executable_loader.in @@ -1,31 +1,47 @@ -#!/bin/bash +#!/usr/bin/env bash -cwd="$(cd "$(dirname "$0")"; pwd)" +cd "$(dirname "$0")" || exit 1 + +cwd="$(pwd)" app="${cwd%/Contents/*}" -etc="${cwd}"/etc +lib="${app}/Contents/Frameworks" +resources="${app}/Contents/Resources" +etc="${resources}"/etc -# for different os x versions -# see https://github.com/Beep6581/RawTherapee/issues/1779 -cups_dir=/tmp/RT4 -install -d ${cups_dir} -cp -f /usr/lib/libcups.2.dylib ${cups_dir} +### Pending deletion: +# See https://github.com/Beep6581/RawTherapee/issues/1779 +# cups_dir=/tmp/RT5 +# install -d "${cups_dir}" +# cp -f /usr/lib/libcups.2.dylib "${cups_dir}" +# export DYLD_LIBRARY_PATH="${lib}:${cups_dir}" -export DYLD_LIBRARY_PATH="${cwd}"/lib:${cups_dir} -export GTK_EXE_PREFIX="${cwd}" -export GTK_DATA_PREFIX="${cwd}" -export GTK_IM_MODULE_FILE="${etc}"/gtk-2.0/gtk.immodules -export GDK_PIXBUF_MODULE_FILE="${etc}"/gtk-2.0/gdk-pixbuf.loaders -export XDG_DATA_DIRS="${cwd}"/share -export PANGO_RC_FILE="${etc}"/pango/pangorc +# export GTK_EXE_PREFIX="${resources}" +# export GTK_DATA_PREFIX="${resources}" +# export XDG_DATA_DIRS="${resources}/share" +# export GTK_IM_MODULE_FILE="${etc}/gtk-3.0/gtk.immodules" -# environment variables for X11 backend -if test -d "${etc}"/fonts; then - export FONTCONFIG_PATH="${etc}"/fonts -fi +export DYLD_LIBRARY_PATH="${lib}" -# strip out system argument -case $1 in -psn_*) shift;; esac +export GTK_PATH="${lib}/gtk-3.0/3.0.0" +export XDG_DATA_HOME="${resources}/share" +export GSETTINGS_SCHEMA_DIR="${resources}/share/glib-2.0/schemas" +export GDK_PIXBUF_MODULE_FILE="${etc}/gtk-3.0/gdk-pixbuf.loaders" +export GDK_PIXBUF_MODULEDIR="${lib}/gdk-pixbuf-2.0/2.10.0/loaders" + +export RT_SETTINGS="${HOME}/Library/Application Support/RawTherapee/config" +export RT_CACHE="${HOME}/Library/Application Support/RawTherapee/cache" + +### Pending deletion: +# Environment variables for X11 backend +#if [[ -d ${etc}/fonts ]]; then +# export FONTCONFIG_PATH="${etc}/fonts" +#fi + +# Strip out system argument +case "$1" in + -psn_*) shift ;; +esac ln -sf "${app}" /tmp -exec "${cwd}"/rawtherapee-bin "$@" +exec "${cwd}/rawtherapee-bin" "$@" diff --git a/tools/osx/libiconv_1.15_rt.patch b/tools/osx/libiconv_1.15_rt.patch new file mode 100644 index 000000000..ca434154b --- /dev/null +++ b/tools/osx/libiconv_1.15_rt.patch @@ -0,0 +1,30 @@ +diff --git a/lib/iconv.c b/lib/iconv.c +index 31853a7..630a498 100644 +--- a/lib/iconv.c ++++ b/lib/iconv.c +@@ -611,4 +611,25 @@ strong_alias (libiconv, iconv) + strong_alias (libiconv_close, iconv_close) + #endif + ++#undef iconv_open ++#undef iconv ++#undef iconv_close ++ ++LIBICONV_DLL_EXPORTED iconv_t iconv_open (const char* tocode, const char* fromcode) ++{ ++ return libiconv_open(tocode, fromcode); ++} ++ ++LIBICONV_DLL_EXPORTED size_t iconv (iconv_t icd, ++ ICONV_CONST char * * inbuf, size_t *inbytesleft, ++ char * * outbuf, size_t *outbytesleft) ++{ ++ return libiconv(icd, inbuf, inbytesleft, outbuf, outbytesleft); ++} ++ ++LIBICONV_DLL_EXPORTED int iconv_close (iconv_t icd) ++{ ++ return libiconv_close(icd); ++} ++ + #endif diff --git a/tools/osx/macosx_bundle.sh b/tools/osx/macosx_bundle.sh index 89e0c23b0..26cf87250 100644 --- a/tools/osx/macosx_bundle.sh +++ b/tools/osx/macosx_bundle.sh @@ -1,17 +1,26 @@ -#!/bin/bash +#!/usr/bin/env bash -# Required variables -# ------------------ -# these are very important variables. Must be set into rtdata/CMakeLists.txt! +# Required variables, must be set in rtdata/CMakeLists.txt # - PROJECT_NAME -# - PROJECT_SOURCE_DIR # - PROJECT_VERSION (if without git) +# - PROJECT_SOURCE_DIR # - CMAKE_BUILD_TYPE # - PROC_BIT_DEPTH # - GTK_PREFIX -function message { - printf '\e[34m-- %s\e[m\n' "$*" +# Formatting +fNormal="$(tput sgr0)" +fBold="$(tput bold)" +# Colors depend upon the user's terminal emulator color scheme - what is readable for you may be not readable for someone else. +fMagenta="$(tput setaf 5)" +fRed="$(tput setaf 1)" + +function msg { + printf "\n${fBold}-- %s${fNormal}\n" "${@}" +} + +function msgError { + printf "\n${fBold}Error:${fNormal}\n%s\n" "${@}" } function GetDependencies { @@ -25,14 +34,14 @@ function CheckLink { done } -# source check -if test ! -d "${CMAKE_BUILD_TYPE}"; then - printf "\e[31m${PWD}/${CMAKE_BUILD_TYPE} directory is not found. Please execute 'make install' first.\e[m\n" +# Source check +if [[ ! -d "${CMAKE_BUILD_TYPE}" ]]; then + msgError "${PWD}/${CMAKE_BUILD_TYPE} folder does not exist. Please execute 'make install' first." exit 1 fi -# update project version -if test -x "$(which git)" -a -d "${PROJECT_SOURCE_DIR}/.git"; then +# Update project version +if [[ -x "$(which git)" && -d "${PROJECT_SOURCE_DIR}/.git" ]]; then ### This section is copied from tools/generateReleaseInfo # Get version description. # Depending on whether you checked out a branch (dev) or a tag (release), @@ -62,25 +71,11 @@ if test -x "$(which git)" -a -d "${PROJECT_SOURCE_DIR}/.git"; then fi -# if not specify CMAKE_OSX_DEPLOYMENT_TARGET when compiling, -# 'MINIMUM_VERSION' will be used host OS X version. -MINIMUM_SYSTEM_VERSION="$(otool -l "${CMAKE_BUILD_TYPE}"/rawtherapee | grep -A2 'LC_VERSION_MIN_MACOSX' | awk '$1 ~ /version/ { printf $2 }')" -if test ! -n "${MINIMUM_SYSTEM_VERSION}"; then +MINIMUM_SYSTEM_VERSION="$(otool -l "${CMAKE_BUILD_TYPE}"/MacOS/rawtherapee | grep -A2 'LC_VERSION_MIN_MACOSX' | awk '$1 ~ /version/ { printf $2 }')" +if [[ -z "${MINIMUM_SYSTEM_VERSION}" ]]; then MINIMUM_SYSTEM_VERSION="$(sw_vers -productVersion | cut -d. -f-2)" fi -# check for pango-querymodules. Pango 1.38.0 and above do not include it. -# https://github.com/Homebrew/homebrew/issues/44764#issuecomment-146795820 -PangoVer="$(brew list --versions pango)" -PangoVer="${PangoVer//./}" -# Only check the first 4 digits, so that "1.36.99" (13699) doesn't test greater than "1.38.0" (1380) -PangoVer="${PangoVer:0:4}" -if [[ "$PangoVer" -ge "1380" ]]; then - ExistPangoQuerymodules="false" -else - ExistPangoQuerymodules="true" -fi - case ${PROC_BIT_DEPTH} in 64) arch=x86_64;; 32) arch=i386;; @@ -97,127 +92,133 @@ GTK_PREFIX: ${GTK_PREFIX} PWD: ${PWD} __EOS__ -APP="${PROJECT_NAME}".app -CONTENTS="${APP}"/Contents -RESOURCES="${CONTENTS}"/Resources -MACOS="${CONTENTS}"/MacOS -LIB="${MACOS}"/lib -ETC="${MACOS}"/etc -EXECUTABLE="${MACOS}"/rawtherapee +APP="${PROJECT_NAME}.app" +CONTENTS="${APP}/Contents" +RESOURCES="${CONTENTS}/Resources" +MACOS="${CONTENTS}/MacOS" +LIB="${CONTENTS}/Frameworks" +ETC="${RESOURCES}/etc" +EXECUTABLE="${MACOS}/rawtherapee" -message "Removing old files" +msg "Removing old files:" rm -rf "${APP}" "${PROJECT_NAME}_*.dmg" -message "Creating bundle container" +msg "Creating bundle container:" install -d "${RESOURCES}" \ -"${MACOS}" \ -"${LIB}" \ -"${ETC}" + "${MACOS}" \ + "${LIB}" \ + "${ETC}" -message "Copying release files" -ditto "${CMAKE_BUILD_TYPE}" "${MACOS}" +msg "Copying release files:" +ditto "${CMAKE_BUILD_TYPE}/MacOS" "${MACOS}" +ditto "${CMAKE_BUILD_TYPE}/Resources" "${RESOURCES}" -message "Copying dependencies from ${GTK_PREFIX}" +msg "Copying dependencies from ${GTK_PREFIX}:" CheckLink "${EXECUTABLE}" -message "Copying library modules from ${GTK_PREFIX}" -ditto --arch "${arch}" {"${GTK_PREFIX}"/lib,"${LIB}"}/gdk-pixbuf-2.0 -ditto --arch "${arch}" {"${GTK_PREFIX}"/lib,"${LIB}"}/gtk-2.0 -ditto --arch "${arch}" {"${GTK_PREFIX}"/lib,"${LIB}"}/pango +msg "Copying library modules from ${GTK_PREFIX}:" +ditto --arch "${arch}" {"${GTK_PREFIX}/lib","${LIB}"}/gdk-pixbuf-2.0 +ditto --arch "${arch}" {"${GTK_PREFIX}/lib","${LIB}"}/gtk-3.0 -message "Removing static libraries and cache files" +msg "Removing static libraries and cache files:" find -E "${LIB}" -type f -regex '.*\.(a|la|cache)$' | while read; do rm "${REPLY}"; done -message "Copying configuration files from ${GTK_PREFIX}" -install -d "${ETC}"/{gtk-2.0,pango} -cp "${GTK_PREFIX}"/etc/gtk-2.0/im-multipress.conf "${ETC}"/gtk-2.0 -"${GTK_PREFIX}"/bin/gdk-pixbuf-query-loaders "${LIB}"/gdk-pixbuf-2.0/*/loaders/*.so > "${ETC}"/gtk-2.0/gdk-pixbuf.loaders -"${GTK_PREFIX}"/bin/gtk-query-immodules-2.0 "${LIB}"/gtk-2.0/*/immodules/*.so > "${ETC}"/gtk-2.0/gtk.immodules -sed -i "" -e "s|${PWD}|/tmp|" "${ETC}"/gtk-2.0/gdk-pixbuf.loaders \ -"${ETC}"/gtk-2.0/gtk.immodules -if [[ "$ExistPangoQuerymodules" = "true" ]]; then - "${GTK_PREFIX}"/bin/pango-querymodules "${LIB}"/pango/*/modules/*.so > "${ETC}"/pango/pango.modules - sed -i "" -e "s|${PWD}|/tmp|" "${ETC}"/pango/pango.modules - printf "[Pango]\nModuleFiles = /tmp/${ETC}/pango/pango.modules" > "${ETC}"/pango/pangorc -fi +msg "Copying configuration files from ${GTK_PREFIX}:" +install -d "${ETC}/gtk-3.0" +cp "${GTK_PREFIX}/etc/gtk-3.0/im-multipress.conf" "${ETC}/gtk-3.0" +"${GTK_PREFIX}/bin/gdk-pixbuf-query-loaders" "${LIB}"/gdk-pixbuf-2.0/*/loaders/*.so > "${ETC}/gtk-3.0/gdk-pixbuf.loaders" +"${GTK_PREFIX}/bin/gtk-query-immodules-3.0" "${LIB}"/gtk-3.0/*/immodules/*.so > "${ETC}/gtk-3.0/gtk.immodules" +sed -i "" -e "s|${PWD}|/tmp|" "${ETC}/gtk-3.0/gdk-pixbuf.loaders" "${ETC}/gtk-3.0/gtk.immodules" -message "Copying shared files from ${GTK_PREFIX}" -cp -R "${GTK_PREFIX}"/share/mime "${MACOS}"/share -# gtk themes -ditto {"${GTK_PREFIX}","${MACOS}"}/share/themes/Mac/gtk-2.0-key/gtkrc -ditto {"${GTK_PREFIX}","${MACOS}"}/share/themes/Clearlooks/gtk-2.0/gtkrc -install -d "${MACOS}"/share/themes/Raleigh/gtk-2.0 -(cd "${MACOS}"/share/themes/Raleigh/gtk-2.0 && ln -s ../../Clearlooks/gtk-2.0/gtkrc) +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/glib-2.0/schemas +"${GTK_PREFIX}/bin/glib-compile-schemas" "${RESOURCES}/share/glib-2.0/schemas" + +msg "Copying shared files from ${GTK_PREFIX}:" +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/mime +# GTK3 themes +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/themes/Mac/gtk-3.0/gtk-keys.css +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/themes/Default/gtk-3.0/gtk-keys.css +# Adwaita icons +iconfolders=("16x16/actions" "16x16/devices" "16x16/mimetypes" "16x16/places" "16x16/status" "48x48/devices") +for f in "${iconfolders[@]}"; do + ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/icons/Adwaita/"$f" +done +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/icons/Adwaita/index.theme +"${GTK_PREFIX}/bin/gtk-update-icon-cache-3.0" "${RESOURCES}/share/icons/Adwaita" + +### Pending deletion: # fontconfig files (X11 backend only) -if otool -L "${EXECUTABLE}" | grep -sq 'libgtk-x11-2.0'; then - message "Installing fontconfig files (Your library is X11 backend. 'FONTCONFIG_PATH' will be set by executable loader.)" - cp -RL "${GTK_PREFIX}"/etc/fonts "${ETC}" -fi +# if otool -L "${EXECUTABLE}" | grep -sq 'libgtk-x11-2.0'; then +# msg "Installing fontconfig files (Using X11 backend. FONTCONFIG_PATH will be set by executable loader.)" +# cp -RL "${GTK_PREFIX}/etc/fonts" "${ETC}" +# fi - - -# install names +# Install names find -E "${MACOS}" -type f -regex '.*/(rawtherapee|.*\.(dylib|so))' | while read x; do - message "Modifying install names: ${x}" + msg "Modifying install names: ${x}" { # id - case ${x} in *.dylib) echo " install_name_tool -id '@rpath/$(basename "${x}")' '${x}'";; esac - # names - GetDependencies "${x}" | while read y; do - echo " install_name_tool -change '${y}' '@rpath/$(basename "${y}")' '${x}'" - done -} | bash -v + case ${x} in *.dylib) echo " install_name_tool -id '@rpath/$(basename "${x}")' '${x}'";; esac + # names + GetDependencies "${x}" | while read y; do + echo " install_name_tool -change '${y}' '@rpath/$(basename "${y}")' '${x}'" + done + } | bash -v done -message "Registering @loader_path into the executable" +msg "Registering @loader_path into the executable:" echo " install_name_tool -add_rpath @loader_path/lib '${EXECUTABLE}'" | bash -v +msg "Installing required application bundle files:" +PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}/tools/osx" - -message "Installing required application bundle files" -PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}"/tools/osx -# executable loader -# note: executable is renamed to 'rawtherapee-bin'. -mv "${MACOS}"/rawtherapee{,-bin} -install -m 0755 "${PROJECT_SOURCE_DATA_DIR}"/executable_loader.in "${MACOS}"/rawtherapee -# app bundle resources -cp "${PROJECT_SOURCE_DATA_DIR}"/{rawtherapee,profile}.icns "${RESOURCES}" -cp "${PROJECT_SOURCE_DATA_DIR}"/PkgInfo "${CONTENTS}" -install -m 0644 "${PROJECT_SOURCE_DATA_DIR}"/Info.plist.in "${CONTENTS}"/Info.plist +# Executable loader +# Note: executable is renamed to 'rawtherapee-bin'. +mv "${MACOS}/rawtherapee" "${MACOS}/rawtherapee-bin" +install -m 0755 "${PROJECT_SOURCE_DATA_DIR}/executable_loader.in" "${MACOS}/rawtherapee" +# App bundle resources +cp "${PROJECT_SOURCE_DATA_DIR}/"{rawtherapee,profile}.icns "${RESOURCES}" +cp "${PROJECT_SOURCE_DATA_DIR}/PkgInfo" "${CONTENTS}" +install -m 0644 "${PROJECT_SOURCE_DATA_DIR}/Info.plist.in" "${CONTENTS}/Info.plist" sed -i "" -e "s|@version@|${PROJECT_FULL_VERSION}| s|@shortVersion@|${PROJECT_VERSION}| s|@arch@|${arch}|" \ -"${CONTENTS}"/Info.plist -plutil -convert binary1 "${CONTENTS}"/Info.plist + "${CONTENTS}/Info.plist" +plutil -convert binary1 "${CONTENTS}/Info.plist" function CreateDmg { - local srcdir="$(mktemp -dt $$)" + local srcDir="$(mktemp -dt $$)" - message "Preparing disk image sources at ${srcdir}" - mv "${APP}" "${srcdir}" - cp AboutThisBuild.txt "${srcdir}" - ln -s /Applications "${srcdir}" + msg "Preparing disk image sources at ${srcDir}:" + cp -R "${APP}" "${srcDir}" + cp AboutThisBuild.txt "${srcDir}" + ln -s /Applications "${srcDir}" - # web bookmarks + # Web bookmarks function CreateWebloc { - defaults write "${srcdir}/$1" URL "$2" - mv "${srcdir}/$1".{plist,webloc} + defaults write "${srcDir}/$1" URL "$2" + mv "${srcDir}/$1".{plist,webloc} } - CreateWebloc 'RawTherapee Blog' 'http://www.rawtherapee.com' - CreateWebloc 'Online Manual' 'http://rawpedia.rawtherapee.com/' + CreateWebloc 'Website' 'http://www.rawtherapee.com/' + CreateWebloc 'Manual' 'http://rawpedia.rawtherapee.com/' - # disk image name + # Disk image name dmg_name="${PROJECT_NAME// /_}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_FULL_VERSION}" - if ! echo "${CMAKE_BUILD_TYPE}" | grep -sqi "release"; then - dmg_name="${dmg_name}_$(echo ${CMAKE_BUILD_TYPE} | tr '[:upper:]' '[:lower:]')" + lower_build_type="$(tr '[:upper:]' '[:lower:]' <<< "$CMAKE_BUILD_TYPE")" + if [[ ${lower_build_type} != release ]]; then + dmg_name="${dmg_name}_${lower_build_type}" fi - message "Creating disk image" - hdiutil create -format UDBZ -srcdir "${srcdir}" -volname "${PROJECT_NAME}_${PROJECT_FULL_VERSION}" "${dmg_name}".dmg + msg "Creating disk image:" + hdiutil create -format UDBZ -srcdir "${srcDir}" -volname "${PROJECT_NAME}_${PROJECT_FULL_VERSION}" "${dmg_name}.dmg" - message "Removing disk image caches" - rm -rf "${srcdir}" + # Zip disk image for redistribution + zip "${dmg_name}.zip" "${dmg_name}.dmg" AboutThisBuild.txt + rm "${dmg_name}.dmg" + + msg "Removing disk image caches:" + rm -rf "${srcDir}" } CreateDmg