diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c60fa37c..13c648de0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,6 +252,12 @@ if(NOT DEFINED APPDATADIR) endif() endif() +if (NOT APPLE) + if(DEFINED LENSFUNDBDIR AND NOT IS_ABSOLUTE "${LENSFUNDBDIR}") + set(LENSFUNDBDIR "${DATADIR}/${LENSFUNDBDIR}") + endif() +endif() + if(APPLE) if("${CODESIGNID}") set(CODESIGNID "${CODESIGNID}" CACHE STRING "Codesigning Identity") @@ -396,7 +402,7 @@ if(WITH_PROF) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wuninitialized -Wcast-qual -Wno-deprecated-declarations -Wno-unused-result") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wuninitialized -Wcast-qual -Wno-deprecated-declarations -Wno-unused-result -Wunused-macros") if(OPTION_OMP) find_package(OpenMP) if(OPENMP_FOUND) diff --git a/rtdata/CMakeLists.txt b/rtdata/CMakeLists.txt index 46722ba01..76804c0f0 100644 --- a/rtdata/CMakeLists.txt +++ b/rtdata/CMakeLists.txt @@ -29,9 +29,12 @@ if(UNIX) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/rawtherapee.desktop" DESTINATION ${DESKTOPDIR}) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/images/png/rawtherapee-logo-16.png" DESTINATION "${ICONSDIR}/hicolor/16x16/apps" RENAME rawtherapee.png) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/images/png/rawtherapee-logo-24.png" DESTINATION "${ICONSDIR}/hicolor/24x24/apps" RENAME rawtherapee.png) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/images/png/rawtherapee-logo-32.png" DESTINATION "${ICONSDIR}/hicolor/32x32/apps" RENAME rawtherapee.png) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/images/png/rawtherapee-logo-48.png" DESTINATION "${ICONSDIR}/hicolor/48x48/apps" RENAME rawtherapee.png) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/images/png/rawtherapee-logo-64.png" DESTINATION "${ICONSDIR}/hicolor/64x64/apps" RENAME rawtherapee.png) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/images/png/rawtherapee-logo-128.png" DESTINATION "${ICONSDIR}/hicolor/128x128/apps" RENAME rawtherapee.png) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/images/png/rawtherapee-logo-256.png" DESTINATION "${ICONSDIR}/hicolor/256x256/apps" RENAME rawtherapee.png) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/images/svg/rt-logo.svg" DESTINATION "${ICONSDIR}/hicolor/scalable/apps" RENAME rawtherapee.svg) endif() install(FILES ${LANGUAGEFILES} DESTINATION "${DATADIR}/languages") diff --git a/rtdata/dcpprofiles/Canon PowerShot S120.dcp b/rtdata/dcpprofiles/Canon PowerShot S120.dcp new file mode 100644 index 000000000..8bb089c29 Binary files /dev/null and b/rtdata/dcpprofiles/Canon PowerShot S120.dcp differ diff --git a/rtdata/languages/Polish b/rtdata/languages/Polish index b4e1a2281..06a5136d6 100644 --- a/rtdata/languages/Polish +++ b/rtdata/languages/Polish @@ -9,13 +9,20 @@ #09 2014-10-16 DrSlony #10 2020-02-02 Bartłomiej Wiśniowski #11 2020-02-02 Bartłomiej Wiśniowski +#12 2020-02-15 Bartłomiej Wiśniowski +#13 2020-02-17 Bartłomiej Wiśniowski ABOUT_TAB_BUILD;Wersja ABOUT_TAB_CREDITS;Zasługi ABOUT_TAB_LICENSE;Licencja ABOUT_TAB_RELEASENOTES;Notatki eksploatacyjne ABOUT_TAB_SPLASH;Ekran powitalny +ADJUSTER_RESET_TO_DEFAULT;Klik - przywróć wartość domyślną.\nCtrl+klik - przywróć wartość początkową. BATCH_PROCESSING;Przetwarzanie wsadowe +CURVEEDITOR_AXIS_IN;We: +CURVEEDITOR_AXIS_LEFT_TAN;Lw: +CURVEEDITOR_AXIS_OUT;Wy: +CURVEEDITOR_AXIS_RIGHT_TAN;Pw: CURVEEDITOR_CATMULLROM;Elastyczny CURVEEDITOR_CURVE;Krzywa CURVEEDITOR_CURVES;Krzywe @@ -37,9 +44,11 @@ CURVEEDITOR_TOOLTIPPASTE;Wstaw krzywą ze schowka CURVEEDITOR_TOOLTIPSAVE;Zapisz krzywą CURVEEDITOR_TYPE;Typ: DIRBROWSER_FOLDERS;Katalogi +DONT_SHOW_AGAIN;Nie pokazuj tej wiadomości ponownie. DYNPROFILEEDITOR_DELETE;Usuń DYNPROFILEEDITOR_EDIT;Edytuj DYNPROFILEEDITOR_IMGTYPE_ANY;Każdy +DYNPROFILEEDITOR_IMGTYPE_HDR;HDR DYNPROFILEEDITOR_IMGTYPE_STD;Standardowy DYNPROFILEEDITOR_MOVE_DOWN;Przesuń w dół DYNPROFILEEDITOR_MOVE_UP;Przesuń w górę @@ -146,6 +155,7 @@ FILEBROWSER_POPUPRANK2;Ocena 2 ** FILEBROWSER_POPUPRANK3;Ocena 3 *** FILEBROWSER_POPUPRANK4;Ocena 4 **** FILEBROWSER_POPUPRANK5;Ocena 5 ***** +FILEBROWSER_POPUPREMOVE;Usuń na zawsze FILEBROWSER_POPUPRENAME;Zmień nazwę FILEBROWSER_POPUPSELECTALL;Zaznacz wszystkie FILEBROWSER_POPUPTRASH;Przenieś do kosza @@ -172,6 +182,7 @@ FILEBROWSER_SHOWDIRHINT;Wyłącza wyszstkie filtry.\nSkrót: d FILEBROWSER_SHOWEDITEDHINT;Pokazuje edytowane zdjęcia.\nSkrót: 7 FILEBROWSER_SHOWEDITEDNOTHINT;Pokazuje nieedytowane zdjęcia.\nSkrót: 6 FILEBROWSER_SHOWEXIFINFO;Pokaż dane Exif.\n\nSkróty:\ni - Tryb wielu zakładek,\nAlt-i - Tryb jednej zakładki. +FILEBROWSER_SHOWNOTTRASHHINT;Pokazuj tylko obrazy które nie znajdują się w koszu. FILEBROWSER_SHOWRANK1HINT;Pokazuje zdjęcia ocenione na 1 gwiazdkę.\nSkrót: 1 FILEBROWSER_SHOWRANK2HINT;Pokazuje zdjęcia ocenione na 2 gwiazdki.\nSkrót: 2 FILEBROWSER_SHOWRANK3HINT;Pokazuje zdjęcia ocenione na 3 gwiazdki.\nSkrót: 3 @@ -218,6 +229,7 @@ GENERAL_PORTRAIT;Pionowo GENERAL_RESET;Resetuj GENERAL_SAVE;Zapisz GENERAL_SAVE_AS;Zapisz jako... +GENERAL_SLIDER;Suwak GENERAL_UNCHANGED;(Niezmienione) GENERAL_WARNING;Uwaga HISTOGRAM_TOOLTIP_B;Pokaż/Ukryj histogram błękitów. @@ -590,6 +602,8 @@ HISTORY_MSG_411;Retinex - Siła HISTORY_MSG_413;Retinex - Kontrast HISTORY_MSG_418;Retinex - Próg HISTORY_MSG_419;Retinex - Przestrzeń kolorów +HISTORY_MSG_421;Retinex - Gamma +HISTORY_MSG_422;Retinex - Gamma HISTORY_MSG_426;Retinex - Wyrównywanie odcieni HISTORY_MSG_429;Retinex - Iteracje HISTORY_MSG_432;Retinex - M - Podświetlenia @@ -602,7 +616,11 @@ HISTORY_MSG_440;CbDL - Metoda HISTORY_MSG_442;Retinex - Skala HISTORY_MSG_449;PS - Adaptacja ISO HISTORY_MSG_452;PS - Pokaż ruch +HISTORY_MSG_453;PS - Pokaż tylko maskę +HISTORY_MSG_465;PS - Promień rozmycia +HISTORY_MSG_468;PS - Wypełnij dziury HISTORY_MSG_471;PS - Korekcja ruchu +HISTORY_MSG_472;PS - Miękkie przejścia HISTORY_MSG_474;PS - Wyrównaj HISTORY_MSG_475;PS - Wyrównaj kanał HISTORY_MSG_485;Korekcja obiektywu @@ -613,6 +631,10 @@ HISTORY_MSG_490;DRC - Ilość HISTORY_MSG_491;Balans bieli HISTORY_MSG_492;Krzywe RGB HISTORY_MSG_CLAMPOOG;Ucinaj kolory spoza zakresu +HISTORY_MSG_COLORTONING_LABGRID_VALUE;CT - Korekcja koloru +HISTORY_MSG_COLORTONING_LABREGION_AB;CT - Korekcja koloru +HISTORY_MSG_COLORTONING_LABREGION_CHANNEL;CT - Kanał +HISTORY_MSG_COLORTONING_LABREGION_SATURATION;CT - Saturacja HISTORY_MSG_DEHAZE_DEPTH;Usuwanie mgły - Głębia HISTORY_MSG_DEHAZE_ENABLED;Usuwanie mgły HISTORY_MSG_DEHAZE_LUMINANCE;Usuwanie mgły - Tylko luminancja @@ -631,6 +653,14 @@ HISTORY_MSG_PDSHARPEN_CONTRAST;CS - Próg kontrastu HISTORY_MSG_PDSHARPEN_ITERATIONS;CS - Iteracje HISTORY_MSG_PDSHARPEN_RADIUS;CS - Promień HISTORY_MSG_PRSHARPEN_CONTRAST;PRS - Próg kontrastu +HISTORY_MSG_RAWCACORR_AUTOIT;Korekcja aberracji chromatycznej - Iteracje +HISTORY_MSG_RAWCACORR_COLORSHIFT;Korekcja aberracji chromatycznej - Unikaj przesunięcia kolorów +HISTORY_MSG_SHARPENING_BLUR;Wyostrzanie - Promień rozmycia +HISTORY_MSG_SHARPENING_CONTRAST;Wyostrzanie - Próg kontrastu +HISTORY_MSG_SH_COLORSPACE;S/H - Przestrzeń kolorów +HISTORY_MSG_SOFTLIGHT_ENABLED;Miękkie światło +HISTORY_MSG_SOFTLIGHT_STRENGTH;Miękkie światło - Siła +HISTORY_MSG_TRANS_Method;Geometria - Metoda HISTORY_NEWSNAPSHOT;Nowa migawka HISTORY_NEWSNAPSHOT_TOOLTIP;Skrót: Alt-s HISTORY_SNAPSHOT;Migawka @@ -649,27 +679,43 @@ ICCPROFCREATOR_ILL_65;D65 ICCPROFCREATOR_ILL_80;D80 ICCPROFCREATOR_ILL_DEF;Domyślne ICCPROFCREATOR_ILL_INC;StdA 2856K +ICCPROFCREATOR_PRIM_ACESP0;ACES AP0 +ICCPROFCREATOR_PRIM_ACESP1;ACES AP1 ICCPROFCREATOR_PRIM_ADOBE;Adobe RGB (1998) ICCPROFCREATOR_PRIM_BEST;BestRGB ICCPROFCREATOR_PRIM_BETA;BetaRGB +ICCPROFCREATOR_PRIM_BLUX;Niebieski X +ICCPROFCREATOR_PRIM_BLUY;Niebieski Y ICCPROFCREATOR_PRIM_BRUCE;BruceRGB +ICCPROFCREATOR_PRIM_GREX;Zielony X +ICCPROFCREATOR_PRIM_GREY;Zielony Y ICCPROFCREATOR_PRIM_PROPH;Prophoto ICCPROFCREATOR_PRIM_REC2020;Rec2020 +ICCPROFCREATOR_PRIM_REDX;Czerwony X +ICCPROFCREATOR_PRIM_REDY;Czerwony Y ICCPROFCREATOR_PRIM_SRGB;sRGB +ICCPROFCREATOR_PRIM_WIDEG;Szeroka gama ICCPROFCREATOR_PROF_V2;ICC v2 ICCPROFCREATOR_PROF_V4;ICC v4 ICCPROFCREATOR_SAVEDIALOG_TITLE;Zapisz profil ICC jako... +ICCPROFCREATOR_SLOPE;Nachylenie +ICCPROFCREATOR_TRC_PRESET;Krzywa odpowiedzi tonalnej: IPTCPANEL_CATEGORY;Kategoria IPTCPANEL_CITY;Miasto IPTCPANEL_CITYHINT;Wprowadź nazwę miasta uwiecznionego na zdjęciu. IPTCPANEL_COPYHINT;Kopiuje ustawienia IPTC do schowka +IPTCPANEL_COPYRIGHT;Informacja o prawach autorskich +IPTCPANEL_COPYRIGHTHINT;Wprowadź informację o aktualnym posiadaczu praw autorskich np. ©2008 Jane Doe. IPTCPANEL_COUNTRY;Kraj +IPTCPANEL_COUNTRYHINT;Wprowadź nazwę kraju uwiecznionego na tym obrazie. IPTCPANEL_CREATOR;Twórca +IPTCPANEL_CREATORHINT;Wprowadź nazwę twórcy obrazu. IPTCPANEL_CREDIT;Zasługa IPTCPANEL_CREDITHINT;Identyfikuje dostawcę zdjęcia, niekoniecznie właściciela lub autora (Credit). IPTCPANEL_DATECREATED;Data utworzenia IPTCPANEL_DATECREATEDHINT;Wprowadź datę zrobienia zdjęcia. IPTCPANEL_DESCRIPTION;Opis +IPTCPANEL_DESCRIPTIONWRITER;Twórca opisu IPTCPANEL_EMBEDDED;Osadzony IPTCPANEL_EMBEDDEDHINT;Resetuje dane IPTC do domyślnych ustawień osadzonych w orginalnym zdjęciu IPTCPANEL_HEADLINE;Nagłówek @@ -682,6 +728,8 @@ IPTCPANEL_RESETHINT;Resetuje do domyślnych ustawień profilu IPTCPANEL_SOURCE;Źródło IPTCPANEL_SUPPCATEGORIES;Dodatkowe kategorie IPTCPANEL_TITLE;Tytuł +IPTCPANEL_TRANSREFERENCE;Numer pracy +IPTCPANEL_TRANSREFERENCEHINT;!IPTCPANEL_TRANSREFERENCEHINT;Wprowadź numer pracy, który umożliwi śledzenie obrazu. MAIN_BUTTON_FULLSCREEN;Pełen ekran MAIN_BUTTON_ICCPROFCREATOR;Kreator profili ICC MAIN_BUTTON_NAVNEXT_TOOLTIP;Przejdź do następnego zdjęcia względem zdjęcia otwartego w Edytorze.\nSkrót: Shift-F4\n\nAby przejść do następnego zdjęcia względem miniaturki wybranej w Nawigatorze Zdjęć:\nSkrót: F4 @@ -716,6 +764,7 @@ MAIN_MSG_OPERATIONCANCELLED;Operację anulowano MAIN_MSG_PATHDOESNTEXIST;Ścieżka\n\n%1\n\nnie istnieje. Wybierz przawidłową ścieżkę w Ustawieniach. MAIN_MSG_QOVERWRITE;Zastąpić? MAIN_MSG_SETPATHFIRST;Aby użyć tej funkcji należy wpierw wybrać odpowiednią ścieżkę docelową w Ustawieniach! +MAIN_MSG_TOOMANYOPENEDITORS;Za duża liczba otwartych edytorów.\nZamknij edytor aby kontynuować. MAIN_MSG_WRITEFAILED;Zapis nie powiódł się:\n\n"%1"\n\nUpewnij się, że folder istnieje oraz że można do niego zapisywać. MAIN_TAB_ADVANCED;Zaawansowane MAIN_TAB_ADVANCED_TOOLTIP;Skrót: Alt-a @@ -834,12 +883,18 @@ PARTIALPASTE_SHADOWSHIGHLIGHTS;Cienie/Podświetlenia PARTIALPASTE_SHARPENEDGE;Krawędzie PARTIALPASTE_SHARPENING;Wyostrzanie PARTIALPASTE_SHARPENMICRO;Mikrokontrast +PARTIALPASTE_SOFTLIGHT;Miękkie światło +PARTIALPASTE_TM_FATTAL;Kompresja zakresu dynamiki PARTIALPASTE_VIBRANCE;Jaskrawość PARTIALPASTE_VIGNETTING;Korekcja winietowania PARTIALPASTE_WHITEBALANCE;Balans bieli PREFERENCES_ADD;Dodaj PREFERENCES_APPEARANCE;Wygląd +PREFERENCES_APPEARANCE_COLORPICKERFONT;Czcionka narzędzia do wybierania kolorów +PREFERENCES_APPEARANCE_CROPMASKCOLOR;Kolor maski kadrowania +PREFERENCES_APPEARANCE_MAINFONT;Główny font PREFERENCES_APPEARANCE_NAVGUIDECOLOR;Kolor ramki Nawigatora +PREFERENCES_APPEARANCE_PSEUDOHIDPI; Tryb pseudo-HiDPI PREFERENCES_APPEARANCE_THEME;Motyw graficzny PREFERENCES_APPLNEXTSTARTUP;wymaga ponownego uruchomienia PREFERENCES_AUTOMONPROFILE;Automatycznie użyj systemowego profilu monitora @@ -855,16 +910,23 @@ PREFERENCES_CACHECLEAR_ONLYPROFILES;Usuń wszystkie profile przetwarzania z pami PREFERENCES_CACHEMAXENTRIES;Maksymalna liczba wpisów w pamięci podręcznej PREFERENCES_CACHEOPTS;Opcje pamięci podręcznej PREFERENCES_CACHETHUMBHEIGHT;Maksymalna wysokość miniatury +PREFERENCES_CHUNKSIZES;Liczba kafelków na wątek PREFERENCES_CHUNKSIZE_RAW_AMAZE;Demozaikowanie AMaZE +PREFERENCES_CHUNKSIZE_RAW_CA;Korekcja aberracji chromatycznej PREFERENCES_CHUNKSIZE_RAW_RCD;Demozaikowanie RCD PREFERENCES_CHUNKSIZE_RAW_XT;Demozaikowanie Xtrans PREFERENCES_CHUNKSIZE_RGB;Przetwarzanie RGB PREFERENCES_CLIPPINGIND;Pokazywanie obciętych prześwietleń/cieni +PREFERENCES_CLUTSCACHE;Cache HaldCLUT PREFERENCES_CLUTSDIR;Folder obrazów HaldCLUT PREFERENCES_CMMBPC;Kompensacja punktu czerni +PREFERENCES_CROP;Kadrowanie +PREFERENCES_CROP_AUTO_FIT;Automatycznie przybliż aby dopasować do skadrowanego obrazu +PREFERENCES_CROP_GUIDES;Zawsze pokazuj ramkę kadrowania PREFERENCES_CROP_GUIDES_FRAME;Ramka PREFERENCES_CROP_GUIDES_FULL;Oryginał PREFERENCES_CROP_GUIDES_NONE;Brak +PREFERENCES_CURVEBBOXPOS;Położenie przycisków kopiuj oraz wklej krzywą PREFERENCES_CURVEBBOXPOS_ABOVE;Powyżej PREFERENCES_CURVEBBOXPOS_BELOW;Poniżej PREFERENCES_CURVEBBOXPOS_LEFT;Z lewej @@ -887,9 +949,11 @@ PREFERENCES_DIRLAST;Ostatnio odwiedzony katalog PREFERENCES_DIROTHER;Inny PREFERENCES_DIRSELECTDLG;Wybierz katalog z obrazami po uruchomieniu... PREFERENCES_DIRSOFTWARE;Katalog instalacyjny +PREFERENCES_EDITORCMDLINE;Własny wiersz poleceń PREFERENCES_EDITORLAYOUT;Układ edytora PREFERENCES_EXTERNALEDITOR;Zewnętrzny edytor PREFERENCES_FBROWSEROPTS;Opcje przeglądarki plików +PREFERENCES_FILEBROWSERTOOLBARSINGLEROW;Zwiń paski w przeglądarce plików PREFERENCES_FLATFIELDFOUND;Znaleziono PREFERENCES_FLATFIELDSDIR;Katalog z pustymi polami PREFERENCES_FLATFIELDSHOTS;kadry @@ -911,6 +975,7 @@ PREFERENCES_INTENT_SATURATION;Nasyceniowy PREFERENCES_INTERNALTHUMBIFUNTOUCHED;Pokaż osadzoną miniaturę JPEG jeśli plik raw jest nieedytowany PREFERENCES_LANG;Język PREFERENCES_LANGAUTODETECT;Użyj języka systemowego +PREFERENCES_MAXRECENTFOLDERS;Maksymalna liczba ostatnio otwieranych folderów PREFERENCES_MENUGROUPEXTPROGS;Grupuj "Otwórz za pomocą" PREFERENCES_MENUGROUPFILEOPERATIONS;Grupuj operacje plików PREFERENCES_MENUGROUPLABEL;Grupuj operacje etykiet @@ -919,30 +984,39 @@ PREFERENCES_MENUGROUPRANK;Grupuj operacje oceny PREFERENCES_MENUOPTIONS;Opcje menu PREFERENCES_MONITOR;Monitor PREFERENCES_MONPROFILE;Domyślny profil kolorów +PREFERENCES_MONPROFILE_WARNOSX;Z powodu ograniczeń MacOS, dostępna jest tylko paleta sRGB. PREFERENCES_MULTITAB;Tryb wielu zakładek PREFERENCES_MULTITABDUALMON;Tryb wielu zakładek (na drugim monitorze jeśli dostępny) PREFERENCES_NAVIGATIONFRAME;Nawigacja PREFERENCES_OVERLAY_FILENAMES;Nakładaj nazwy pliku na miniatury +PREFERENCES_OVERLAY_FILENAMES_FILMSTRIP;Nakładaj nazwy plików na miniaturki w przeglądarce PREFERENCES_OVERWRITEOUTPUTFILE;Nadpisuj istniejące pliki PREFERENCES_PANFACTORLABEL;Współczynnik PREFERENCES_PARSEDEXT;Przetwarzane rozszerzenia PREFERENCES_PARSEDEXTADD;Dodaj rozszerzenie PREFERENCES_PARSEDEXTADDHINT;Proszę wprowadzić rozszerzenie i zatwierdzić przyciskiem, by dodać do listy PREFERENCES_PARSEDEXTDELHINT;Skasuje wybrane rozszerzenie z listy +PREFERENCES_PARSEDEXTDOWNHINT;Przenieś wybrane rozszerzenie w dół. +PREFERENCES_PARSEDEXTUPHINT;Przenieś wybrane rozszerzenie w górę. +PREFERENCES_PERFORMANCE_MEASURE;Zmierz PREFERENCES_PERFORMANCE_THREADS;Wątki PREFERENCES_PREVDEMO;Metoda demozaikowania podglądu PREFERENCES_PREVDEMO_FAST;Szybka +PREFERENCES_PREVDEMO_LABEL;Metoda demozaikowania podczas podglądu przy powiększeniu mniejszym niż 100%: +PREFERENCES_PREVDEMO_SIDECAR;Tak jak w PP3 PREFERENCES_PROFILEHANDLING;Obsługa profili PREFERENCES_PROFILELOADPR;Priorytet wczytywania profilu PREFERENCES_PROFILEPRCACHE;Profil w pamięci podręcznej PREFERENCES_PROFILEPRFILE;Profil przy pliku wejściowym PREFERENCES_PROFILESAVECACHE;Zapisz parametry przetwarzania w pamięci podręcznej PREFERENCES_PROFILESAVEINPUT;Zapisz parametry przetwarzania obok pliku wejściowego +PREFERENCES_PROFILESAVELOCATION;Miejsce zapisywania profilu przetwarzania PREFERENCES_PROFILE_NONE;Żaden PREFERENCES_PROPERTY;Własność PREFERENCES_PRTPROFILE;Profil kolorów PREFERENCES_PSPATH;Katalog w którym zainstalowany jest Adobe Photoshop PREFERENCES_SELECTLANG;Wybierz język +PREFERENCES_SERIALIZE_TIFF_READ;Ustawienia odczytu TIFF PREFERENCES_SET;Ustaw PREFERENCES_SHOWBASICEXIF;Pokaż podstawowe dane Exif PREFERENCES_SHOWDATETIME;Pokaż datę i czas @@ -961,6 +1035,7 @@ PREFERENCES_TAB_GENERAL;Ogólne PREFERENCES_TAB_IMPROC;Przetwarzanie obrazu PREFERENCES_TAB_PERFORMANCE;Wydajność PREFERENCES_TAB_SOUND;Dźwięki +PREFERENCES_THUMBNAIL_INSPECTOR_MODE;Image to show PREFERENCES_TP_LABEL;Panel narzędzi: PREFERENCES_TP_VSCROLLBAR;Ukry pionowy pasek przesuwania PREFERENCES_USEBUNDLEDPROFILES;Użyj załączone profile przetwarzania @@ -974,6 +1049,7 @@ PROFILEPANEL_MODE_TIP;Tryb wypełnienia parametrów przetwarzania.\n\nWduszone: PROFILEPANEL_MYPROFILES;Moje profile przetwarzania PROFILEPANEL_PASTEPPASTE;Parametry do wklejenia PROFILEPANEL_PCUSTOM;Własny +PROFILEPANEL_PDYNAMIC;Dynamika PROFILEPANEL_PFILE;Z pliku PROFILEPANEL_PINTERNAL;Neutralny PROFILEPANEL_PLASTSAVED;Ostatnio zapisany @@ -984,7 +1060,10 @@ PROFILEPANEL_TOOLTIPLOAD;Ładuj profil z pliku.\nCtrl+klik aby wybrać pa PROFILEPANEL_TOOLTIPPASTE;Wklej profil ze schowka.\nCtrl+klik aby wybrać parametry do wklejenia. PROFILEPANEL_TOOLTIPSAVE;Zapisz aktualny profil.\nCtrl+klik aby wybrać parametry do zapisania. PROGRESSBAR_DECODING;Dekodowanie... +PROGRESSBAR_GREENEQUIL;Równoważenie koloru zielonego... PROGRESSBAR_HLREC;Rekonstrukcja podświetleń... +PROGRESSBAR_HOTDEADPIXELFILTER;Filtr gorących/martwych pikseli.. +PROGRESSBAR_LINEDENOISE;Liniowy filtr szumu... PROGRESSBAR_LOADING;Wczytywanie obrazu... PROGRESSBAR_LOADINGTHUMBS;Wczytywanie miniatur... PROGRESSBAR_LOADJPEG;Ładowanie pliku JPEG... @@ -993,6 +1072,7 @@ PROGRESSBAR_LOADTIFF;Ładowanie pliku TIFF... PROGRESSBAR_NOIMAGES;Nie znaleziono żadnych obrazów PROGRESSBAR_PROCESSING;Przetwarzanie obrazu... PROGRESSBAR_PROCESSING_PROFILESAVED;Zapisano profil przetwarzania +PROGRESSBAR_RAWCACORR;Korekcja aberracji chromatycznej... PROGRESSBAR_READY;Gotowe PROGRESSBAR_SAVEJPEG;Zapisywanie pliku JPEG... PROGRESSBAR_SAVEPNG;Zapisywanie pliku PNG... @@ -1011,8 +1091,18 @@ QUEUE_FORMAT_TITLE;Format pliku QUEUE_LOCATION_FOLDER;Zapisz do katalogu QUEUE_LOCATION_TEMPLATE;Użyj schemat QUEUE_LOCATION_TEMPLATE_TOOLTIP;Dozwolone są następujące kody formatujące:\n%f, %d1, %d2, ..., %p1, %p2, ..., %r, %s1, %s2, ...\n\nKody formatujące odnoszą się do różnych elementów ścieżki zdjęcia, atrybutów zdjęcia oraz do arbitralnego ciągu numerycznego operacji wsadowej.\n\nPrzykładowo, jeśli zdjęcie obrabiane ma następującą ścieżkę:\n/home/andrzej/zdjecia/2010-10-31/dsc0042.nef\nznaczenie kodów formatujących jest następujące:\n%d4 = home\n%d3 = andrzej\n%d2 = zdjecia\n%d1 = 2010-10-31\n%f = dsc0042\n%p1 = /home/tom/photos/2010-10-31/\n%p2 = /home/andrzej/zdjecia/\n%p3 = /home/andrzej/\n%p4 = /home/\n\n%r zostanie zastąpione oceną zdjęcia. Jeśli zdjęcie nie posiada oceny, %r zostanie zastąpione liczbą '0'. Jeśli zdjęcie leży w śmietniku, %r zostanie zastąpione znakiem 'x'.\n\n%s1, %s2, etc. zostanie zastąpione ciągniem numerycznym dopełnionym od jednej do dziewięciu cyfr. Ciąg ten zostanie rozpocznięty od "1" za każdym razem gdy kolejka przetwarzania zostanie uruchomiona, i liczba jest zwiększona o "1" dla każdego zapisanego obrazu.\n\nJeśli chcesz zapisać obraz wyjściowy obok obrazu wejściowego, napisz:\n%p1/%f\n\nJeśli chcesz zapisać obraz wyjściowy w folderze o nazwie "wywolane" znajdującego się w katalogu zawierającym otwarty obraz, napisz:\n%p1/wywolane/%f\n\nJeśli chcesz zapisać obraz wyjściowy w folderze o nazwie "/home/andrzej/zdjecia/wywolane/2010-10-31", napisz:\n%p2/wywolane/%d1/%f +QUEUE_LOCATION_TITLE;Lokalizacja wyjściowa +SAMPLEFORMAT_0;Nieznany typ pliku +SAMPLEFORMAT_1;8-bit bez znaku +SAMPLEFORMAT_2;16-bit bez znaku +SAMPLEFORMAT_4;24-bit LogLuv +SAMPLEFORMAT_8;32-bit LogLuv +SAMPLEFORMAT_16;16-bit zmiennoprzecinkowy +SAMPLEFORMAT_32;24-bit zmiennoprzecinkowy +SAMPLEFORMAT_64;32-bit zmiennoprzecinkowy SAVEDLG_AUTOSUFFIX;Automatycznie dodaj przyrostek, jeżeli plik już istnieje SAVEDLG_FILEFORMAT;Format pliku +SAVEDLG_FILEFORMAT_FLOAT; zmiennoprzecinkowy SAVEDLG_FORCEFORMATOPTS;Wymuś opcje zapisu SAVEDLG_JPEGQUAL;Jakość JPEG SAVEDLG_PUTTOQUEUE;Umieść w kolejce przetwarzania @@ -1099,6 +1189,9 @@ TP_BWMIX_VAL;L TP_CACORRECTION_BLUE;Niebieski TP_CACORRECTION_LABEL;Korekcja aberracji chromatycznej TP_CACORRECTION_RED;Czerwony +TP_CBDL_AFT;Po zmianie na Cz-B +TP_CBDL_BEF;Przed zmianą na Cz-B +TP_CBDL_METHOD;Gdzie TP_CHMIXER_BLUE;Niebieski TP_CHMIXER_GREEN;Zielony TP_CHMIXER_LABEL;Mieszacz kanałów @@ -1188,11 +1281,17 @@ TP_COLORTONING_LABREGION_CHANNEL_ALL;Wszystkie TP_COLORTONING_LABREGION_CHANNEL_B;Niebieski TP_COLORTONING_LABREGION_CHANNEL_G;Zielony TP_COLORTONING_LABREGION_CHANNEL_R;Czerwony +TP_COLORTONING_LABREGION_CHROMATICITYMASK;C +TP_COLORTONING_LABREGION_HUEMASK;H +TP_COLORTONING_LABREGION_LIGHTNESSMASK;L TP_COLORTONING_LABREGION_LIST_TITLE;Korekcja TP_COLORTONING_LABREGION_MASK;Maska +TP_COLORTONING_LABREGION_MASKBLUR;Rozmycie maski TP_COLORTONING_LABREGION_OFFSET;Przesunięcie +TP_COLORTONING_LABREGION_POWER;Moc TP_COLORTONING_LABREGION_SATURATION;Saturacja TP_COLORTONING_LABREGION_SHOWMASK;Pokaż maskę +TP_COLORTONING_LABREGION_SLOPE;Nachylenie TP_COLORTONING_LUMA;Luminancja TP_COLORTONING_LUMAMODE;Zachowaj luminancję TP_COLORTONING_LUMAMODE_TOOLTIP;Luminancja zostanie zachowana przy zmianie kolorów. @@ -1205,7 +1304,7 @@ TP_COLORTONING_OPACITY;Przezroczystość TP_COLORTONING_RGBCURVES;RGB - Krzywe TP_COLORTONING_RGBSLIDERS;RGB - Suwaki TP_COLORTONING_SA;Ochrona przed przesyceniem -TP_COLORTONING_SATURATEDOPACITY;Śiła +TP_COLORTONING_SATURATEDOPACITY;Siła TP_COLORTONING_SATURATIONTHRESHOLD;Próg TP_COLORTONING_SHADOWS;Cienie TP_COLORTONING_SPLITCO;Cienie/półcienie/podświetlenia @@ -1244,6 +1343,7 @@ TP_DEHAZE_LABEL;Usuwanie mgły TP_DEHAZE_LUMINANCE;Tylko luminancja TP_DEHAZE_SHOW_DEPTH_MAP;Pokaż mapę głębokości TP_DEHAZE_STRENGTH;Siła +TP_DIRPYRDENOISE_CHROMINANCE_AUTOGLOBAL;Automatycznie TP_DIRPYRDENOISE_CHROMINANCE_BLUEYELLOW;Chrominancja - Błękit-żółć TP_DIRPYRDENOISE_CHROMINANCE_CURVE;Krzywa chrominancji TP_DIRPYRDENOISE_CHROMINANCE_FRAME;Chrominancja @@ -1277,6 +1377,12 @@ TP_DIRPYRDENOISE_MEDIAN_METHOD_RGB;RGB TP_DIRPYRDENOISE_MEDIAN_METHOD_TOOLTIP;Przy użyciu metod "tylko luminancja" oraz "L*a*b*", filtrowanie mediana zostanie wykonane prosto po funkcji falki w procesie odszumiania.\nW trybie "RGB" filtrowanie to zostanie wykonana pod koniec calego procesu. TP_DIRPYRDENOISE_MEDIAN_PASSES;Liczba powtórzeń mediana TP_DIRPYRDENOISE_MEDIAN_TYPE;Rodzaj mediana +TP_DIRPYRDENOISE_TYPE_3X3;3×3 +TP_DIRPYRDENOISE_TYPE_3X3SOFT;3×3 miękko +TP_DIRPYRDENOISE_TYPE_5X5;5×5 +TP_DIRPYRDENOISE_TYPE_5X5SOFT;5×5 miękko +TP_DIRPYRDENOISE_TYPE_7X7;7×7 +TP_DIRPYRDENOISE_TYPE_9X9;9×9 TP_DIRPYREQUALIZER_ALGO;Zakres odcieni skóry TP_DIRPYREQUALIZER_ALGO_TOOLTIP;- TP_DIRPYREQUALIZER_ARTIF;Usuń artefakty @@ -1322,11 +1428,16 @@ TP_EXPOSURE_TCMODE_FILMLIKE;Klisza TP_EXPOSURE_TCMODE_LABEL1;Tryb krzywej 1 TP_EXPOSURE_TCMODE_LABEL2;Tryb krzywej 2 TP_EXPOSURE_TCMODE_LUMINANCE;Luminancja +TP_EXPOSURE_TCMODE_PERCEPTUAL;Percepcyjny TP_EXPOSURE_TCMODE_SATANDVALBLENDING;Mieszanie nasycenia i mocy światła białego TP_EXPOSURE_TCMODE_STANDARD;Standardowa TP_EXPOSURE_TCMODE_WEIGHTEDSTD;Ważona standardowa TP_EXPOS_BLACKPOINT_LABEL;Punkt czerni raw TP_EXPOS_WHITEPOINT_LABEL;Punkt bieli raw +TP_FILMNEGATIVE_BLUE;Proporcja niebieskiego +TP_FILMNEGATIVE_LABEL;Negatyw - klisza +TP_FILMNEGATIVE_PICK;Wybierz miejsce neutralne +TP_FILMNEGATIVE_RED;Proporcja czerwonego TP_FILMSIMULATION_LABEL;Symulacja Kliszy TP_FILMSIMULATION_STRENGTH;Siła TP_FILMSIMULATION_ZEROCLUTSFOUND;Ustaw folder HaldCLUT w Ustawieniach @@ -1389,8 +1500,12 @@ TP_ICM_SAVEREFERENCE_TOOLTIP;Zapisz liniowy obraz TIFF zanim profil wejściowy z TP_ICM_TONECURVE;Użyj krzywą tonalną z DCP TP_ICM_TONECURVE_TOOLTIP;Włącz aby użyć krzywą tonalną znajdującą się w profilu DCP. Opcja ta jest tylko aktywna jeśli profil DCP zawiera krzywą tonalną. TP_ICM_WORKINGPROFILE;Profil roboczy +TP_ICM_WORKING_TRC;Krzywa odpowiedzi tonalnej: TP_ICM_WORKING_TRC_CUSTOM;Własna +TP_ICM_WORKING_TRC_GAMMA;Gamma TP_ICM_WORKING_TRC_NONE;Żadna +TP_ICM_WORKING_TRC_SLOPE;Nachylenie +TP_ICM_WORKING_TRC_TOOLTIP;Tylko dla wbudowanych profili. TP_IMPULSEDENOISE_LABEL;Redukcja Szumów Impulsowych TP_IMPULSEDENOISE_THRESH;Próg TP_LABCURVE_AVOIDCOLORSHIFT;Zapobiegaj zmianom koloru @@ -1435,14 +1550,19 @@ TP_LENSGEOM_FILL;Auto-wypełnienie TP_LENSGEOM_LABEL;Obiektyw / Geometria TP_LENSGEOM_LIN;Liniowo TP_LENSGEOM_LOG;Logarytmicznie +TP_LENSPROFILE_CORRECTION_AUTOMATCH;Wybierz automatycznie TP_LENSPROFILE_CORRECTION_LCPFILE;Plik LCP +TP_LENSPROFILE_CORRECTION_MANUAL;Wybierz ręcznie TP_LENSPROFILE_LABEL;Profil korekcji obiektywu LCP TP_LENSPROFILE_MODE_HEADER;Profil obiektywu TP_LENSPROFILE_USE_CA;Aberracja chromatyczna TP_LENSPROFILE_USE_GEOMETRIC;Zniekształcenia geometryczne +TP_LENSPROFILE_USE_HEADER;Popraw TP_LENSPROFILE_USE_VIGNETTING;Winietowanie TP_LOCALCONTRAST_AMOUNT;Ilość +TP_LOCALCONTRAST_DARKNESS;Ciemne miejsca TP_LOCALCONTRAST_LABEL;Kontrast lokalny +TP_LOCALCONTRAST_LIGHTNESS;Jasne miejsca TP_LOCALCONTRAST_RADIUS;Promień TP_METADATA_EDIT;Zastosuj modyfikacje TP_METADATA_MODE;Tryb kopiowania metadanych @@ -1470,9 +1590,11 @@ TP_PREPROCESS_HOTPIXFILT_TOOLTIP;Łata gorące piksele (pojedyńcze świecące, TP_PREPROCESS_LABEL;Przetwarzanie początkowe TP_PREPROCESS_LINEDENOISE;Filtr zakłóceń liniowych TP_PREPROCESS_LINEDENOISE_DIRECTION;Kierunek +TP_PREPROCESS_LINEDENOISE_DIRECTION_BOTH;Oba TP_PREPROCESS_LINEDENOISE_DIRECTION_HORIZONTAL;Poziomo TP_PREPROCESS_LINEDENOISE_DIRECTION_VERTICAL;Pionowo TP_PREPROCESS_NO_FOUND;Nic nie znaleziono +TP_PRSHARPENING_LABEL;Wyostrzanie po zmianie rozmiaru TP_RAWCACORR_AUTO;Autokorekcja TP_RAWCACORR_AUTOIT;Iteracje TP_RAWCACORR_AVOIDCOLORSHIFT;Unikaj przesunięcia kolorów @@ -1517,11 +1639,23 @@ TP_RAW_LMMSE;LMMSE TP_RAW_LMMSEITERATIONS;Ilość kroków udoskonalenia LMMSE TP_RAW_LMMSE_TOOLTIP;Aby zmniejszyć ilość artefaktów i poprawić stosunek sygnału do szumów, można wykorzystać następujące ustawienia:\n1: Gamma\n2-4: Średnia mediana\n5-6: Rafinowanie TP_RAW_MONO;Mono +TP_RAW_PIXELSHIFTBLUR;Maska rozmycia ruchu +TP_RAW_PIXELSHIFTDMETHOD;Metoda demozaikowania ruchu TP_RAW_PIXELSHIFTEPERISO;Czułość +TP_RAW_PIXELSHIFTEQUALBRIGHT;Wyrównaj jasność klatek +TP_RAW_PIXELSHIFTHOLEFILL;Wypełnij dziury w masce ruchu +TP_RAW_PIXELSHIFTHOLEFILL_TOOLTIP;Wypełnia dziury w masce ruchu +TP_RAW_PIXELSHIFTMEDIAN;Użyj mediany dla poruszonych fragmentów TP_RAW_PIXELSHIFTMM_AUTO;Automatyczny TP_RAW_PIXELSHIFTMM_CUSTOM;Własny TP_RAW_PIXELSHIFTMM_OFF;Wyłączony +TP_RAW_PIXELSHIFTMOTIONMETHOD;Korekcja ruchu +TP_RAW_PIXELSHIFTNONGREENCROSS;Szukaj ruchu w kanale niebieskim/czerwonym +TP_RAW_PIXELSHIFTSHOWMOTION;Pokaż maskę ruchu +TP_RAW_PIXELSHIFTSHOWMOTIONMASKONLY;Pokaż tylko maskę ruchu +TP_RAW_PIXELSHIFTSHOWMOTIONMASKONLY_TOOLTIP;Pokaż samą maskę ruchu (bez obrazu). TP_RAW_PIXELSHIFTSIGMA;Promień rozmycia +TP_RAW_PIXELSHIFTSMOOTH;Miękkie przejścia TP_RAW_RCD;RCD TP_RAW_RCDVNG4;RCD+VNG4 TP_RAW_SENSOR_BAYER_LABEL;Matryca z filtrem Bayera @@ -1530,6 +1664,7 @@ TP_RAW_SENSOR_XTRANS_LABEL;Matryca z filtrem X-Trans TP_RAW_VNG4;VNG4 TP_RAW_XTRANS;X-Trans TP_RAW_XTRANSFAST;Szybki X-Trans +TP_RESIZE_ALLOW_UPSCALING;Zezwól na zwiększenie rozdzielczości TP_RESIZE_APPLIESTO;Dotyczy: TP_RESIZE_CROPPEDAREA;Obszaru kadrowanego TP_RESIZE_FITBOX;Wymiary obwodu @@ -1548,10 +1683,21 @@ TP_RETINEX_CONTEDIT_HSL;Histogram HSL TP_RETINEX_CONTEDIT_LAB;Histogram L*a*b* TP_RETINEX_CONTEDIT_LH;Odcień TP_RETINEX_CONTEDIT_MAP;Wyrównywanie +TP_RETINEX_CURVEEDITOR_CD;L=f(L) +TP_RETINEX_CURVEEDITOR_LH;Siła=f(H) +TP_RETINEX_CURVEEDITOR_MAP;L=f(L) TP_RETINEX_EQUAL;Wyrównywanie TP_RETINEX_GAIN;Wzmocnienie +TP_RETINEX_GAMMA;Gamma +TP_RETINEX_GAMMA_FREE;Wolna +TP_RETINEX_GAMMA_HIGH;Wysoka +TP_RETINEX_GAMMA_LOW;Niska +TP_RETINEX_GAMMA_MID;Średnia +TP_RETINEX_GAMMA_NONE;Żaden TP_RETINEX_HIGH;Wysoki TP_RETINEX_HIGHLIGHT;Próg podświetleń +TP_RETINEX_HSLSPACE_LIN;HSL-Liniowa +TP_RETINEX_HSLSPACE_LOG;HSL-Logarytmiczna TP_RETINEX_LABEL;Retinex TP_RETINEX_LABEL_MASK;Maska TP_RETINEX_LABSPACE;L*a*b* @@ -1595,6 +1741,7 @@ TP_SHARPENEDGE_LABEL;Krawędzie TP_SHARPENEDGE_PASSES;Powtórzenia TP_SHARPENEDGE_THREE;Tylko luminancja TP_SHARPENING_AMOUNT;Siła +TP_SHARPENING_BLUR;Promień rozmycia TP_SHARPENING_CONTRAST;Próg kontrastu TP_SHARPENING_EDRADIUS;Promień TP_SHARPENING_EDTOLERANCE;Tolerancja krawędzi @@ -1617,6 +1764,7 @@ TP_SHARPENMICRO_MATRIX;Matryca 3×3 zamiast 5×5 TP_SHARPENMICRO_UNIFORMITY;Jednolitość TP_SOFTLIGHT_STRENGTH;Siła TP_TM_FATTAL_AMOUNT;Ilość +TP_TM_FATTAL_LABEL;Kompresja zakresu dynamiki TP_TM_FATTAL_THRESHOLD;Detale TP_VIBRANCE_AVOIDCOLORSHIFT;Zapobiegaj przesunięcia kolorów TP_VIBRANCE_CURVEEDITOR_SKINTONES;HH @@ -1659,14 +1807,24 @@ TP_WAVELET_BACKGROUND;Tło TP_WAVELET_BACUR;Krzywa TP_WAVELET_BALCHRO;Balans chrominancji TP_WAVELET_BANONE;Żaden +TP_WAVELET_BASLI;Suwak +TP_WAVELET_BATYPE;Metoda balansu kontrastu +TP_WAVELET_CBENAB;Tonowanie i balans kolorów TP_WAVELET_CCURVE;Kontrast lokalny +TP_WAVELET_CH1;Cały zakres chrominancji +TP_WAVELET_CH2;Nasycone/pastelowe +TP_WAVELET_CH3;Połącz poziomy kontrastu TP_WAVELET_CHCU;Krzywa +TP_WAVELET_CHSL;Suwaki TP_WAVELET_COMPCONT;Kontrast +TP_WAVELET_COMPGAMMA;Kompresja - Gamma TP_WAVELET_CONTR;Gamut TP_WAVELET_CONTRA;Kontrast TP_WAVELET_CONTRAST_MINUS;Kontrast - TP_WAVELET_CONTRAST_PLUS;Kontrast + TP_WAVELET_CTYPE;Kontrola chrominancji +TP_WAVELET_CURVEEDITOR_CL;L +TP_WAVELET_CURVEEDITOR_HH;HH TP_WAVELET_DALL;We wszystkich kierunkach TP_WAVELET_DAUB2;D2 - niski TP_WAVELET_DAUB4;D4 - standard @@ -1681,18 +1839,28 @@ TP_WAVELET_EDGCONT;Kontrast lokalny TP_WAVELET_EDGE;Ostrość krawędzi TP_WAVELET_EDGEDETECTTHR;Niski próg (szum) TP_WAVELET_EDGEDETECTTHR2;Wysoki próg (wykrywanie) +TP_WAVELET_EDGTHRESH;Szczegółowość TP_WAVELET_EDRAD;Promień TP_WAVELET_EDSL;Suwaki progów +TP_WAVELET_EDTYPE;Metoda kontrastu lokalnego: TP_WAVELET_EDVAL;Siła +TP_WAVELET_FINAL;Ostateczny retusz +TP_WAVELET_FINEST;Najdokładniej +TP_WAVELET_HIGHLIGHT;Zakres luminancji podświetleń +TP_WAVELET_HS1;Zakres luminancji TP_WAVELET_HS2;Cienie/Podświetlenia TP_WAVELET_HUESKIN;Odcień skóry TP_WAVELET_HUESKY;Odcień nieba +TP_WAVELET_LEVCH;Chrominancja TP_WAVELET_LEVF;Kontrast TP_WAVELET_LEVONE;Poziom 2 TP_WAVELET_LEVTHRE;Poziom 4 TP_WAVELET_LEVTWO;Poziom 3 TP_WAVELET_LEVZERO;Poziom 1 +TP_WAVELET_LINKEDG;Połącz z siłą 'Ostrość krawędzi' TP_WAVELET_LIPST;Usprawniony algorytm +TP_WAVELET_LOWLIGHT;Zakres luminancji cieni +TP_WAVELET_MEDGREINF;Pierwszy poziom TP_WAVELET_MEDI;Usuwaj artefakty niebieskiego nieba TP_WAVELET_MEDILEV;Wykrywanie krawędzi TP_WAVELET_NEUTRAL;Neutralny @@ -1701,12 +1869,16 @@ TP_WAVELET_NPHIGH;Wysoki TP_WAVELET_NPLOW;Niski TP_WAVELET_NPNONE;Brak TP_WAVELET_NPTYPE;Piksele sąsiadujące +TP_WAVELET_PASTEL;Chrominancja kolorów pastelowych TP_WAVELET_PROC;Proces TP_WAVELET_RE1;Wzmocniony TP_WAVELET_RE2;Niezmieniony TP_WAVELET_RE3;Zmniejszony +TP_WAVELET_RESCHRO;Chrominancja TP_WAVELET_RESCON;Cienie TP_WAVELET_RESCONH;Podświetlenia +TP_WAVELET_SAT;Chrominancja kolorów nasyconych +TP_WAVELET_SKY;Odcień nieba - wybór/ochrona TP_WAVELET_STREN;Siła TP_WAVELET_STRENGTH;Siła TP_WAVELET_SUPE;Ekstra @@ -1714,7 +1886,9 @@ TP_WAVELET_THR;Próg cieni TP_WAVELET_THRESHOLD;Poziom podświetleń TP_WAVELET_THRESHOLD2;Poziom cieni TP_WAVELET_THRH;Próg podświetleń +TP_WAVELET_TMSTRENGTH;Siła kompresji TP_WAVELET_TMTYPE;Metoda kompresji +TP_WAVELET_TON;Tonowanie TP_WBALANCE_AUTO;Auto TP_WBALANCE_CAMERA;Z aparatu TP_WBALANCE_CLOUDY;Pochmurnie @@ -1757,6 +1931,7 @@ TP_WBALANCE_SOLUX41;Solux 4100K TP_WBALANCE_SOLUX47;Solux 4700K (vendor) TP_WBALANCE_SOLUX47_NG;Solux 4700K (Nat. Gallery) TP_WBALANCE_SPOTWB;Punktowy +TP_WBALANCE_TEMPBIAS;Kompensacja automatycznego balansu bieli (AWB) TP_WBALANCE_TEMPERATURE;Temperatura TP_WBALANCE_TUNGSTEN;Wolfram TP_WBALANCE_WATER1;Pod wodą 1 @@ -1774,16 +1949,9 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - ! Untranslated keys follow; remove the ! prefix after an entry is translated. !!!!!!!!!!!!!!!!!!!!!!!!! -!ADJUSTER_RESET_TO_DEFAULT;Click - reset to default value.\nCtrl+click - reset to initial value. -!CURVEEDITOR_AXIS_IN;I: -!CURVEEDITOR_AXIS_LEFT_TAN;LT: -!CURVEEDITOR_AXIS_OUT;O: -!CURVEEDITOR_AXIS_RIGHT_TAN;RT: !CURVEEDITOR_EDITPOINT_HINT;Enable edition of node in/out values.\n\nRight-click on a node to select it.\nRight-click on empty space to de-select the node. -!DONT_SHOW_AGAIN;Don't show this message again. !DYNPROFILEEDITOR_EDIT_RULE;Edit Dynamic Profile Rule !DYNPROFILEEDITOR_ENTRY_TOOLTIP;The matching is case insensitive.\nUse the "re:" prefix to enter\na regular expression. -!DYNPROFILEEDITOR_IMGTYPE_HDR;HDR !DYNPROFILEEDITOR_IMGTYPE_PS;Pixel Shift !DYNPROFILEEDITOR_NEW_RULE;New Dynamic Profile Rule !EXPORT_BYPASS;Processing steps to bypass @@ -1796,11 +1964,8 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !FILEBROWSER_DELETEDIALOG_ALL;Are you sure you want to permanently delete all %1 files in trash? !FILEBROWSER_DELETEDIALOG_SELECTED;Are you sure you want to permanently delete the selected %1 files? !FILEBROWSER_DELETEDIALOG_SELECTEDINCLPROC;Are you sure you want to permanently delete the selected %1 files, including a queue-processed version? -!FILEBROWSER_POPUPREMOVE;Delete permanently !FILEBROWSER_POPUPREMOVEINCLPROC;Delete permanently, including queue-processed version -!FILEBROWSER_SHOWNOTTRASHHINT;Show only images not in trash. !FILEBROWSER_SHOWORIGINALHINT;Show only original images.\n\nWhen several images exist with the same filename but different extensions, the one considered original is the one whose extension is nearest the top of the parsed extensions list in Preferences > File Browser > Parsed Extensions. -!GENERAL_SLIDER;Slider !GIMP_PLUGIN_INFO;Welcome to the RawTherapee GIMP plugin!\nOnce you are done editing, simply close the main RawTherapee window and the image will be automatically imported in GIMP. !HISTOGRAM_TOOLTIP_MODE;Toggle between linear, log-linear and log-log scaling of the histogram. !HISTORY_MSG_235;B&W - CM - Auto @@ -1862,8 +2027,6 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !HISTORY_MSG_416;Retinex !HISTORY_MSG_417;Retinex - Transmission median !HISTORY_MSG_420;Retinex - Histogram - HSL -!HISTORY_MSG_421;Retinex - Gamma -!HISTORY_MSG_422;Retinex - Gamma !HISTORY_MSG_423;Retinex - Gamma slope !HISTORY_MSG_424;Retinex - HL threshold !HISTORY_MSG_425;Retinex - Log base @@ -1877,14 +2040,10 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !HISTORY_MSG_443;Output black point compensation !HISTORY_MSG_444;WB - Temp bias !HISTORY_MSG_445;Raw sub-image -!HISTORY_MSG_453;PS - Show mask only !HISTORY_MSG_457;PS - Check red/blue !HISTORY_MSG_462;PS - Check green !HISTORY_MSG_464;PS - Blur motion mask -!HISTORY_MSG_465;PS - Blur radius -!HISTORY_MSG_468;PS - Fill holes !HISTORY_MSG_469;PS - Median -!HISTORY_MSG_472;PS - Smooth transitions !HISTORY_MSG_473;PS - Use LMMSE !HISTORY_MSG_476;CAM02 - Temp out !HISTORY_MSG_477;CAM02 - Green out @@ -1898,9 +2057,6 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !HISTORY_MSG_488;Dynamic Range Compression !HISTORY_MSG_493;L*a*b* Adjustments !HISTORY_MSG_494;Capture Sharpening -!HISTORY_MSG_COLORTONING_LABGRID_VALUE;CT - Color correction -!HISTORY_MSG_COLORTONING_LABREGION_AB;CT - Color correction -!HISTORY_MSG_COLORTONING_LABREGION_CHANNEL;CT - Channel !HISTORY_MSG_COLORTONING_LABREGION_CHROMATICITYMASK;CT - region C mask !HISTORY_MSG_COLORTONING_LABREGION_HUEMASK;CT - H mask !HISTORY_MSG_COLORTONING_LABREGION_LIGHTNESS;CT - Lightness @@ -1909,7 +2065,6 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !HISTORY_MSG_COLORTONING_LABREGION_MASKBLUR;CT - region mask blur !HISTORY_MSG_COLORTONING_LABREGION_OFFSET;CT - region offset !HISTORY_MSG_COLORTONING_LABREGION_POWER;CT - region power -!HISTORY_MSG_COLORTONING_LABREGION_SATURATION;CT - Saturation !HISTORY_MSG_COLORTONING_LABREGION_SHOWMASK;CT - region show mask !HISTORY_MSG_COLORTONING_LABREGION_SLOPE;CT - region slope !HISTORY_MSG_DUALDEMOSAIC_AUTO_CONTRAST;Dual demosaic - Auto threshold @@ -1928,43 +2083,19 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !HISTORY_MSG_PIXELSHIFT_DEMOSAIC;PS - Demosaic method for motion !HISTORY_MSG_PREPROCESS_LINEDENOISE_DIRECTION;Line noise filter direction !HISTORY_MSG_PREPROCESS_PDAFLINESFILTER;PDAF lines filter -!HISTORY_MSG_RAWCACORR_AUTOIT;Raw CA Correction - Iterations -!HISTORY_MSG_RAWCACORR_COLORSHIFT;Raw CA Correction - Avoid color shift !HISTORY_MSG_RAW_BORDER;Raw border !HISTORY_MSG_RESIZE_ALLOWUPSCALING;Resize - Allow upscaling -!HISTORY_MSG_SHARPENING_BLUR;Sharpening - Blur radius -!HISTORY_MSG_SHARPENING_CONTRAST;Sharpening - Contrast threshold -!HISTORY_MSG_SH_COLORSPACE;S/H - Colorspace -!HISTORY_MSG_SOFTLIGHT_ENABLED;Soft light -!HISTORY_MSG_SOFTLIGHT_STRENGTH;Soft light - Strength !HISTORY_MSG_TM_FATTAL_ANCHOR;DRC - Anchor -!HISTORY_MSG_TRANS_Method;Geometry - Method !ICCPROFCREATOR_DESCRIPTION_ADDPARAM;Append gamma and slope values to the description !ICCPROFCREATOR_DESCRIPTION_TOOLTIP;Leave empty to set the default description. !ICCPROFCREATOR_ILL;Illuminant: !ICCPROFCREATOR_ILL_TOOLTIP;You can only set the illuminant for ICC v4 profiles. !ICCPROFCREATOR_PRIMARIES;Primaries: -!ICCPROFCREATOR_PRIM_ACESP0;ACES AP0 -!ICCPROFCREATOR_PRIM_ACESP1;ACES AP1 -!ICCPROFCREATOR_PRIM_BLUX;Blue X -!ICCPROFCREATOR_PRIM_BLUY;Blue Y -!ICCPROFCREATOR_PRIM_GREX;Green X -!ICCPROFCREATOR_PRIM_GREY;Green Y -!ICCPROFCREATOR_PRIM_REDX;Red X -!ICCPROFCREATOR_PRIM_REDY;Red Y !ICCPROFCREATOR_PRIM_TOOLTIP;You can only set custom primaries for ICC v4 profiles. -!ICCPROFCREATOR_PRIM_WIDEG;Widegamut -!ICCPROFCREATOR_SLOPE;Slope -!ICCPROFCREATOR_TRC_PRESET;Tone response curve: !IPTCPANEL_CATEGORYHINT;Identifies the subject of the image in the opinion of the provider. -!IPTCPANEL_COPYRIGHT;Copyright notice -!IPTCPANEL_COPYRIGHTHINT;Enter a Notice on the current owner of the Copyright for this image, such as ©2008 Jane Doe. -!IPTCPANEL_COUNTRYHINT;Enter the name of the country pictured in this image. -!IPTCPANEL_CREATORHINT;Enter the name of the person that created this image. !IPTCPANEL_CREATORJOBTITLE;Creator's job title !IPTCPANEL_CREATORJOBTITLEHINT;Enter the Job Title of the person listed in the Creator field. !IPTCPANEL_DESCRIPTIONHINT;Enter a "caption" describing the who, what, and why of what is happening in this image, this might include names of people, and/or their role in the action that is taking place within the image. -!IPTCPANEL_DESCRIPTIONWRITER;Description writer !IPTCPANEL_DESCRIPTIONWRITERHINT;Enter the name of the person involved in writing, editing or correcting the description of the image. !IPTCPANEL_HEADLINEHINT;Enter a brief publishable synopsis or summary of the contents of the image. !IPTCPANEL_INSTRUCTIONSHINT;Enter information about embargoes, or other restrictions not covered by the Copyright field. @@ -1973,9 +2104,6 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !IPTCPANEL_SOURCEHINT;Enter or edit the name of a person or party who has a role in the content supply chain, such as a person or entity from whom you received this image from. !IPTCPANEL_SUPPCATEGORIESHINT;Further refines the subject of the image. !IPTCPANEL_TITLEHINT;Enter a short verbal and human readable name for the image, this may be the file name. -!IPTCPANEL_TRANSREFERENCE;Job ID -!IPTCPANEL_TRANSREFERENCEHINT;Enter a number or identifier needed for workflow control or tracking. -!MAIN_MSG_TOOMANYOPENEDITORS;Too many open editors.\nPlease close an editor to continue. !MAIN_TOOLTIP_BACKCOLOR3;Background color of the preview: middle grey\nShortcut: 9 !MAIN_TOOLTIP_PREVIEWSHARPMASK;Preview the sharpening contrast mask.\nShortcut: p\n\nOnly works when sharpening is enabled and zoom >= 100%. !OPTIONS_BUNDLED_MISSING;The bundled profile "%1" could not be found!\n\nYour installation could be damaged.\n\nDefault internal values will be used instead. @@ -1991,78 +2119,34 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !PARTIALPASTE_RAW_BORDER;Raw border !PARTIALPASTE_RAW_IMAGENUM;Sub-image !PARTIALPASTE_RAW_PIXELSHIFT;Pixel Shift -!PARTIALPASTE_SOFTLIGHT;Soft light -!PARTIALPASTE_TM_FATTAL;Dynamic range compression -!PREFERENCES_APPEARANCE_COLORPICKERFONT;Color picker font -!PREFERENCES_APPEARANCE_CROPMASKCOLOR;Crop mask color -!PREFERENCES_APPEARANCE_MAINFONT;Main font -!PREFERENCES_APPEARANCE_PSEUDOHIDPI;Pseudo-HiDPI mode !PREFERENCES_AUTOSAVE_TP_OPEN;Save tool collapsed/expanded state on exit !PREFERENCES_CACHECLEAR_ALLBUTPROFILES;Clear all cached files except for cached processing profiles: !PREFERENCES_CACHECLEAR_SAFETY;Only files in the cache are cleared. Processing profiles stored alongside the source images are not touched. -!PREFERENCES_CHUNKSIZES;Tiles per thread -!PREFERENCES_CHUNKSIZE_RAW_CA;Raw CA correction -!PREFERENCES_CLUTSCACHE;HaldCLUT Cache !PREFERENCES_CLUTSCACHE_LABEL;Maximum number of cached CLUTs -!PREFERENCES_CROP;Crop Editing -!PREFERENCES_CROP_AUTO_FIT;Automatically zoom to fit the crop -!PREFERENCES_CROP_GUIDES;Guides shown when not editing the crop -!PREFERENCES_CURVEBBOXPOS;Position of curve copy & paste buttons -!PREFERENCES_EDITORCMDLINE;Custom command line -!PREFERENCES_FILEBROWSERTOOLBARSINGLEROW;Compact toolbars in File Browser !PREFERENCES_FSTRIP_SAME_THUMB_HEIGHT;Same thumbnail height between the Filmstrip and the File Browser !PREFERENCES_FSTRIP_SAME_THUMB_HEIGHT_HINT;Having separate thumbnail size will require more processing time each time you'll switch between the single Editor tab and the File Browser. !PREFERENCES_INSPECT_MAXBUFFERS_TOOLTIP;Set the maximum number of images stored in cache when hovering over them in the File Browser; systems with little RAM (2GB) should keep this value set to 1 or 2. -!PREFERENCES_MAXRECENTFOLDERS;Maximum number of recent folders !PREFERENCES_MONINTENT;Default rendering intent -!PREFERENCES_MONPROFILE_WARNOSX;Due to MacOS limitations, only sRGB is supported. -!PREFERENCES_OVERLAY_FILENAMES_FILMSTRIP;Overlay filenames on thumbnails in the editor pannel -!PREFERENCES_PARSEDEXTDOWNHINT;Move selected extension down in the list. -!PREFERENCES_PARSEDEXTUPHINT;Move selected extension up in the list. -!PREFERENCES_PERFORMANCE_MEASURE;Measure !PREFERENCES_PERFORMANCE_MEASURE_HINT;Logs processing times in console !PREFERENCES_PERFORMANCE_THREADS_LABEL;Maximum number of threads for Noise Reduction and Wavelet Levels (0 = Automatic) -!PREFERENCES_PREVDEMO_LABEL;Demosaicing method used for the preview at <100% zoom: -!PREFERENCES_PREVDEMO_SIDECAR;As in PP3 !PREFERENCES_PRINTER;Printer (Soft-Proofing) !PREFERENCES_PROFILESAVEBOTH;Save processing profile both to the cache and next to the input file -!PREFERENCES_PROFILESAVELOCATION;Processing profile saving location !PREFERENCES_PRTINTENT;Rendering intent !PREFERENCES_REMEMBERZOOMPAN;Remember zoom % and pan offset !PREFERENCES_REMEMBERZOOMPAN_TOOLTIP;Remember the zoom % and pan offset of the current image when opening a new image.\n\nThis option only works in "Single Editor Tab Mode" and when "Demosaicing method used for the preview at <100% zoom" is set to "As in PP3". !PREFERENCES_SAVE_TP_OPEN_NOW;Save tool collapsed/expanded state now -!PREFERENCES_SERIALIZE_TIFF_READ;TIFF Read Settings !PREFERENCES_SERIALIZE_TIFF_READ_LABEL;Serialize reading of TIFF files !PREFERENCES_SERIALIZE_TIFF_READ_TOOLTIP;Enabling this option when working with folders containing uncompressed TIFF files can increase performance of thumbnail generation. !PREFERENCES_SHOWFILMSTRIPTOOLBAR;Show Filmstrip toolbar !PREFERENCES_TAB_DYNAMICPROFILE;Dynamic Profile Rules !PREFERENCES_THUMBNAIL_INSPECTOR_JPEG;Embedded JPEG preview -!PREFERENCES_THUMBNAIL_INSPECTOR_MODE;Image to show !PREFERENCES_THUMBNAIL_INSPECTOR_RAW;Neutral raw rendering !PREFERENCES_THUMBNAIL_INSPECTOR_RAW_IF_NO_JPEG_FULLSIZE;Embedded JPEG if fullsize, neutral raw otherwise -!PROFILEPANEL_PDYNAMIC;Dynamic -!PROGRESSBAR_GREENEQUIL;Green equilibration... -!PROGRESSBAR_HOTDEADPIXELFILTER;Hot/dead pixel filter... -!PROGRESSBAR_LINEDENOISE;Line noise filter... -!PROGRESSBAR_RAWCACORR;Raw CA correction... -!QUEUE_LOCATION_TITLE;Output Location !QUEUE_STARTSTOP_TOOLTIP;Start or stop processing the images in the queue.\n\nShortcut: Ctrl+s -!SAMPLEFORMAT_0;Unknown data format -!SAMPLEFORMAT_1;8-bit unsigned -!SAMPLEFORMAT_2;16-bit unsigned -!SAMPLEFORMAT_4;24-bit LogLuv -!SAMPLEFORMAT_8;32-bit LogLuv -!SAMPLEFORMAT_16;16-bit floating-point -!SAMPLEFORMAT_32;24-bit floating-point -!SAMPLEFORMAT_64;32-bit floating-point -!SAVEDLG_FILEFORMAT_FLOAT; floating-point !SAVEDLG_SUBSAMP_TOOLTIP;Best compression:\nJ:a:b 4:2:0\nh/v 2/2\nChroma halved horizontally and vertically.\n\nBalanced:\nJ:a:b 4:2:2\nh/v 2/1\nChroma halved horizontally.\n\nBest quality:\nJ:a:b 4:4:4\nh/v 1/1\nNo chroma subsampling. !SOFTPROOF_GAMUTCHECK_TOOLTIP;Highlight pixels with out-of-gamut colors with respect to:\n- the printer profile, if one is set and soft-proofing is enabled,\n- the output profile, if a printer profile is not set and soft-proofing is enabled,\n- the monitor profile, if soft-proofing is disabled. !SOFTPROOF_TOOLTIP;Soft-proofing simulates the appearance of the image:\n- when printed, if a printer profile is set in Preferences > Color Management,\n- when viewed on a display that uses the current output profile, if a printer profile is not set. !TOOLBAR_TOOLTIP_COLORPICKER;Lockable Color Picker\n\nWhen the tool is active:\n- Add a picker: left-click.\n- Drag a picker: left-click and drag.\n- Delete a picker: right-click.\n- Delete all pickers: Ctrl+Shift+right-click.\n- Revert to hand tool: right-click outside any picker. -!TP_CBDL_AFT;After Black-and-White -!TP_CBDL_BEF;Before Black-and-White -!TP_CBDL_METHOD;Process located !TP_CBDL_METHOD_TOOLTIP;Choose whether the Contrast by Detail Levels tool is to be positioned after the Black-and-White tool, which makes it work in L*a*b* space, or before it, which makes it work in RGB space. !TP_COLORAPP_CAT02ADAPTATION_TOOLTIP;When setting manually, values above 65 are recommended. !TP_COLORAPP_FREE;Free temp+green + CAT02 + [output] @@ -2072,18 +2156,11 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !TP_COLORTONING_LABGRID_VALUES;HL: a=%1 b=%2\nS: a=%3 b=%4 !TP_COLORTONING_LABREGIONS;Color correction regions !TP_COLORTONING_LABREGION_ABVALUES;a=%1 b=%2 -!TP_COLORTONING_LABREGION_CHROMATICITYMASK;C -!TP_COLORTONING_LABREGION_HUEMASK;H !TP_COLORTONING_LABREGION_LIGHTNESS;Lightness -!TP_COLORTONING_LABREGION_LIGHTNESSMASK;L -!TP_COLORTONING_LABREGION_MASKBLUR;Mask Blur -!TP_COLORTONING_LABREGION_POWER;Power -!TP_COLORTONING_LABREGION_SLOPE;Slope !TP_CROP_GTHARMMEANS;Harmonic Means !TP_CROP_GTTRIANGLE1;Golden Triangles 1 !TP_CROP_GTTRIANGLE2;Golden Triangles 2 !TP_DIRPYRDENOISE_CHROMINANCE_AMZ;Auto multi-zones -!TP_DIRPYRDENOISE_CHROMINANCE_AUTOGLOBAL;Automatic global !TP_DIRPYRDENOISE_CHROMINANCE_CURVE_TOOLTIP;Increase (multiply) the value of all chrominance sliders.\nThis curve lets you adjust the strength of chromatic noise reduction as a function of chromaticity, for instance to increase the action in areas of low saturation and to decrease it in those of high saturation. !TP_DIRPYRDENOISE_CHROMINANCE_METHODADVANCED_TOOLTIP;Manual\nActs on the full image.\nYou control the noise reduction settings manually.\n\nAutomatic global\nActs on the full image.\n9 zones are used to calculate a global chrominance noise reduction setting.\n\nPreview\nActs on the whole image.\nThe part of the image visible in the preview is used to calculate global chrominance noise reduction settings. !TP_DIRPYRDENOISE_CHROMINANCE_METHOD_TOOLTIP;Manual\nActs on the full image.\nYou control the noise reduction settings manually.\n\nAutomatic global\nActs on the full image.\n9 zones are used to calculate a global chrominance noise reduction setting.\n\nAutomatic multi-zones\nNo preview - works only during saving, but using the "Preview" method by matching the tile size and center to the preview size and center you can get an idea of the expected results.\nThe image is divided into tiles (about 10 to 70 depending on image size) and each tile receives its own chrominance noise reduction settings.\n\nPreview\nActs on the whole image.\nThe part of the image visible in the preview is used to calculate global chrominance noise reduction settings. @@ -2096,22 +2173,11 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !TP_DIRPYRDENOISE_MEDIAN_METHOD_WEIGHTED;Weighted L* (little) + a*b* (normal) !TP_DIRPYRDENOISE_MEDIAN_PASSES_TOOLTIP;Applying three median filter iterations with a 3×3 window size often leads to better results than using one median filter iteration with a 7×7 window size. !TP_DIRPYRDENOISE_MEDIAN_TYPE_TOOLTIP;Apply a median filter of the desired window size. The larger the window's size, the longer it takes.\n\n3×3 soft: treats 5 pixels in a 3×3 pixel window.\n3×3: treats 9 pixels in a 3×3 pixel window.\n5×5 soft: treats 13 pixels in a 5×5 pixel window.\n5×5: treats 25 pixels in a 5×5 pixel window.\n7×7: treats 49 pixels in a 7×7 pixel window.\n9×9: treats 81 pixels in a 9×9 pixel window.\n\nSometimes it is possible to achieve higher quality running several iterations with a smaller window size than one iteration with a larger one. -!TP_DIRPYRDENOISE_TYPE_3X3;3×3 -!TP_DIRPYRDENOISE_TYPE_3X3SOFT;3×3 soft -!TP_DIRPYRDENOISE_TYPE_5X5;5×5 -!TP_DIRPYRDENOISE_TYPE_5X5SOFT;5×5 soft -!TP_DIRPYRDENOISE_TYPE_7X7;7×7 -!TP_DIRPYRDENOISE_TYPE_9X9;9×9 !TP_DISTORTION_AUTO_TIP;Automatically corrects lens distortion in raw files by matching it against the embedded JPEG image if one exists and has had its lens disortion auto-corrected by the camera. !TP_EXPOSURE_HISTMATCHING;Auto-Matched Tone Curve !TP_EXPOSURE_HISTMATCHING_TOOLTIP;Automatically adjust sliders and curves (except exposure compensation) to match the look of the embedded JPEG thumbnail. -!TP_EXPOSURE_TCMODE_PERCEPTUAL;Perceptual -!TP_FILMNEGATIVE_BLUE;Blue ratio !TP_FILMNEGATIVE_GREEN;Reference exponent (contrast) !TP_FILMNEGATIVE_GUESS_TOOLTIP;Automatically set the red and blue ratios by picking two patches which had a neutral hue (no color) in the original scene. The patches should differ in brightness. Set the white balance afterwards. -!TP_FILMNEGATIVE_LABEL;Film Negative -!TP_FILMNEGATIVE_PICK;Pick neutral spots -!TP_FILMNEGATIVE_RED;Red ratio !TP_FILMSIMULATION_SLOWPARSEDIR;RawTherapee is configured to look for Hald CLUT images, which are used for the Film Simulation tool, in a folder which is taking too long to load.\nGo to Preferences > Image Processing > Film Simulation\nto see which folder is being used. You should either point RawTherapee to a folder which contains only Hald CLUT images and nothing more, or to an empty folder if you don't want to use the Film Simulation tool.\n\nRead the Film Simulation article in RawPedia for more information.\n\nDo you want to cancel the scan now? !TP_ICM_APPLYBASELINEEXPOSUREOFFSET;Baseline exposure !TP_ICM_APPLYBASELINEEXPOSUREOFFSET_TOOLTIP;Employ the embedded DCP baseline exposure offset. The setting is only available if the selected DCP has one. @@ -2122,21 +2188,10 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !TP_ICM_PROFILEINTENT;Rendering Intent !TP_ICM_SAVEREFERENCE;Save Reference Image !TP_ICM_SAVEREFERENCE_APPLYWB_TOOLTIP;Generally, apply the white balance when saving images to create ICC profiles, and do not apply the white balance to create DCP profiles. -!TP_ICM_WORKING_TRC;Tone response curve: -!TP_ICM_WORKING_TRC_GAMMA;Gamma -!TP_ICM_WORKING_TRC_SLOPE;Slope -!TP_ICM_WORKING_TRC_TOOLTIP;Only for built-in profiles. -!TP_LENSPROFILE_CORRECTION_AUTOMATCH;Automatically selected -!TP_LENSPROFILE_CORRECTION_MANUAL;Manually selected !TP_LENSPROFILE_LENS_WARNING;Warning: the crop factor used for lens profiling is larger than the crop factor of the camera, the results might be wrong. -!TP_LENSPROFILE_USE_HEADER;Correct -!TP_LOCALCONTRAST_DARKNESS;Darkness level -!TP_LOCALCONTRAST_LIGHTNESS;Lightness level !TP_PDSHARPENING_LABEL;Capture Sharpening -!TP_PREPROCESS_LINEDENOISE_DIRECTION_BOTH;Both !TP_PREPROCESS_LINEDENOISE_DIRECTION_PDAF_LINES;Horizontal only on PDAF rows !TP_PREPROCESS_PDAFLINESFILTER;PDAF lines filter -!TP_PRSHARPENING_LABEL;Post-Resize Sharpening !TP_PRSHARPENING_TOOLTIP;Sharpens the image after resizing. Only works when the "Lanczos" resizing method is used. It is impossible to preview the effects of this tool. See RawPedia for usage instructions. !TP_RAWCACORR_AUTOIT_TOOLTIP;This setting is available if "Auto-correction" is checked.\nAuto-correction is conservative, meaning that it often does not correct all chromatic aberration.\nTo correct the remaining chromatic aberration, you can use up to five iterations of automatic chromatic aberration correction.\nEach iteration will reduce the remaining chromatic aberration from the last iteration at the cost of additional processing time. !TP_RAW_BORDER;Border @@ -2147,44 +2202,22 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !TP_RAW_IMAGENUM_TOOLTIP;Some raw files consist of several sub-images (Pentax/Sony Pixel Shift, Pentax 3-in-1 HDR, Canon Dual Pixel, Fuji EXR).\n\nWhen using any demosaicing method other than Pixel Shift, this selects which sub-image is used.\n\nWhen using the Pixel Shift demosaicing method on a Pixel Shift raw, all sub-images are used, and this selects which sub-image should be used for moving parts. !TP_RAW_NONE;None (Shows sensor pattern) !TP_RAW_PIXELSHIFT;Pixel Shift -!TP_RAW_PIXELSHIFTBLUR;Blur motion mask -!TP_RAW_PIXELSHIFTDMETHOD;Demosaic method for motion !TP_RAW_PIXELSHIFTEPERISO_TOOLTIP;The default value of 0 should work fine for base ISO.\nHigher values increase sensitivity of motion detection.\nChange in small steps and watch the motion mask while changing.\nIncrease sensitivity for underexposed or high ISO images. -!TP_RAW_PIXELSHIFTEQUALBRIGHT;Equalize brightness of frames !TP_RAW_PIXELSHIFTEQUALBRIGHTCHANNEL;Equalize per channel !TP_RAW_PIXELSHIFTEQUALBRIGHTCHANNEL_TOOLTIP;Enabled: Equalize the RGB channels individually.\nDisabled: Use same equalization factor for all channels. !TP_RAW_PIXELSHIFTEQUALBRIGHT_TOOLTIP;Equalize the brightness of the frames to the brightness of the selected frame.\nIf there are overexposed areas in the frames select the brightest frame to avoid magenta color cast in overexposed areas or enable motion correction. !TP_RAW_PIXELSHIFTGREEN;Check green channel for motion -!TP_RAW_PIXELSHIFTHOLEFILL;Fill holes in motion mask -!TP_RAW_PIXELSHIFTHOLEFILL_TOOLTIP;Fill holes in motion mask -!TP_RAW_PIXELSHIFTMEDIAN;Use median for moving parts !TP_RAW_PIXELSHIFTMEDIAN_TOOLTIP;Use median of all frames instead of selected frame for regions with motion.\nRemoves objects which are at different places in all frames.\nGives motion effect on slow moving (overlapping) objects. -!TP_RAW_PIXELSHIFTMOTIONMETHOD;Motion Correction -!TP_RAW_PIXELSHIFTNONGREENCROSS;Check red/blue channels for motion -!TP_RAW_PIXELSHIFTSHOWMOTION;Show motion mask -!TP_RAW_PIXELSHIFTSHOWMOTIONMASKONLY;Show only motion mask -!TP_RAW_PIXELSHIFTSHOWMOTIONMASKONLY_TOOLTIP;Shows the motion mask without the image. !TP_RAW_PIXELSHIFTSHOWMOTION_TOOLTIP;Overlays the image with a green mask showing the regions with motion. !TP_RAW_PIXELSHIFTSIGMA_TOOLTIP;The default radius of 1.0 usually fits well for base ISO.\nIncrease the value for high ISO shots, 5.0 is a good starting point.\nWatch the motion mask while changing the value. -!TP_RAW_PIXELSHIFTSMOOTH;Smooth transitions !TP_RAW_PIXELSHIFTSMOOTH_TOOLTIP;Smooth transitions between areas with motion and areas without.\nSet to 0 to disable transition smoothing.\nSet to 1 to either get the AMaZE/LMMSE result of the selected frame (depending on whether "Use LMMSE" is selected), or the median of all four frames if "Use median" is selected. -!TP_RESIZE_ALLOW_UPSCALING;Allow Upscaling -!TP_RETINEX_CURVEEDITOR_CD;L=f(L) !TP_RETINEX_CURVEEDITOR_CD_TOOLTIP;Luminance according to luminance L=f(L)\nCorrect raw data to reduce halos and artifacts. -!TP_RETINEX_CURVEEDITOR_LH;Strength=f(H) !TP_RETINEX_CURVEEDITOR_LH_TOOLTIP;Strength according to hue Strength=f(H)\nThis curve also acts on chroma when using the "Highlight" retinex method. -!TP_RETINEX_CURVEEDITOR_MAP;L=f(L) !TP_RETINEX_CURVEEDITOR_MAP_TOOLTIP;This curve can be applied alone or with a Gaussian mask or wavelet mask.\nBeware of artifacts! !TP_RETINEX_FREEGAMMA;Free gamma !TP_RETINEX_GAINOFFS;Gain and Offset (brightness) !TP_RETINEX_GAINTRANSMISSION;Gain transmission !TP_RETINEX_GAINTRANSMISSION_TOOLTIP;Amplify or reduce the transmission map to achieve the desired luminance.\nThe x-axis is the transmission.\nThe y-axis is the gain. -!TP_RETINEX_GAMMA;Gamma -!TP_RETINEX_GAMMA_FREE;Free -!TP_RETINEX_GAMMA_HIGH;High -!TP_RETINEX_GAMMA_LOW;Low -!TP_RETINEX_GAMMA_MID;Middle -!TP_RETINEX_GAMMA_NONE;None !TP_RETINEX_GAMMA_TOOLTIP;Restore tones by applying gamma before and after Retinex. Different from Retinex curves or others curves (Lab, Exposure, etc.). !TP_RETINEX_GRAD;Transmission gradient !TP_RETINEX_GRADS;Strength gradient @@ -2192,8 +2225,6 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !TP_RETINEX_GRAD_TOOLTIP;If slider at 0, all iterations are identical.\nIf > 0 Variance and Threshold are reduced when iterations increase, and conversely. !TP_RETINEX_HIGHLIG;Highlight !TP_RETINEX_HIGHLIGHT_TOOLTIP;Increase action of High algorithm.\nMay require you to re-adjust "Neighboring pixels" and to increase the "White-point correction" in the Raw tab -> Raw White Points tool. -!TP_RETINEX_HSLSPACE_LIN;HSL-Linear -!TP_RETINEX_HSLSPACE_LOG;HSL-Logarithmic !TP_RETINEX_ITER;Iterations (Tone-mapping) !TP_RETINEX_ITERF;Tone mapping !TP_RETINEX_ITER_TOOLTIP;Simulate a tone-mapping operator.\nHigh values increase the processing time. @@ -2219,31 +2250,21 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !TP_RETINEX_VIEW_METHOD_TOOLTIP;Standard - Normal display.\nMask - Displays the mask.\nUnsharp mask - Displays the image with a high radius unsharp mask.\nTransmission - Auto/Fixed - Displays the file transmission-map, before any action on contrast and brightness.\n\nAttention: the mask does not correspond to reality, but is amplified to make it more visible. !TP_RETINEX_VIEW_TRAN;Transmission - Auto !TP_RETINEX_VIEW_TRAN2;Transmission - Fixed -!TP_SHARPENING_BLUR;Blur radius !TP_SHARPENING_ITERCHECK;Auto limit iterations !TP_SHARPENING_RADIUS_BOOST;Corner radius boost !TP_SOFTLIGHT_LABEL;Soft Light !TP_TM_FATTAL_ANCHOR;Anchor -!TP_TM_FATTAL_LABEL;Dynamic Range Compression !TP_WAVELET_B2;Residual !TP_WAVELET_BALANCE;Contrast balance d/v-h !TP_WAVELET_BALANCE_TOOLTIP;Alters the balance between the wavelet directions: vertical-horizontal and diagonal.\nIf contrast, chroma or residual tone mapping are activated, the effect due to balance is amplified. !TP_WAVELET_BALCHRO_TOOLTIP;If enabled, the 'Contrast balance' curve or slider also modifies chroma balance. -!TP_WAVELET_BASLI;Slider -!TP_WAVELET_BATYPE;Contrast balance method -!TP_WAVELET_CBENAB;Toning and Color Balance !TP_WAVELET_CB_TOOLTIP;For strong values product color-toning by combining it or not with levels decomposition 'toning'\nFor low values you can change the white balance of the background (sky, ...) without changing that of the front plane, generally more contrasted -!TP_WAVELET_CH1;Whole chroma range -!TP_WAVELET_CH2;Saturated/pastel -!TP_WAVELET_CH3;Link contrast levels !TP_WAVELET_CHR;Chroma-contrast link strength !TP_WAVELET_CHRO;Saturated/pastel threshold !TP_WAVELET_CHRO_TOOLTIP;Sets the wavelet level which will be the threshold between saturated and pastel colors.\n1-x: saturated\nx-9: pastel\n\nIf the value exceeds the amount of wavelet levels you are using then it will be ignored. !TP_WAVELET_CHR_TOOLTIP;Adjusts chroma as a function of "contrast levels" and "chroma-contrast link strength" -!TP_WAVELET_CHSL;Sliders !TP_WAVELET_CHTYPE;Chrominance method !TP_WAVELET_COLORT;Opacity Red-Green -!TP_WAVELET_COMPGAMMA;Compression gamma !TP_WAVELET_COMPGAMMA_TOOLTIP;Adjusting the gamma of the residual image allows you to equilibrate the data and histogram. !TP_WAVELET_COMPTM;Tone mapping !TP_WAVELET_CONTEDIT;'After' contrast curve @@ -2251,9 +2272,7 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !TP_WAVELET_CURVEEDITOR_CC_TOOLTIP;Modifies local contrast as a function of the original local contrast (abscissa).\nLow abscissa values represent small local contrast (real values about 10..20).\n50% abscissa represents average local contrast (real value about 100..300).\n66% abscissa represents standard deviation of local contrast (real value about 300..800).\n100% abscissa represents maximum local contrast (real value about 3000..8000). !TP_WAVELET_CURVEEDITOR_CH;Contrast levels=f(Hue) !TP_WAVELET_CURVEEDITOR_CH_TOOLTIP;Modifies each level's contrast as a function of hue.\nTake care not to overwrite changes made with the Gamut sub-tool's hue controls.\nThe curve will only have an effect when wavelet contrast level sliders are non-zero. -!TP_WAVELET_CURVEEDITOR_CL;L !TP_WAVELET_CURVEEDITOR_CL_TOOLTIP;Applies a final contrast luminance curve at the end of the wavelet treatment. -!TP_WAVELET_CURVEEDITOR_HH;HH !TP_WAVELET_CURVEEDITOR_HH_TOOLTIP;Modifies the residual image's hue as a function of hue. !TP_WAVELET_DAUB;Edge performance !TP_WAVELET_DAUB_TOOLTIP;Changes Daubechies coefficients:\nD4 = Standard,\nD14 = Often best performance, 10% more time-intensive.\n\nAffects edge detection as well as the general quality of the firsts levels. However the quality is not strictly related to this coefficient and can vary with images and uses. @@ -2264,21 +2283,14 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !TP_WAVELET_EDGEDETECT_TOOLTIP;Moving the slider to the right increases edge sensitivity. This affects local contrast, edge settings and noise. !TP_WAVELET_EDGESENSI;Edge sensitivity !TP_WAVELET_EDGREINF_TOOLTIP;Reinforce or reduce the action of the first level, do the opposite to the second level, and leave the rest unchanged. -!TP_WAVELET_EDGTHRESH;Detail !TP_WAVELET_EDGTHRESH_TOOLTIP;Change the repartition between the first levels and the others. The higher the threshold the more the action is centered on the first levels. Be careful with negative values, they increase the action of high levels and can introduce artifacts. !TP_WAVELET_EDRAD_TOOLTIP;This radius adjustment is very different from those in other sharpening tools. Its value is compared to each level through a complex function. In this sense, a value of zero still has an effect. -!TP_WAVELET_EDTYPE;Local contrast method -!TP_WAVELET_FINAL;Final Touchup -!TP_WAVELET_FINEST;Finest -!TP_WAVELET_HIGHLIGHT;Highlight luminance range -!TP_WAVELET_HS1;Whole luminance range !TP_WAVELET_HUESKIN_TOOLTIP;The bottom points set the beginning of the transition zone, and the upper points the end of it, where the effect is at its maximum.\n\nIf you need to move the area significantly, or if there are artifacts, then the white balance is incorrect. !TP_WAVELET_HUESKY_TOOLTIP;The bottom points set the beginning of the transition zone, and the upper points the end of it, where the effect is at its maximum.\n\nIf you need to move the area significantly, or if there are artifacts, then the white balance is incorrect. !TP_WAVELET_ITER;Delta balance levels !TP_WAVELET_ITER_TOOLTIP;Left: increase low levels and reduce high levels,\nRight: reduce low levels and increase high levels. !TP_WAVELET_LABEL;Wavelet Levels !TP_WAVELET_LARGEST;Coarsest -!TP_WAVELET_LEVCH;Chroma !TP_WAVELET_LEVDIR_ALL;All levels in all directions !TP_WAVELET_LEVDIR_INF;Below or equal the level !TP_WAVELET_LEVDIR_ONE;One level @@ -2286,9 +2298,6 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !TP_WAVELET_LEVELS;Wavelet levels !TP_WAVELET_LEVELS_TOOLTIP;Choose the number of detail levels the image is to be decomposed into. More levels require more RAM and require a longer processing time. !TP_WAVELET_LEVLABEL;Preview maximum possible levels = %1 -!TP_WAVELET_LINKEDG;Link with Edge Sharpness' Strength -!TP_WAVELET_LOWLIGHT;Shadow luminance range -!TP_WAVELET_MEDGREINF;First level !TP_WAVELET_MEDILEV_TOOLTIP;When you enable Edge Detection, it is recommanded:\n- to disabled low contrast levels to avoid artifacts,\n- to use high values of gradient sensitivity.\n\nYou can modulate the strength with 'refine' from Denoise and Refine. !TP_WAVELET_NOISE;Denoise and Refine !TP_WAVELET_NPTYPE_TOOLTIP;This algorithm uses the proximity of a pixel and eight of its neighbors. If less difference, edges are reinforced. @@ -2296,14 +2305,10 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !TP_WAVELET_OPACITYW;Contrast balance d/v-h curve !TP_WAVELET_OPACITYWL;Final local contrast !TP_WAVELET_OPACITYWL_TOOLTIP;Modify the final local contrast at the end of the wavelet treatment.\n\nThe left side represents the smallest local contrast, progressing to the largest local contrast on the right. -!TP_WAVELET_PASTEL;Pastel chroma -!TP_WAVELET_RESCHRO;Chroma !TP_WAVELET_RESID;Residual Image -!TP_WAVELET_SAT;Saturated chroma !TP_WAVELET_SETTINGS;Wavelet Settings !TP_WAVELET_SKIN;Skin targetting/protection !TP_WAVELET_SKIN_TOOLTIP;At -100 skin-tones are targetted.\nAt 0 all tones are treated equally.\nAt +100 skin-tones are protected while all other tones are affected. -!TP_WAVELET_SKY;Sky targetting/protection !TP_WAVELET_SKY_TOOLTIP;At -100 sky-tones are targetted.\nAt 0 all tones are treated equally.\nAt +100 sky-tones are protected while all other tones are affected. !TP_WAVELET_THRESHOLD2_TOOLTIP;Only levels between 9 and 9 minus the value will be affected by the shadow luminance range. Other levels will be fully treated. The highest level possible is limited by the highlight level value (9 minus highlight level value). !TP_WAVELET_THRESHOLD_TOOLTIP;Only levels beyond the chosen value will be affected by the highlight luminance range. Other levels will be fully treated. The chosen value here limits the highest possible value of the shadow levels. @@ -2312,8 +2317,5 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !TP_WAVELET_TILESIZE;Tiling method !TP_WAVELET_TILESLIT;Little tiles !TP_WAVELET_TILES_TOOLTIP;Processing the full image leads to better quality and is the recommended option, while using tiles is a fall-back solution for users with little RAM. Refer to RawPedia for memory requirements. -!TP_WAVELET_TMSTRENGTH;Compression strength !TP_WAVELET_TMSTRENGTH_TOOLTIP;Control the strength of tone mapping or contrast compression of the residual image. When the value is different from 0, the Strength and Gamma sliders of the Tone Mapping tool in the Exposure tab will become grayed out. -!TP_WAVELET_TON;Toning -!TP_WBALANCE_TEMPBIAS;AWB temperature bias !TP_WBALANCE_TEMPBIAS_TOOLTIP;Allows to alter the computation of the "auto white balance"\nby biasing it towards warmer or cooler temperatures. The bias\nis expressed as a percentage of the computed temperature,\nso that the result is given by "computedTemp + computedTemp * bias". diff --git a/rtengine/CA_correct_RT.cc b/rtengine/CA_correct_RT.cc index f4d082199..fa9788af0 100644 --- a/rtengine/CA_correct_RT.cc +++ b/rtengine/CA_correct_RT.cc @@ -790,12 +790,12 @@ float* RawImageSource::CA_correct_RT( for (int m = 0; m < polyord; m++) { double powHblock = powHblockInit; for (int n = 0; n < polyord; n++) { - polymat[c][dir][numpar * (polyord * i + j) + (polyord * m + n)] += powVblock * powHblock * blockwt[vblock * hblsz + hblock]; + polymat[c][dir][numpar * (polyord * i + j) + (polyord * m + n)] += powVblock * powHblock * static_cast(blockwt[vblock * hblsz + hblock]); powHblock *= hblock; } powVblock *= vblock; } - shiftmat[c][dir][(polyord * i + j)] += powVblockInit * powHblockInit * bstemp[dir] * blockwt[vblock * hblsz + hblock]; + shiftmat[c][dir][(polyord * i + j)] += powVblockInit * powHblockInit * static_cast(bstemp[dir]) * static_cast(blockwt[vblock * hblsz + hblock]); powHblockInit *= hblock; } powVblockInit *= vblock; @@ -848,7 +848,7 @@ float* RawImageSource::CA_correct_RT( for (int top = -border; top < height; top += ts - border2) { for (int left = -border; left < width - (W & 1); left += ts - border2) { memset(bufferThr, 0, buffersizePassTwo); - float lblockshifts[2][2]; + double lblockshifts[2][2]; const int vblock = ((top + border) / (ts - border2)) + 1; const int hblock = ((left + border) / (ts - border2)) + 1; const int bottom = min(top + ts, height + border); @@ -1036,8 +1036,8 @@ float* RawImageSource::CA_correct_RT( } if (!autoCA) { - float hfrac = -((float)(hblock - 0.5) / (hblsz - 2) - 0.5); - float vfrac = -((float)(vblock - 0.5) / (vblsz - 2) - 0.5) * height / width; + double hfrac = -((hblock - 0.5) / (hblsz - 2) - 0.5); + double vfrac = -((vblock - 0.5) / (vblsz - 2) - 0.5) * height / width; lblockshifts[0][0] = 2 * vfrac * cared; lblockshifts[0][1] = 2 * hfrac * cared; lblockshifts[1][0] = 2 * vfrac * cablue; @@ -1058,7 +1058,7 @@ float* RawImageSource::CA_correct_RT( } powVblock *= vblock; } - constexpr float bslim = 3.99; //max allowed CA shift + constexpr double bslim = 3.99f; //max allowed CA shift lblockshifts[0][0] = LIM(lblockshifts[0][0], -bslim, bslim); lblockshifts[0][1] = LIM(lblockshifts[0][1], -bslim, bslim); lblockshifts[1][0] = LIM(lblockshifts[1][0], -bslim, bslim); @@ -1070,14 +1070,14 @@ float* RawImageSource::CA_correct_RT( //some parameters for the bilinear interpolation shiftvfloor[c] = floor((float)lblockshifts[c>>1][0]); shiftvceil[c] = ceil((float)lblockshifts[c>>1][0]); - if (lblockshifts[c>>1][0] < 0.f) { + if (lblockshifts[c>>1][0] < 0.0) { std::swap(shiftvfloor[c], shiftvceil[c]); } shiftvfrac[c] = fabs(lblockshifts[c>>1][0] - shiftvfloor[c]); shifthfloor[c] = floor((float)lblockshifts[c>>1][1]); shifthceil[c] = ceil((float)lblockshifts[c>>1][1]); - if (lblockshifts[c>>1][1] < 0.f) { + if (lblockshifts[c>>1][1] < 0.0) { std::swap(shifthfloor[c], shifthceil[c]); } shifthfrac[c] = fabs(lblockshifts[c>>1][1] - shifthfloor[c]); diff --git a/rtengine/CMakeLists.txt b/rtengine/CMakeLists.txt index 26603571d..5f59da371 100644 --- a/rtengine/CMakeLists.txt +++ b/rtengine/CMakeLists.txt @@ -99,6 +99,7 @@ set(RTENGINESOURCEFILES ipretinex.cc ipshadowshighlights.cc ipsharpen.cc + ipsharpenedges.cc ipsoftlight.cc iptransform.cc ipvibrance.cc @@ -110,6 +111,7 @@ set(RTENGINESOURCEFILES lj92.c lmmse_demosaic.cc loadinitial.cc + munselllch.cc myfile.cc panasonic_decoders.cc pdaflinesfilter.cc diff --git a/rtengine/EdgePreservingDecomposition.cc b/rtengine/EdgePreservingDecomposition.cc index 700181e1d..04459e88a 100644 --- a/rtengine/EdgePreservingDecomposition.cc +++ b/rtengine/EdgePreservingDecomposition.cc @@ -55,7 +55,7 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl #endif for(int ii = 0; ii < n; ii++) { - rs += r[ii] * s[ii]; + rs += static_cast(r[ii]) * static_cast(s[ii]); } //Search direction d. @@ -84,15 +84,15 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl #endif for(int ii = 0; ii < n; ii++) { - ab += d[ii] * ax[ii]; + ab += static_cast(d[ii]) * static_cast(ax[ii]); } - if(ab == 0.0f) { + if(ab == 0.0) { break; //So unlikely. It means perfectly converged or singular, stop either way. } ab = rs / ab; - + float abf = ab; //Update x and r with this step size. double rms = 0.0; // use double precision for large summations #ifdef _OPENMP @@ -100,15 +100,15 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl #endif for(int ii = 0; ii < n; ii++) { - x[ii] += ab * d[ii]; - r[ii] -= ab * ax[ii]; //"Fast recursive formula", use explicit r = b - Ax occasionally? - rms += r[ii] * r[ii]; + x[ii] += abf * d[ii]; + r[ii] -= abf * ax[ii]; //"Fast recursive formula", use explicit r = b - Ax occasionally? + rms += rtengine::SQR(r[ii]); } rms = sqrtf(rms / n); //Quit? This probably isn't the best stopping condition, but ok. - if(rms < RMSResidual) { + if(rms < static_cast(RMSResidual)) { break; } @@ -129,20 +129,20 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl #endif for(int ii = 0; ii < n; ii++) { - rs += r[ii] * s[ii]; + rs += static_cast(r[ii]) * static_cast(s[ii]); } } ab = rs / ab; - + abf = ab; //Update search direction p. #ifdef _OPENMP #pragma omp parallel for #endif for(int ii = 0; ii < n; ii++) { - d[ii] = s[ii] + ab * d[ii]; + d[ii] = s[ii] + abf * d[ii]; } diff --git a/rtengine/FTblockDN.cc b/rtengine/FTblockDN.cc index 121c8189d..9120fe0ad 100644 --- a/rtengine/FTblockDN.cc +++ b/rtengine/FTblockDN.cc @@ -56,7 +56,6 @@ #define TS 64 // Tile size #define offset 25 // shift between tiles -#define fTS ((TS/2+1)) // second dimension of Fourier tiles #define blkrad 1 // radius of block averaging #define epsilon 0.001f/(TS*TS) //tolerance @@ -548,7 +547,7 @@ BENCHFUN const bool denoiseMethodRgb = (dnparams.dmethod == "RGB"); // init luma noisevarL const float noiseluma = static_cast(dnparams.luma); - const float noisevarL = (useNoiseLCurve && (denoiseMethodRgb || !isRAW)) ? static_cast(SQR(((noiseluma + 1.0) / 125.0) * (10. + (noiseluma + 1.0) / 25.0))) : static_cast(SQR((noiseluma / 125.0) * (1.0 + noiseluma / 25.0))); + const float noisevarL = (useNoiseLCurve && (denoiseMethodRgb || !isRAW)) ? SQR(((noiseluma + 1.f) / 125.f) * (10.f + (noiseluma + 1.f) / 25.f)) : SQR((noiseluma / 125.f) * (1.f + noiseluma / 25.f)); const bool denoiseLuminance = (noisevarL > 0.00001f); //printf("NL=%f \n",noisevarL); @@ -635,20 +634,20 @@ BENCHFUN if (dnparams.luma != 0 || dnparams.chroma != 0 || dnparams.methodmed == "Lab" || dnparams.methodmed == "Lonly") { // gamma transform for input data - float gam = dnparams.gamma; - float gamthresh = 0.001f; + double gam = dnparams.gamma; + constexpr double gamthresh = 0.001; if (!isRAW) {//reduce gamma under 1 for Lab mode ==> TIF and JPG - if (gam < 1.9f) { - gam = 1.f - (1.9f - gam) / 3.f; //minimum gamma 0.7 - } else if (gam >= 1.9f && gam <= 3.f) { - gam = (1.4f / 1.1f) * gam - 1.41818f; + if (gam < 1.9) { + gam = 1.0 - (1.9 - gam) / 3.0; //minimum gamma 0.7 + } else if (gam >= 1.9 && gam <= 3.0) { + gam = (1.4 / 1.1) * gam - 1.41818; } } LUTf gamcurve(65536, LUT_CLIP_BELOW); - float gamslope = exp(log(static_cast(gamthresh)) / gam) / gamthresh; + const double gamslope = exp(log(gamthresh) / gam) / gamthresh; if (denoiseMethodRgb) { Color::gammaf2lut(gamcurve, gam, gamthresh, gamslope, 65535.f, 32768.f); @@ -657,9 +656,9 @@ BENCHFUN } // inverse gamma transform for output data - float igam = 1.f / gam; - float igamthresh = gamthresh * gamslope; - float igamslope = 1.f / gamslope; + const float igam = 1.0 / gam; + const float igamthresh = gamthresh * gamslope; + const float igamslope = 1.0 / gamslope; LUTf igamcurve(65536, LUT_CLIP_BELOW); @@ -669,9 +668,9 @@ BENCHFUN Color::gammanf2lut(igamcurve, igam, 32768.f, 65535.f); } - const float gain = pow(2.0f, float(expcomp)); - float params_Ldetail = min(float(dnparams.Ldetail), 99.9f); // max out to avoid div by zero when using noisevar_Ldetail as divisor - float noisevar_Ldetail = SQR(static_cast(SQR(100. - params_Ldetail) + 50.*(100. - params_Ldetail)) * TS * 0.5f); + const float gain = std::pow(2.0, expcomp); + const double params_Ldetail = std::min(dnparams.Ldetail, 99.9); // max out to avoid div by zero when using noisevar_Ldetail as divisor + const float noisevar_Ldetail = SQR(SQR(100. - params_Ldetail) + 50.0 * (100.0 - params_Ldetail) * TS * 0.5); array2D tilemask_in(TS, TS); array2D tilemask_out(TS, TS); @@ -681,13 +680,13 @@ BENCHFUN for (int i = 0; i < TS; ++i) { float i1 = abs((i > TS / 2 ? i - TS + 1 : i)); - float vmask = (i1 < border ? SQR(sin((rtengine::RT_PI * i1) / (2 * border))) : 1.0f); - float vmask2 = (i1 < 2 * border ? SQR(sin((rtengine::RT_PI * i1) / (2 * border))) : 1.0f); + float vmask = (i1 < border ? SQR(sin((rtengine::RT_PI_F * i1) / (2 * border))) : 1.f); + float vmask2 = (i1 < 2 * border ? SQR(sin((rtengine::RT_PI_F * i1) / (2 * border))) : 1.f); for (int j = 0; j < TS; ++j) { float j1 = abs((j > TS / 2 ? j - TS + 1 : j)); - tilemask_in[i][j] = (vmask * (j1 < border ? SQR(sin((rtengine::RT_PI * j1) / (2 * border))) : 1.0f)) + epsilon; - tilemask_out[i][j] = (vmask2 * (j1 < 2 * border ? SQR(sin((rtengine::RT_PI * j1) / (2 * border))) : 1.0f)) + epsilon; + tilemask_in[i][j] = (vmask * (j1 < border ? SQR(sin((rtengine::RT_PI_F * j1) / (2 * border))) : 1.0f)) + epsilon; + tilemask_out[i][j] = (vmask2 * (j1 < 2 * border ? SQR(sin((rtengine::RT_PI_F * j1) / (2 * border))) : 1.0f)) + epsilon; } } @@ -883,19 +882,19 @@ BENCHFUN int height = tilebottom - tiletop; int width2 = (width + 1) / 2; float realred, realblue; - float interm_med = static_cast(dnparams.chroma) / 10.0; + float interm_med = dnparams.chroma / 10.0; float intermred, intermblue; if (dnparams.redchro > 0.) { - intermred = (dnparams.redchro / 10.); + intermred = dnparams.redchro / 10.0; } else { - intermred = static_cast(dnparams.redchro) / 7.0; //increase slower than linear for more sensit + intermred = dnparams.redchro / 7.0; //increase slower than linear for more sensit } if (dnparams.bluechro > 0.) { - intermblue = (dnparams.bluechro / 10.); + intermblue = dnparams.bluechro / 10.0; } else { - intermblue = static_cast(dnparams.bluechro) / 7.0; //increase slower than linear for more sensit + intermblue = dnparams.bluechro / 7.0; //increase slower than linear for more sensit } if (ponder && kall == 2) { @@ -1096,7 +1095,7 @@ BENCHFUN //binary 1 or 0 for each level, eg subsampling = 0 means no subsampling, 1 means subsample //the first level only, 7 means subsample the first three levels, etc. //actual implementation only works with subsampling set to 1 - float interm_medT = static_cast(dnparams.chroma) / 10.0; + float interm_medT = dnparams.chroma / 10.0; bool execwavelet = true; if (!denoiseLuminance && interm_medT < 0.05f && dnparams.median && (dnparams.methodmed == "Lab" || dnparams.methodmed == "Lonly")) { @@ -2121,7 +2120,7 @@ float ImProcFunctions::Mad(const float * DataList, const int datalen) int count_ = count - histo[median - 1]; // interpolate - return (((median - 1) + (datalen / 2 - count_) / (static_cast(count - count_))) / 0.6745); + return (((median - 1) + (datalen / 2 - count_) / (static_cast(count - count_))) / 0.6745f); } float ImProcFunctions::MadRgb(const float * DataList, const int datalen) @@ -2155,7 +2154,7 @@ float ImProcFunctions::MadRgb(const float * DataList, const int datalen) // interpolate delete[] histo; - return (((median - 1) + (datalen / 2 - count_) / (static_cast(count - count_))) / 0.6745); + return (((median - 1) + (datalen / 2 - count_) / (static_cast(count - count_))) / 0.6745f); } @@ -2908,7 +2907,7 @@ void ImProcFunctions::RGB_denoise_infoGamCurve(const procparams::DirPyrDenoisePa bool denoiseMethodRgb = (dnparams.dmethod == "RGB"); if (denoiseMethodRgb) { - gamslope = exp(log(static_cast(gamthresh)) / gam) / gamthresh; + gamslope = exp(log(static_cast(gamthresh)) / static_cast(gam)) / static_cast(gamthresh); Color::gammaf2lut(gamcurve, gam, gamthresh, gamslope, 65535.f, 32768.f); } else { Color::gammanf2lut(gamcurve, gam, 65535.f, 32768.f); @@ -3189,19 +3188,19 @@ void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat * provicalc, } float realred, realblue; - float interm_med = static_cast(dnparams.chroma) / 10.0; + float interm_med = dnparams.chroma / 10.0; float intermred, intermblue; if (dnparams.redchro > 0.) { - intermred = (dnparams.redchro / 10.); + intermred = dnparams.redchro / 10.0; } else { - intermred = static_cast(dnparams.redchro) / 7.0; //increase slower than linear for more sensit + intermred = dnparams.redchro / 7.0; //increase slower than linear for more sensit } if (dnparams.bluechro > 0.) { - intermblue = (dnparams.bluechro / 10.); + intermblue = dnparams.bluechro / 10.0; } else { - intermblue = static_cast(dnparams.bluechro) / 7.0; //increase slower than linear for more sensit + intermblue = dnparams.bluechro / 7.0; //increase slower than linear for more sensit } realred = interm_med + intermred; diff --git a/rtengine/PF_correct_RT.cc b/rtengine/PF_correct_RT.cc index 9a95b8e2f..15b7b21ee 100644 --- a/rtengine/PF_correct_RT.cc +++ b/rtengine/PF_correct_RT.cc @@ -103,7 +103,7 @@ void ImProcFunctions::PF_correct_RT(LabImage * lab, double radius, int thresh) // no precalculated values without SSE => calculate const float HH = xatan2f(lab->b[i][j], lab->a[i][j]); #endif - float chparam = chCurve->getVal((Color::huelab_to_huehsv2(HH))) - 0.5f; // get C=f(H) + float chparam = chCurve->getVal((Color::huelab_to_huehsv2(HH))) - 0.5; // get C=f(H) if (chparam < 0.f) { chparam *= 2.f; // increased action if chparam < 0 @@ -113,25 +113,25 @@ void ImProcFunctions::PF_correct_RT(LabImage * lab, double radius, int thresh) } const float chroma = chromaChfactor * (SQR(lab->a[i][j] - tmpa[i][j]) + SQR(lab->b[i][j] - tmpb[i][j])); // modulate chroma function hue - chromave += chroma; + chromave += static_cast(chroma); fringe[i * width + j] = chroma; } } } chromave /= height * width; - if (chromave > 0.0) { // now as chromave is calculated, we postprocess fringe to reduce the number of divisions in future + const float chromavef = chromave; #ifdef _OPENMP #pragma omp parallel for simd #endif for (int j = 0; j < width * height; j++) { - fringe[j] = 1.f / (fringe[j] + chromave); + fringe[j] = 1.f / (fringe[j] + chromavef); } - const float threshfactor = 1.f / (SQR(thresh / 33.f) * chromave * 5.0f + chromave); + const float threshfactor = 1.f / (SQR(thresh / 33.f) * chromavef * 5.0f + chromavef); const int halfwin = std::ceil(2 * radius) + 1; // Issue 1674: @@ -297,7 +297,7 @@ void ImProcFunctions::PF_correct_RTcam(CieImage * ncie, double radius, int thres // no precalculated values without SSE => calculate const float HH = xatan2f(srbb[i][j], sraa[i][j]); #endif - float chparam = chCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f; //get C=f(H) + float chparam = chCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5; //get C=f(H) if (chparam < 0.f) { chparam *= 2.f; // increase action if chparam < 0 @@ -307,7 +307,7 @@ void ImProcFunctions::PF_correct_RTcam(CieImage * ncie, double radius, int thres } const float chroma = chromaChfactor * (SQR(sraa[i][j] - tmaa[i][j]) + SQR(srbb[i][j] - tmbb[i][j])); //modulate chroma function hue - chromave += chroma; + chromave += static_cast(chroma); fringe[i * width + j] = chroma; } } @@ -317,15 +317,16 @@ void ImProcFunctions::PF_correct_RTcam(CieImage * ncie, double radius, int thres if (chromave > 0.0) { // now as chromave is calculated, we postprocess fringe to reduce the number of divisions in future + const float chromavef = chromave; #ifdef _OPENMP #pragma omp parallel for simd #endif for (int j = 0; j < width * height; j++) { - fringe[j] = 1.f / (fringe[j] + chromave); + fringe[j] = 1.f / (fringe[j] + chromavef); } - const float threshfactor = 1.f / (SQR(thresh / 33.f) * chromave * 5.0f + chromave); + const float threshfactor = 1.f / (SQR(thresh / 33.f) * chromavef * 5.0f + chromavef); const int halfwin = std::ceil(2 * radius) + 1; // Issue 1674: @@ -695,7 +696,7 @@ void ImProcFunctions::Badpixelscam(CieImage * ncie, double radius, int thresh, i for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { const float chroma = SQR(sraa[i][j] - tmaa[i][j]) + SQR(srbb[i][j] - tmbb[i][j]); - chrommed += chroma; + chrommed += static_cast(chroma); badpix[i * width + j] = chroma; } } @@ -703,15 +704,16 @@ void ImProcFunctions::Badpixelscam(CieImage * ncie, double radius, int thresh, i chrommed /= height * width; if (chrommed > 0.0) { + const float chrommedf = chrommed; // now as chrommed is calculated, we postprocess badpix to reduce the number of divisions in future - const float threshfactor = 1.f / ((thresh * chrommed) / 33.f + chrommed); + const float threshfactor = 1.f / ((thresh * chrommedf) / 33.f + chrommedf); const int halfwin = std::ceil(2 * radius) + 1; #ifdef _OPENMP #pragma omp parallel #endif { #ifdef __SSE2__ - const vfloat chrommedv = F2V(chrommed); + const vfloat chrommedv = F2V(chrommedf); const vfloat onev = F2V(1.f); #endif #ifdef _OPENMP @@ -726,7 +728,7 @@ void ImProcFunctions::Badpixelscam(CieImage * ncie, double radius, int thresh, i } #endif for (; j < width; j++) { - badpix[i * width + j] = 1.f / (badpix[i * width + j] + chrommed); + badpix[i * width + j] = 1.f / (badpix[i * width + j] + chrommedf); } } @@ -1040,7 +1042,7 @@ void ImProcFunctions::BadpixelsLab(LabImage * lab, double radius, int thresh, fl for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { const float chroma = SQR(lab->a[i][j] - tmaa[i][j]) + SQR(lab->b[i][j] - tmbb[i][j]); - chrommed += chroma; + chrommed += static_cast(chroma); badpix[i * width + j] = chroma; } } @@ -1049,13 +1051,13 @@ void ImProcFunctions::BadpixelsLab(LabImage * lab, double radius, int thresh, fl if (chrommed > 0.0) { // now as chrommed is calculated, we postprocess badpix to reduce the number of divisions in future - + const float chrommedf = chrommed; #ifdef _OPENMP #pragma omp parallel #endif { #ifdef __SSE2__ - const vfloat chrommedv = F2V(chrommed); + const vfloat chrommedv = F2V(chrommedf); const vfloat onev = F2V(1.f); #endif #ifdef _OPENMP @@ -1070,12 +1072,12 @@ void ImProcFunctions::BadpixelsLab(LabImage * lab, double radius, int thresh, fl } #endif for (; j < width; j++) { - badpix[i * width + j] = 1.f / (badpix[i * width + j] + chrommed); + badpix[i * width + j] = 1.f / (badpix[i * width + j] + chrommedf); } } } - const float threshfactor = 1.f / ((thresh * chrommed) / 33.f + chrommed); + const float threshfactor = 1.f / ((thresh * chrommedf) / 33.f + chrommedf); chrom *= 327.68f; chrom *= chrom; diff --git a/rtengine/ahd_demosaic_RT.cc b/rtengine/ahd_demosaic_RT.cc index 064dfd6e1..536726925 100644 --- a/rtengine/ahd_demosaic_RT.cc +++ b/rtengine/ahd_demosaic_RT.cc @@ -52,13 +52,13 @@ void RawImageSource::ahd_demosaic() int width = W, height = H; - constexpr double xyz_rgb[3][3] = { /* XYZ from RGB */ - { 0.412453, 0.357580, 0.180423 }, - { 0.212671, 0.715160, 0.072169 }, - { 0.019334, 0.119193, 0.950227 } + constexpr float xyz_rgb[3][3] = { /* XYZ from RGB */ + { 0.412453f, 0.357580f, 0.180423f }, + { 0.212671f, 0.715160f, 0.072169f }, + { 0.019334f, 0.119193f, 0.950227f } }; - constexpr float d65_white[3] = { 0.950456, 1, 1.088754 }; + constexpr float d65_white[3] = { 0.950456f, 1.f, 1.088754f }; double progress = 0.0; @@ -76,7 +76,7 @@ void RawImageSource::ahd_demosaic() for (unsigned int j = 0; j < 3; j++) { xyz_cam[i][j] = 0; for (int k = 0; k < 3; k++) { - xyz_cam[i][j] += xyz_rgb[i][k] * imatrices.rgb_cam[k][j] / d65_white[i]; + xyz_cam[i][j] += xyz_rgb[i][k] * static_cast(imatrices.rgb_cam[k][j]) / d65_white[i]; } } } diff --git a/rtengine/badpixels.cc b/rtengine/badpixels.cc index 0ae63a618..97294bdf7 100644 --- a/rtengine/badpixels.cc +++ b/rtengine/badpixels.cc @@ -477,7 +477,7 @@ int RawImageSource::interpolateBadPixelsXtrans(const PixelsMap &bitmapBads) int RawImageSource::findHotDeadPixels(PixelsMap &bpMap, const float thresh, const bool findHotPixels, const bool findDeadPixels) const { BENCHFUN - const float varthresh = (20.0 * (thresh / 100.0) + 1.0) / 24.f; + const float varthresh = (20.f * (thresh / 100.f) + 1.f) / 24.f; // counter for dead or hot pixels int counter = 0; diff --git a/rtengine/camconst.cc b/rtengine/camconst.cc index d136d6a21..36aa96030 100644 --- a/rtengine/camconst.cc +++ b/rtengine/camconst.cc @@ -553,7 +553,7 @@ CameraConst::get_Levels(struct camera_const_levels & lvl, int bw, int iso, float float av = (avh - 1) + (float)k / 3; float aperture = sqrtf(powf(2, av)); - if (fnumber > aperture * 0.97 && fnumber < aperture / 0.97) { + if (fnumber > aperture * 0.97f && fnumber < aperture / 0.97f) { fnumber = fn_tab[avh][k]; it = mApertureScaling.find(fnumber); avh = 7; @@ -579,7 +579,7 @@ CameraConst::get_Levels(struct camera_const_levels & lvl, int bw, int iso, float scaling = it->second; } - if (scaling > 1.0) { + if (scaling > 1.f) { for (int i = 0; i < 4; i++) { lvl.levels[i] *= scaling; @@ -638,7 +638,7 @@ CameraConst::update_globalGreenEquilibration(bool other) } bool -CameraConstantsStore::parse_camera_constants_file(Glib::ustring filename_) +CameraConstantsStore::parse_camera_constants_file(const Glib::ustring& filename_) { // read the file into a single long string const char *filename = filename_.c_str(); @@ -809,7 +809,7 @@ CameraConstantsStore::~CameraConstantsStore() } } -void CameraConstantsStore::init(Glib::ustring baseDir, Glib::ustring userSettingsDir) +void CameraConstantsStore::init(const Glib::ustring& baseDir, const Glib::ustring& userSettingsDir) { parse_camera_constants_file(Glib::build_filename(baseDir, "camconst.json")); diff --git a/rtengine/camconst.h b/rtengine/camconst.h index 1096e1767..3af05ab01 100644 --- a/rtengine/camconst.h +++ b/rtengine/camconst.h @@ -3,10 +3,17 @@ */ #pragma once -#include #include +#include #include +namespace Glib +{ + +class ustring; + +} + namespace rtengine { @@ -14,7 +21,7 @@ struct camera_const_levels { int levels[4]; }; -class CameraConst +class CameraConst final { private: std::string make_model; @@ -56,17 +63,17 @@ public: void update_globalGreenEquilibration(bool other); }; -class CameraConstantsStore +class CameraConstantsStore final { private: std::map mCameraConstants; CameraConstantsStore(); - bool parse_camera_constants_file(Glib::ustring filename); + bool parse_camera_constants_file(const Glib::ustring& filename); public: ~CameraConstantsStore(); - void init(Glib::ustring baseDir, Glib::ustring userSettingsDir); + void init(const Glib::ustring& baseDir, const Glib::ustring& userSettingsDir); static CameraConstantsStore *getInstance(void); CameraConst *get(const char make[], const char model[]); }; diff --git a/rtengine/camconst.json b/rtengine/camconst.json index ab42f3d19..f58167478 100644 --- a/rtengine/camconst.json +++ b/rtengine/camconst.json @@ -1221,7 +1221,7 @@ Camera constants: { // Quality A, changes for raw crop which is wrong (larger) in dcraw "make_model": "Canon PowerShot S120", - "dcraw_matrix": [ 6961,-1685,-695,-4625,12945,1836,-1114,2152,5518 ], + "dcraw_matrix": [ 6961, -1685, -695, -4625, 12945, 1836, -1114, 2152, 5518 ], // ColorMatrix2 using illuminant D65 from Adobe DNG Converter 12.2 "raw_crop": [ 120, 30, 4024, 3030 ], "masked_areas": [ 32, 2, 3028, 80 ], "ranges": { "white": 4050 } diff --git a/rtengine/capturesharpening.cc b/rtengine/capturesharpening.cc index 9b60694f2..4dcdd0734 100644 --- a/rtengine/capturesharpening.cc +++ b/rtengine/capturesharpening.cc @@ -761,13 +761,13 @@ bool checkForStop(float** tmpIThr, float** iterCheck, int fullTileSize, int bord return false; } -void CaptureDeconvSharpening (float** luminance, const float* const * oldLuminance, const float * const * blend, int W, int H, double sigma, double sigmaCornerOffset, int iterations, bool checkIterStop, rtengine::ProgressListener* plistener, double startVal, double endVal) +void CaptureDeconvSharpening (float** luminance, const float* const * oldLuminance, const float * const * blend, int W, int H, float sigma, float sigmaCornerOffset, int iterations, bool checkIterStop, rtengine::ProgressListener* plistener, double startVal, double endVal) { BENCHFUN - const bool is9x9 = (sigma <= 1.50 && sigmaCornerOffset == 0.0); - const bool is7x7 = (sigma <= 1.15 && sigmaCornerOffset == 0.0); - const bool is5x5 = (sigma <= 0.84 && sigmaCornerOffset == 0.0); - const bool is3x3 = (sigma < 0.6 && sigmaCornerOffset == 0.0); + const bool is9x9 = (sigma <= 1.5f && sigmaCornerOffset == 0.f); + const bool is7x7 = (sigma <= 1.15f && sigmaCornerOffset == 0.f); + const bool is5x5 = (sigma <= 0.84f && sigmaCornerOffset == 0.f); + const bool is3x3 = (sigma < 0.6f && sigmaCornerOffset == 0.f); float kernel13[13][13]; float kernel9[9][9]; float kernel7[7][7]; @@ -906,11 +906,11 @@ BENCHFUN } } } else { - if (sigmaCornerOffset != 0.0) { + if (sigmaCornerOffset != 0.f) { const float distance = sqrt(rtengine::SQR(i + tileSize / 2 - H / 2) + rtengine::SQR(j + tileSize / 2 - W / 2)); const float sigmaTile = static_cast(sigma) + distanceFactor * distance; if (sigmaTile >= 0.4f) { - if (sigmaTile > 1.50) { // have to use 13x13 kernel + if (sigmaTile > 1.5f) { // have to use 13x13 kernel float lkernel13[13][13]; compute13x13kernel(static_cast(sigma) + distanceFactor * distance, lkernel13); for (int k = 0; k < iterations; ++k) { @@ -921,7 +921,7 @@ BENCHFUN break; } } - } else if (sigmaTile > 1.15) { // have to use 9x9 kernel + } else if (sigmaTile > 1.15f) { // have to use 9x9 kernel float lkernel9[9][9]; compute9x9kernel(static_cast(sigma) + distanceFactor * distance, lkernel9); for (int k = 0; k < iterations; ++k) { @@ -932,7 +932,7 @@ BENCHFUN break; } } - } else if (sigmaTile > 0.84) { // have to use 7x7 kernel + } else if (sigmaTile > 0.84f) { // have to use 7x7 kernel float lkernel7[7][7]; compute7x7kernel(static_cast(sigma) + distanceFactor * distance, lkernel7); for (int k = 0; k < iterations; ++k) { @@ -1021,7 +1021,7 @@ BENCHFUN { 0.019334, 0.119193, 0.950227 } }; - float contrast = conrastThreshold / 100.f; + float contrast = conrastThreshold / 100.0; const float clipVal = (ri->get_white(1) - ri->get_cblack(1)) * scale_mul[1]; diff --git a/rtengine/ciecam02.cc b/rtengine/ciecam02.cc index c7e49b2ed..208ed4366 100644 --- a/rtengine/ciecam02.cc +++ b/rtengine/ciecam02.cc @@ -28,7 +28,7 @@ #endif #undef CLIPD -#define CLIPD(a) ((a)>0.0?((a)<1.0?(a):1.0):0.0) +#define CLIPD(a) ((a)>0.f?((a)<1.f?(a):1.f):0.f) #define MAXR(a,b) ((a) > (b) ? (a) : (b)) namespace rtengine @@ -408,7 +408,7 @@ void Ciecam02::initcam1float (float yb, float pilotd, float f, float la, float x { n = yb / yw; - if (pilotd == 2.0) { + if (pilotd == 2.f) { d = d_factorfloat ( f, la ); } else { d = pilotd; @@ -434,7 +434,7 @@ void Ciecam02::initcam2float (float yb, float pilotd, float f, float la, float x { n = yb / yw; - if (pilotd == 2.0) { + if (pilotd == 2.f) { d = d_factorfloat ( f, la ); } else { d = pilotd; @@ -492,7 +492,7 @@ void Ciecam02::xyz2jchqms_ciecam02float ( float &J, float &C, float &h, float &Q myh = xatan2f ( cb, ca ); if ( myh < 0.0f ) { - myh += (2.f * rtengine::RT_PI); + myh += (2.f * rtengine::RT_PI_F); } a = ((2.0f * rpa) + gpa + (0.05f * bpa) - 0.305f) * nbb; @@ -620,7 +620,7 @@ void Ciecam02::xyz2jch_ciecam02float ( float &J, float &C, float &h, float aw, f myh = xatan2f ( cb, ca ); if ( myh < 0.0f ) { - myh += (2.f * rtengine::RT_PI); + myh += (2.f * rtengine::RT_PI_F); } a = ((2.0f * rpa) + gpa + (0.05f * bpa) - 0.305f) * nbb; diff --git a/rtengine/cieimage.h b/rtengine/cieimage.h index fea675cd4..329c0ba74 100644 --- a/rtengine/cieimage.h +++ b/rtengine/cieimage.h @@ -23,7 +23,7 @@ namespace rtengine { -class CieImage : +class CieImage final : public NonCopyable { private: diff --git a/rtengine/color.cc b/rtengine/color.cc index 8d20fb9ba..e998b665c 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -16,6 +16,7 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ +#include #include "rtengine.h" #include "color.h" @@ -2997,1384 +2998,6 @@ void Color::LabGamutMunsell(float *labL, float *laba, float *labb, const int N, } -/* - * MunsellLch correction - * Copyright (c) 2012 Jacques Desmis - * - * Find the right LUT and calculate the correction - */ -void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, float &correction, int zone, float &lbe, bool &correctL) -{ - - int x = int(memChprov); - int y = int(chrom); - - //begin PB correction + sky - if(zone == 1) { - if(lum > 5.0) { - if(lum < 15.0) { - if( (hue >= (_15PB10[x] - 0.035)) && (hue < (_15PB10[x] + 0.052) && x <= 45)) { - if(y > 49) { - y = 49; - } - - correction = _15PB10[y] - _15PB10[x] ; - lbe = _15PB10[y]; - correctL = true; - } else if (( hue >= ( _3PB10[x] - 0.052)) && (hue < (_45PB10[x] + _3PB10[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _3PB10[y] - _3PB10[x]; - lbe = _3PB10[y]; - correctL = true; - } else if (( hue >= (_45PB10[x] + _3PB10[x]) / 2.0) && (hue < (_45PB10[x] + 0.052)) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _45PB10[y] - _45PB10[x] ; - lbe = _45PB10[y]; - correctL = true; - } else if (( hue >= (_6PB10[x] - 0.052) && (hue < (_6PB10[x] + _75PB10[x]) / 2.0))) { - correction = _6PB10[y] - _6PB10[x] ; - lbe = _6PB10[y]; - correctL = true; - } else if (( hue >= (_6PB10[x] + _75PB10[x]) / 2.0) && (hue < (_9PB10[x] + _75PB10[x]) / 2.0)) { - correction = _75PB10[y] - _75PB10[x] ; - lbe = _75PB10[y]; - correctL = true; - } else if (( hue >= (_9PB10[x] + _75PB10[x]) / 2.0) && (hue < (_9PB10[x] + _10PB10[x]) / 2.0)) { - correction = _9PB10[y] - _9PB10[x] ; - lbe = _9PB10[y]; - correctL = true; - } else if (( hue >= (_10PB10[x] + _9PB10[x]) / 2.0) && (hue < (_1P10[x] + _10PB10[x]) / 2.0)) { - correction = _10PB10[y] - _10PB10[x] ; - lbe = _10PB10[y]; - correctL = true; - } else if (( hue >= (_10PB10[x] + _1P10[x]) / 2.0) && (hue < (_1P10[x] + _4P10[x]) / 2.0)) { - correction = _1P10[y] - _1P10[x]; - lbe = _1P10[y]; - correctL = true; - } else if (( hue >= (_1P10[x] + _4P10[x]) / 2.0) && (hue < (0.035 + _4P10[x]) / 2.0)) { - correction = _4P10[y] - _4P10[x] ; - lbe = _4P10[y]; - correctL = true; - } - } else if (lum < 25.0) { - if( (hue >= (_15PB20[x] - 0.035)) && (hue < (_15PB20[x] + _3PB20[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _15PB20[y] - _15PB20[x] ; - lbe = _15PB20[y]; - correctL = true; - } else if (( hue >= (_15PB20[x] + _3PB20[x]) / 2.0) && (hue < (_45PB20[x] + _3PB20[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _3PB20[y] - _3PB20[x] ; - lbe = _3PB20[y]; - correctL = true; - } else if (( hue >= (_45PB20[x] + _3PB20[x]) / 2.0) && (hue < ( _45PB20[x] + 0.052)) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _45PB20[y] - _45PB20[x] ; - lbe = _45PB20[y]; - correctL = true; - } else if (( hue >= (_45PB20[x] + 0.052)) && (hue < (_6PB20[x] + _75PB20[x]) / 2.0)) { - correction = _6PB20[y] - _6PB20[x]; - lbe = _6PB20[y]; - correctL = true; - } else if (( hue >= (_6PB20[x] + _75PB20[x]) / 2.0) && (hue < (_9PB20[x] + _75PB20[x]) / 2.0)) { - correction = _75PB20[y] - _75PB20[x] ; - lbe = _75PB20[y]; - correctL = true; - } else if (( hue >= (_9PB20[x] + _75PB20[x]) / 2.0) && (hue < (_9PB20[x] + _10PB20[x]) / 2.0)) { - correction = _9PB20[y] - _9PB20[x] ; - lbe = _9PB20[y]; - correctL = true; - } else if (( hue >= (_10PB20[x] + _9PB20[x]) / 2.0) && (hue < (_1P20[x] + _10PB20[x]) / 2.0)) { - correction = _10PB20[y] - _10PB20[x] ; - lbe = _10PB20[y]; - correctL = true; - } else if (( hue >= (_10PB20[x] + _1P20[x]) / 2.0) && (hue < (_1P20[x] + _4P20[x]) / 2.0)) { - correction = _1P20[y] - _1P20[x] ; - lbe = _1P20[y]; - correctL = true; - } else if (( hue >= (_1P20[x] + _4P20[x]) / 2.0) && (hue < (0.035 + _4P20[x]) / 2.0)) { - correction = _4P20[y] - _4P20[x] ; - lbe = _4P20[y]; - correctL = true; - } - } else if (lum < 35.0) { - if( (hue >= (_15PB30[x] - 0.035)) && (hue < (_15PB30[x] + _3PB30[x]) / 2.0) && x <= 85 ) { - if(y > 89) { - y = 89; - } - - correction = _15PB30[y] - _15PB30[x] ; - lbe = _15PB30[y]; - correctL = true; - } else if (( hue >= (_15PB30[x] + _3PB30[x]) / 2.0) && (hue < (_45PB30[x] + _3PB30[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _3PB30[y] - _3PB30[x] ; - lbe = _3PB30[y]; - correctL = true; - } else if (( hue >= (_45PB30[x] + _3PB30[x]) / 2.0) && (hue < (_45PB30[x] + 0.052)) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _45PB30[y] - _45PB30[x] ; - lbe = _45PB30[y]; - correctL = true; - } else if (( hue >= ( _45PB30[x] + 0.052)) && (hue < (_6PB30[x] + _75PB30[x]) / 2.0)) { - correction = _6PB30[y] - _6PB30[x] ; - lbe = _6PB30[y]; - correctL = true; - } else if (( hue >= (_6PB30[x] + _75PB30[x]) / 2.0) && (hue < (_9PB30[x] + _75PB30[x]) / 2.0)) { - correction = _75PB30[y] - _75PB30[x] ; - lbe = _75PB30[y] ; - correctL = true; - } else if (( hue >= (_9PB30[x] + _75PB30[x]) / 2.0) && (hue < (_9PB30[x] + _10PB30[x]) / 2.0)) { - correction = _9PB30[y] - _9PB30[x] ; - lbe = _9PB30[y]; - correctL = true; - } else if (( hue >= (_10PB30[x] + _9PB30[x]) / 2.0) && (hue < (_1P30[x] + _10PB30[x]) / 2.0)) { - correction = _10PB30[y] - _10PB30[x] ; - lbe = _10PB30[y]; - correctL = true; - } else if (( hue >= (_10PB30[x] + _1P30[x]) / 2.0) && (hue < (_1P30[x] + _4P30[x]) / 2.0)) { - correction = _1P30[y] - _1P30[x] ; - lbe = _1P30[y]; - correctL = true; - } else if (( hue >= (_1P30[x] + _4P30[x]) / 2.0) && (hue < (0.035 + _4P30[x]) / 2.0)) { - correction = _4P30[y] - _4P30[x] ; - lbe = _4P30[y]; - correctL = true; - } - } else if (lum < 45.0) { - if( (hue <= (_05PB40[x] + _15PB40[x]) / 2.0) && (hue > (_05PB40[x] + _10B40[x]) / 2.0) && x < 75 ) { - if(y > 75) { - y = 75; - } - - correction = _05PB40[y] - _05PB40[x] ; - lbe = _05PB40[y]; - correctL = true; - } else if( (hue <= (_05PB40[x] + _10B40[x]) / 2.0) && (hue > (_10B40[x] + _9B40[x]) / 2.0) && x < 70 ) { - if(y > 70) { - y = 70; - } - - correction = _10B40[y] - _10B40[x] ; - lbe = _10B40[y]; - correctL = true; - } else if( (hue <= (_10B40[x] + _9B40[x]) / 2.0) && (hue > (_9B40[x] + _7B40[x]) / 2.0) && x < 70 ) { - if(y > 70) { - y = 70; - } - - correction = _9B40[y] - _9B40[x] ; - lbe = _9B40[y]; - correctL = true; - } else if( (hue <= (_9B40[x] + _7B40[x]) / 2.0) && (hue > (_5B40[x] + _7B40[x]) / 2.0) && x < 70 ) { - if(y > 70) { - y = 70; - } - - correction = _7B40[y] - _7B40[x] ; - lbe = _7B40[y]; - correctL = true; - } else if (( hue <= (_5B40[x] + _7B40[x]) / 2.0) && (hue > (_5B40[x] - 0.035)) && x < 70) { - if(y > 70) { - y = 70; // - } - - correction = _5B40[y] - _5B40[x] ; - lbe = _5B40[y]; - correctL = true; - } - - else if( (hue >= (_15PB40[x] - 0.035)) && (hue < (_15PB40[x] + _3PB40[x]) / 2.0) && x <= 85 ) { - if(y > 89) { - y = 89; - } - - correction = _15PB40[y] - _15PB40[x] ; - lbe = _15PB40[y]; - correctL = true; - } else if (( hue >= (_15PB40[x] + _3PB40[x]) / 2.0) && (hue < (_45PB40[x] + _3PB40[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _3PB40[y] - _3PB40[x] ; - lbe = _3PB40[y]; - correctL = true; - } else if (( hue >= (_45PB40[x] + _3PB40[x]) / 2.0) && (hue < (_45PB40[x] + 0.052)) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _45PB40[y] - _45PB40[x] ; - lbe = _45PB40[y] ; - correctL = true; - } else if (( hue >= (_45PB40[x] + 0.052)) && (hue < (_6PB40[x] + _75PB40[x]) / 2.0)) { - correction = _6PB40[y] - _6PB40[x] ; - lbe = _6PB40[y]; - correctL = true; - } else if (( hue >= (_6PB40[x] + _75PB40[x]) / 2.0) && (hue < (_9PB40[x] + _75PB40[x]) / 2.0)) { - correction = _75PB40[y] - _75PB40[x] ; - lbe = _75PB40[y]; - correctL = true; - } else if (( hue >= (_9PB40[x] + _75PB40[x]) / 2.0) && (hue < (_9PB40[x] + _10PB40[x]) / 2.0)) { - correction = _9PB40[y] - _9PB40[x] ; - lbe = _9PB40[y]; - correctL = true; - } else if (( hue >= (_10PB40[x] + _9PB40[x]) / 2.0) && (hue < (_1P40[x] + _10PB40[x]) / 2.0)) { - correction = _10PB40[y] - _10PB40[x] ; - lbe = _10PB40[y]; - correctL = true; - } else if (( hue >= (_10PB40[x] + _1P40[x]) / 2.0) && (hue < (_1P40[x] + _4P40[x]) / 2.0)) { - correction = _1P40[y] - _1P40[x] ; - lbe = _1P40[y]; - correctL = true; - } else if (( hue >= (_1P40[x] + _4P40[x]) / 2.0) && (hue < (0.035 + _4P40[x]) / 2.0)) { - correction = _4P40[y] - _4P40[x] ; - lbe = _4P40[y]; - correctL = true; - } - } else if (lum < 55.0) { - if( (hue <= (_05PB50[x] + _15PB50[x]) / 2.0) && (hue > (_05PB50[x] + _10B50[x]) / 2.0) && x < 79 ) { - if(y > 79) { - y = 79; - } - - correction = _05PB50[y] - _05PB50[x] ; - lbe = _05PB50[y]; - correctL = true; - } else if( (hue <= (_05PB50[x] + _10B50[x]) / 2.0) && (hue > (_10B50[x] + _9B50[x]) / 2.0) && x < 79 ) { - if(y > 79) { - y = 79; - } - - correction = _10B50[y] - _10B50[x] ; - lbe = _10B50[y]; - correctL = true; - } else if( (hue <= (_10B50[x] + _9B50[x]) / 2.0) && (hue > (_9B50[x] + _7B50[x]) / 2.0) && x < 79 ) { - if(y > 79) { - y = 79; - } - - correction = _9B50[y] - _9B50[x] ; - lbe = _9B50[y]; - correctL = true; - } else if( (hue <= (_9B50[x] + _7B50[x]) / 2.0) && (hue > (_5B50[x] + _7B50[x]) / 2.0) && x < 79 ) { - if(y > 79) { - y = 79; - } - - correction = _7B50[y] - _7B50[x] ; - lbe = _7B50[y]; - correctL = true; - } else if (( hue <= (_5B50[x] + _7B50[x]) / 2.0) && (hue > (_5B50[x] - 0.035)) && x < 79) { - if(y > 79) { - y = 79; // - } - - correction = _5B50[y] - _5B50[x] ; - lbe = _5B50[y]; - correctL = true; - } - - else if( (hue >= (_15PB50[x] - 0.035)) && (hue < (_15PB50[x] + _3PB50[x]) / 2.0) && x <= 85 ) { - if(y > 89) { - y = 89; - } - - correction = _15PB50[y] - _15PB50[x] ; - lbe = _15PB50[y]; - correctL = true; - } else if (( hue >= (_15PB50[x] + _3PB50[x]) / 2.0) && (hue < (_45PB50[x] + _3PB50[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _3PB50[y] - _3PB50[x] ; - lbe = _3PB50[y]; - correctL = true; - } else if (( hue >= (_45PB50[x] + _3PB50[x]) / 2.0) && (hue < (_6PB50[x] + _45PB50[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _45PB50[y] - _45PB50[x] ; - lbe = _45PB50[y]; - correctL = true; - } else if (( hue >= (_6PB50[x] + _45PB50[x]) / 2.0) && (hue < (_6PB50[x] + _75PB50[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _6PB50[y] - _6PB50[x] ; - lbe = _6PB50[y]; - correctL = true; - } else if (( hue >= (_6PB50[x] + _75PB50[x]) / 2.0) && (hue < (_9PB50[x] + _75PB50[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _75PB50[y] - _75PB50[x] ; - lbe = _75PB50[y]; - correctL = true; - } else if (( hue >= (_9PB50[x] + _75PB50[x]) / 2.0) && (hue < (_9PB50[x] + _10PB50[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _9PB50[y] - _9PB50[x] ; - lbe = _9PB50[y]; - correctL = true; - } else if (( hue >= (_10PB50[x] + _9PB50[x]) / 2.0) && (hue < (_1P50[x] + _10PB50[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _10PB50[y] - _10PB50[x] ; - lbe = _10PB50[y]; - correctL = true; - } else if (( hue >= (_10PB50[x] + _1P50[x]) / 2.0) && (hue < (_1P50[x] + _4P50[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _1P50[y] - _1P50[x] ; - lbe = _1P50[y]; - correctL = true; - } else if (( hue >= (_1P50[x] + _4P50[x]) / 2.0) && (hue < (0.035 + _4P50[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _4P50[y] - _4P50[x] ; - lbe = _4P50[y]; - correctL = true; - } - } else if (lum < 65.0) { - if( (hue <= (_05PB60[x] + _15PB60[x]) / 2.0) && (hue > (_05PB60[x] + _10B60[x]) / 2.0) && x < 79 ) { - if(y > 79) { - y = 79; - } - - correction = _05PB60[y] - _05PB60[x] ; - lbe = _05PB60[y]; - correctL = true; - } else if( (hue <= (_05PB60[x] + _10B60[x]) / 2.0) && (hue > (_10B60[x] + _9B60[x]) / 2.0) && x < 79 ) { - if(y > 79) { - y = 79; - } - - correction = _10B60[y] - _10B60[x] ; - lbe = _10B60[y]; - correctL = true; - } else if( (hue <= (_10B60[x] + _9B60[x]) / 2.0) && (hue > (_9B60[x] + _7B60[x]) / 2.0) && x < 79 ) { - if(y > 79) { - y = 79; - } - - correction = _9B60[y] - _9B60[x] ; - lbe = _9B60[y]; - correctL = true; - } else if( (hue <= (_9B60[x] + _7B60[x]) / 2.0) && (hue > (_5B60[x] + _7B60[x]) / 2.0) && x < 79 ) { - if(y > 79) { - y = 79; - } - - correction = _7B60[y] - _7B60[x] ; - lbe = _7B60[y]; - correctL = true; - } else if (( hue <= (_5B60[x] + _7B60[x]) / 2.0) && (hue > (_5B60[x] - 0.035)) && x < 79) { - if(y > 79) { - y = 79; // - } - - correction = _5B60[y] - _5B60[x] ; - lbe = _5B60[y]; - correctL = true; - } - - else if( (hue >= (_15PB60[x] - 0.035)) && (hue < (_15PB60[x] + _3PB60[x]) / 2.0) && x <= 85 ) { - if(y > 89) { - y = 89; - } - - correction = _15PB60[y] - _15PB60[x] ; - lbe = _15PB60[y]; - correctL = true; - } else if (( hue >= (_15PB60[x] + _3PB60[x]) / 2.0) && (hue < (_45PB60[x] + _3PB60[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _3PB60[y] - _3PB60[x] ; - lbe = _3PB60[y]; - correctL = true; - } else if (( hue >= (_45PB60[x] + _3PB60[x]) / 2.0) && (hue < (_6PB60[x] + _45PB60[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _45PB60[y] - _45PB60[x] ; - lbe = _45PB60[y]; - correctL = true; - } else if (( hue >= (_6PB60[x] + _45PB60[x]) / 2.0) && (hue < (_6PB60[x] + _75PB60[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _6PB60[y] - _6PB60[x] ; - lbe = _6PB60[y]; - correctL = true; - } else if (( hue >= (_6PB60[x] + _75PB60[x]) / 2.0) && (hue < (_9PB60[x] + _75PB60[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _75PB60[y] - _75PB60[x] ; - lbe = _75PB60[y]; - correctL = true; - } else if (( hue >= (_9PB60[x] + _75PB60[x]) / 2.0) && (hue < (_9PB60[x] + _10PB60[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _9PB60[y] - _9PB60[x] ; - lbe = _9PB60[y]; - correctL = true; - } else if (( hue >= (_10PB60[x] + _9PB60[x]) / 2.0) && (hue < (_1P60[x] + _10PB60[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _10PB60[y] - _10PB60[x] ; - lbe = _10PB60[y]; - correctL = true; - } else if (( hue >= (_10PB60[x] + _1P60[x]) / 2.0) && (hue < (_1P60[x] + _4P60[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _1P60[y] - _1P60[x] ; - lbe = _1P60[y]; - correctL = true; - } else if (( hue >= (_1P60[x] + _4P60[x]) / 2.0) && (hue < (0.035 + _4P60[x]) / 2.0) && x <= 85) { - if(y > 89) { - y = 89; - } - - correction = _4P60[y] - _4P60[x] ; - lbe = _4P60[y]; - correctL = true; - } - } else if (lum < 75.0) { - if( (hue <= (_05PB70[x] + _15PB70[x]) / 2.0) && (hue > (_05PB70[x] + _10B70[x]) / 2.0) && x < 50 ) { - if(y > 49) { - y = 49; - } - - correction = _05PB70[y] - _05PB70[x] ; - lbe = _05PB70[y]; - correctL = true; - } else if( (hue <= (_05PB70[x] + _10B70[x]) / 2.0) && (hue > (_10B70[x] + _9B70[x]) / 2.0) && x < 50 ) { - if(y > 49) { - y = 49; - } - - correction = _10B70[y] - _10B70[x] ; - lbe = _10B70[y]; - correctL = true; - } else if( (hue <= (_10B70[x] + _9B70[x]) / 2.0) && (hue > (_9B70[x] + _7B70[x]) / 2.0) && x < 50 ) { - if(y > 49) { - y = 49; - } - - correction = _9B70[y] - _9B70[x] ; - lbe = _9B70[y]; - correctL = true; - } else if( (hue <= (_9B70[x] + _7B70[x]) / 2.0) && (hue > (_5B70[x] + _7B70[x]) / 2.0) && x < 50 ) { - if(y > 49) { - y = 49; - } - - correction = _7B70[y] - _7B70[x] ; - lbe = _7B70[y]; - correctL = true; - } else if (( hue <= (_5B70[x] + _7B70[x]) / 2.0) && (hue > (_5B70[x] - 0.035)) && x < 50) { - if(y > 49) { - y = 49; // - } - - correction = _5B70[y] - _5B70[x] ; - lbe = _5B70[y]; - correctL = true; - } - - else if( (hue >= (_15PB70[x] - 0.035)) && (hue < (_15PB70[x] + _3PB70[x]) / 2.0) && x < 50 ) { - if(y > 49) { - y = 49; - } - - correction = _15PB70[y] - _15PB70[x] ; - lbe = _15PB70[y]; - correctL = true; - } else if (( hue >= (_45PB70[x] + _3PB70[x]) / 2.0) && (hue < (_6PB70[x] + _45PB70[x]) / 2.0) && x < 50) { - if(y > 49) { - y = 49; - } - - correction = _45PB70[y] - _45PB70[x] ; - lbe = _45PB70[y]; - correctL = true; - } else if (( hue >= (_6PB70[x] + _45PB70[x]) / 2.0) && (hue < (_6PB70[x] + _75PB70[x]) / 2.0) && x < 50) { - if(y > 49) { - y = 49; - } - - correction = _6PB70[y] - _6PB70[x] ; - lbe = _6PB70[y]; - correctL = true; - } else if (( hue >= (_6PB70[x] + _75PB70[x]) / 2.0) && (hue < (_9PB70[x] + _75PB70[x]) / 2.0) && x < 50) { - if(y > 49) { - y = 49; - } - - correction = _75PB70[y] - _75PB70[x] ; - lbe = _75PB70[y]; - correctL = true; - } else if (( hue >= (_9PB70[x] + _75PB70[x]) / 2.0) && (hue < (_9PB70[x] + 0.035)) && x < 50) { - if(y > 49) { - y = 49; - } - - correction = _9PB70[y] - _9PB70[x] ; - lbe = _9PB70[y]; - correctL = true; - } - } else if (lum < 85.0) { - if( (hue <= (_05PB80[x] + _15PB80[x]) / 2.0) && (hue > (_05PB80[x] + _10B80[x]) / 2.0) && x < 40 ) { - if(y > 39) { - y = 39; - } - - correction = _05PB80[y] - _05PB80[x] ; - lbe = _05PB80[y] ; - correctL = true; - } else if( (hue <= (_05PB80[x] + _10B80[x]) / 2.0) && (hue > (_10B80[x] + _9B80[x]) / 2.0) && x < 40 ) { - if(y > 39) { - y = 39; - } - - correction = _10B80[y] - _10B80[x] ; - lbe = _10B80[y]; - correctL = true; - } else if( (hue <= (_10B80[x] + _9B80[x]) / 2.0) && (hue > (_9B80[x] + _7B80[x]) / 2.0) && x < 40 ) { - if(y > 39) { - y = 39; - } - - correction = _9B80[y] - _9B80[x] ; - lbe = _9B80[y]; - correctL = true; - } else if( (hue <= (_9B80[x] + _7B80[x]) / 2.0) && (hue > (_5B80[x] + _7B80[x]) / 2.0) && x < 50 ) { - if(y > 49) { - y = 49; - } - - correction = _7B80[y] - _7B80[x] ; - lbe = _7B80[y]; - correctL = true; - } else if (( hue <= (_5B80[x] + _7B80[x]) / 2.0) && (hue > (_5B80[x] - 0.035)) && x < 50) { - if(y > 49) { - y = 49; // - } - - correction = _5B80[y] - _5B80[x] ; - lbe = _5B80[y]; - correctL = true; - } - - else if( (hue >= (_15PB80[x] - 0.035)) && (hue < (_15PB80[x] + _3PB80[x]) / 2.0) && x < 50 ) { - if(y > 49) { - y = 49; - } - - correction = _15PB80[y] - _15PB80[x] ; - lbe = _15PB80[y]; - correctL = true; - } else if (( hue >= (_45PB80[x] + _3PB80[x]) / 2.0) && (hue < (_6PB80[x] + _45PB80[x]) / 2.0) && x < 50) { - if(y > 49) { - y = 49; - } - - correction = _45PB80[y] - _45PB80[x] ; - lbe = _45PB80[y]; - correctL = true; - } else if (( hue >= (_6PB80[x] + _45PB80[x]) / 2.0) && (hue < (_6PB80[x] + _75PB80[x]) / 2.0) && x < 50) { - if(y > 49) { - y = 49; - } - - correction = _6PB80[y] - _6PB80[x] ; - lbe = _6PB80[y]; - correctL = true; - } else if (( hue >= (_6PB80[x] + _75PB80[x]) / 2.0) && (hue < (_9PB80[x] + _75PB80[x]) / 2.0) && x < 50) { - if(y > 49) { - y = 49; - } - - correction = _75PB80[y] - _75PB80[x] ; - lbe = _75PB80[y]; - correctL = true; - } else if (( hue >= (_9PB80[x] + _75PB80[x]) / 2.0) && (hue < (_9PB80[x] + 0.035)) && x < 50) { - if(y > 49) { - y = 49; - } - - correction = _9PB80[y] - _9PB80[x] ; - lbe = _9PB80[y]; - correctL = true; - } - } - } - } - // end PB correction - - //red yellow correction - else if(zone == 2) { - if(lum > 15.0) { - if(lum < 25.0) { - if( (hue <= (_10YR20[x] + 0.035)) && (hue > (_10YR20[x] + _85YR20[x]) / 2.0) && x <= 45) { - if(y > 49) { - y = 49; - } - - correction = _10YR20[y] - _10YR20[x] ; - lbe = _10YR20[y]; - correctL = true; - } else if (( hue <= (_85YR20[x] + _10YR20[x]) / 2.0) && (hue > (_85YR20[x] + 0.035) && x <= 45)) { - if(y > 49) { - y = 49; - } - - correction = _85YR20[y] - _85YR20[x] ; - lbe = _85YR20[y]; - correctL = true; - } - } else if (lum < 35.0) { - if( (hue <= (_10YR30[x] + 0.035)) && (hue > (_10YR30[x] + _85YR30[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _10YR30[y] - _10YR30[x] ; - lbe = _10YR30[y]; - correctL = true; - } else if( (hue <= (_10YR30[x] + _85YR30[x]) / 2.0) && (hue > (_85YR30[x] + _7YR30[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _85YR30[y] - _85YR30[x] ; - lbe = _85YR30[y]; - correctL = true; - } else if (( hue <= (_85YR30[x] + _7YR30[x]) / 2.0) && (hue > (_7YR30[x] + _55YR30[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _7YR30[y] - _7YR30[x] ; - lbe = _7YR30[y]; - correctL = true; - } else if (( hue <= (_7YR30[x] + _55YR30[x]) / 2.0) && (hue > (_55YR30[x] + _4YR30[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _55YR30[y] - _55YR30[x] ; - lbe = _55YR30[y]; - correctL = true; - } else if (( hue <= (_55YR30[x] + _4YR30[x]) / 2.0) && (hue > (_4YR30[x] + _25YR30[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _4YR30[y] - _4YR30[x] ; - lbe = _4YR30[y]; - correctL = true; - } else if (( hue <= (_4YR30[x] + _25YR30[x]) / 2.0) && (hue > (_25YR30[x] + _10R30[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _25YR30[y] - _25YR30[x] ; - lbe = _25YR30[y]; - correctL = true; - } else if (( hue <= (_25YR30[x] + _10R30[x]) / 2.0) && (hue > (_10R30[x] + _9R30[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _10R30[y] - _10R30[x] ; - lbe = _10R30[y]; - correctL = true; - } else if (( hue <= (_10R30[x] + _9R30[x]) / 2.0) && (hue > (_9R30[x] + _7R30[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _9R30[y] - _9R30[x] ; - lbe = _9R30[y]; - correctL = true; - } else if (( hue <= (_9R30[x] + _7R30[x]) / 2.0) && (hue > (_7R30[x] - 0.035)) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _7R30[y] - _7R30[x] ; - lbe = _7R30[y] ; - correctL = true; - } - } else if (lum < 45.0) { - if( (hue <= (_10YR40[x] + 0.035)) && (hue > (_10YR40[x] + _85YR40[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _10YR40[y] - _10YR40[x] ; - lbe = _10YR40[y]; - correctL = true; - } else if( (hue <= (_10YR40[x] + _85YR40[x]) / 2.0) && (hue > (_85YR40[x] + _7YR40[x]) / 2.0) && x < 85 ) { - if(y > 89) { - y = 89; - } - - correction = _85YR40[y] - _85YR40[x] ; - lbe = _85YR40[y]; - correctL = true; - } else if (( hue <= (_85YR40[x] + _7YR40[x]) / 2.0) && (hue > (_7YR40[x] + _55YR40[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _7YR40[y] - _7YR40[x] ; - lbe = _7YR40[y]; - correctL = true; - } else if (( hue <= (_7YR40[x] + _55YR40[x]) / 2.0) && (hue > (_55YR40[x] + _4YR40[x]) / 2.0) && x < 85 ) { - if(y > 89) { - y = 89; - } - - correction = _55YR40[y] - _55YR40[x] ; - lbe = _55YR40[y]; - correctL = true; - } else if (( hue <= (_55YR40[x] + _4YR40[x]) / 2.0) && (hue > (_4YR40[x] + _25YR40[x]) / 2.0) && x < 85 ) { - if(y > 89) { - y = 89; - } - - correction = _4YR40[y] - _4YR40[x] ; - lbe = _4YR40[y]; - correctL = true; - } else if (( hue <= (_4YR40[x] + _25YR40[x]) / 2.0) && (hue > (_25YR40[x] + _10R40[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _25YR40[y] - _25YR40[x] ; - lbe = _25YR40[y] ; - correctL = true; - } else if (( hue <= (_25YR40[x] + _10R40[x]) / 2.0) && (hue > (_10R40[x] + _9R40[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _10R40[y] - _10R40[x] ; - lbe = _10R40[y]; - correctL = true; - } else if (( hue <= (_10R40[x] + _9R40[x]) / 2.0) && (hue > (_9R40[x] + _7R40[x]) / 2.0) && x < 85 ) { - if(y > 89) { - y = 89; - } - - correction = _9R40[y] - _9R40[x] ; - lbe = _9R40[y]; - correctL = true; - } else if (( hue <= (_9R40[x] + _7R40[x]) / 2.0) && (hue > (_7R40[x] - 0.035)) && x < 85 ) { - if(y > 89) { - y = 89; - } - - correction = _7R40[y] - _7R40[x] ; - lbe = _7R40[y]; - correctL = true; - } - } else if (lum < 55.0) { - if( (hue <= (_10YR50[x] + 0.035)) && (hue > (_10YR50[x] + _85YR50[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _10YR50[y] - _10YR50[x] ; - lbe = _10YR50[y]; - correctL = true; - } else if( (hue <= (_10YR50[x] + _85YR50[x]) / 2.0) && (hue > (_85YR50[x] + _7YR50[x]) / 2.0) && x < 85 ) { - if(y > 89) { - y = 89; - } - - correction = _85YR50[y] - _85YR50[x] ; - lbe = _85YR50[y]; - correctL = true; - } else if (( hue <= (_85YR50[x] + _7YR50[x]) / 2.0) && (hue > (_7YR50[x] + _55YR50[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _7YR50[y] - _7YR50[x] ; - lbe = _7YR50[y]; - correctL = true; - } else if (( hue <= (_7YR50[x] + _55YR50[x]) / 2.0) && (hue > (_55YR50[x] + _4YR50[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _55YR50[y] - _55YR50[x] ; - lbe = _55YR50[y]; - correctL = true; - } else if (( hue <= (_55YR50[x] + _4YR50[x]) / 2.0) && (hue > (_4YR50[x] + _25YR50[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _4YR50[y] - _4YR50[x] ; - lbe = _4YR50[y]; - correctL = true; - } else if (( hue <= (_4YR50[x] + _25YR50[x]) / 2.0) && (hue > (_25YR50[x] + _10R50[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _25YR50[y] - _25YR50[x] ; - lbe = _25YR50[y]; - correctL = true; - } else if (( hue <= (_25YR50[x] + _10R50[x]) / 2.0) && (hue > (_10R50[x] + _9R50[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _10R50[y] - _10R50[x] ; - lbe = _10R50[y]; - correctL = true; - } else if (( hue <= (_10R50[x] + _9R50[x]) / 2.0) && (hue > (_9R50[x] + _7R50[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _9R50[y] - _9R50[x] ; - lbe = _9R50[y]; - correctL = true; - } else if (( hue <= (_9R50[x] + _7R50[x]) / 2.0) && (hue > (_7R50[x] - 0.035)) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _7R50[y] - _7R50[x] ; - lbe = _7R50[y]; - correctL = true; - } - } else if (lum < 65.0) { - if( (hue <= (_10YR60[x] + 0.035)) && (hue > (_10YR60[x] + _85YR60[x]) / 2.0)) { - ; - correction = _10YR60[y] - _10YR60[x] ; - lbe = _10YR60[y]; - correctL = true; - } else if( (hue <= (_10YR60[x] + _85YR60[x]) / 2.0) && (hue > (_85YR60[x] + _7YR60[x]) / 2.0) ) { - ; - correction = _85YR60[y] - _85YR60[x] ; - lbe = _85YR60[y]; - correctL = true; - } else if (( hue <= (_85YR60[x] + _7YR60[x]) / 2.0) && (hue > (_7YR60[x] + _55YR60[x]) / 2.0)) { - correction = _7YR60[y] - _7YR60[x] ; - lbe = _7YR60[y]; - correctL = true; - } else if (( hue <= (_7YR60[x] + _55YR60[x]) / 2.0) && (hue > (_55YR60[x] + _4YR60[x]) / 2.0)) { - correction = _55YR60[y] - _55YR60[x] ; - lbe = _55YR60[y]; - correctL = true; - } else if (( hue <= (_55YR60[x] + _4YR60[x]) / 2.0) && (hue > (_4YR60[x] + _25YR60[x]) / 2.0)) { - correction = _4YR60[y] - _4YR60[x] ; - lbe = _4YR60[y]; - correctL = true; - } else if (( hue <= (_4YR60[x] + _25YR60[x]) / 2.0) && (hue > (_25YR60[x] + _10R60[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _25YR60[y] - _25YR60[x] ; - lbe = _25YR60[y]; - correctL = true; - } else if (( hue <= (_25YR60[x] + _10R60[x]) / 2.0) && (hue > (_10R60[x] + _9R60[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _10R60[y] - _10R60[x] ; - lbe = _10R60[y]; - correctL = true; - } else if (( hue <= (_10R60[x] + _9R60[x]) / 2.0) && (hue > (_9R60[x] + _7R60[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _9R60[y] - _9R60[x] ; - lbe = _9R60[y]; - correctL = true; - } else if (( hue <= (_9R60[x] + _7R60[x]) / 2.0) && (hue > (_7R60[x] - 0.035)) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _7R60[y] - _7R60[x] ; - lbe = _7R60[y]; - correctL = true; - } - } else if (lum < 75.0) { - if( (hue <= (_10YR70[x] + 0.035)) && (hue > (_10YR70[x] + _85YR70[x]) / 2.0)) { - correction = _10YR70[y] - _10YR70[x] ; - lbe = _10YR70[y]; - correctL = true; - } else if( (hue <= (_10YR70[x] + _85YR70[x]) / 2.0) && (hue > (_85YR70[x] + _7YR70[x]) / 2.0)) { - correction = _85YR70[y] - _85YR70[x] ; - lbe = _85YR70[y]; - correctL = true; - } - - if (( hue <= (_85YR70[x] + _7YR70[x]) / 2.0) && (hue > (_7YR70[x] + _55YR70[x]) / 2.0)) { - correction = _7YR70[y] - _7YR70[x] ; - lbe = _7YR70[y]; - correctL = true; - } else if (( hue <= (_7YR70[x] + _55YR70[x]) / 2.0) && (hue > (_55YR70[x] + _4YR70[x]) / 2.0)) { - correction = _55YR70[y] - _55YR70[x] ; - lbe = _55YR70[y]; - correctL = true; - } else if (( hue <= (_55YR70[x] + _4YR70[x]) / 2.0) && (hue > (_4YR70[x] + _25YR70[x]) / 2.0)) { - correction = _4YR70[y] - _4YR70[x] ; - lbe = _4YR70[y]; - correctL = true; - } else if (( hue <= (_4YR70[x] + _25YR70[x]) / 2.0) && (hue > (_25YR70[x] + _10R70[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _25YR70[y] - _25YR70[x] ; - lbe = _25YR70[y]; - correctL = true; - } else if (( hue <= (_25YR70[x] + _10R70[x]) / 2.0) && (hue > (_10R70[x] + _9R70[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _10R70[y] - _10R70[x] ; - lbe = _10R70[y]; - correctL = true; - } else if (( hue <= (_10R70[x] + _9R70[x]) / 2.0) && (hue > (_9R70[x] + _7R70[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _9R70[y] - _9R70[x] ; - lbe = _9R70[y] ; - correctL = true; - } else if (( hue <= (_9R70[x] + _7R70[x]) / 2.0) && (hue > (_7R70[x] - 0.035)) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _7R70[y] - _7R70[x] ; - lbe = _7R70[y]; - correctL = true; - } - } else if (lum < 85.0) { - if( (hue <= (_10YR80[x] + 0.035)) && (hue > (_10YR80[x] + _85YR80[x]) / 2.0)) { - correction = _10YR80[y] - _10YR80[x] ; - lbe = _10YR80[y]; - correctL = true; - } else if( (hue <= (_10YR80[x] + _85YR80[x]) / 2.0) && (hue > (_85YR80[x] + _7YR80[x]) / 2.0)) { - correction = _85YR80[y] - _85YR80[x] ; - lbe = _85YR80[y]; - } else if (( hue <= (_85YR80[x] + _7YR80[x]) / 2.0) && (hue > (_7YR80[x] + _55YR80[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _7YR80[y] - _7YR80[x] ; - lbe = _7YR80[y]; - correctL = true; - } else if (( hue <= (_7YR80[x] + _55YR80[x]) / 2.0) && (hue > (_55YR80[x] + _4YR80[x]) / 2.0) && x < 45) { - correction = _55YR80[y] - _55YR80[x] ; - lbe = _55YR80[y]; - correctL = true; - } else if (( hue <= (_55YR80[x] + _4YR80[x]) / 2.0) && (hue > (_4YR80[x] - 0.035) && x < 45)) { - if(y > 49) { - y = 49; - } - - correction = _4YR80[y] - _4YR80[x] ; - lbe = _4YR80[y] ; - correctL = true; - } - } else if (lum < 95.0) { - if( (hue <= (_10YR90[x] + 0.035)) && (hue > (_10YR90[x] - 0.035) && x < 85)) { - if(y > 89) { - y = 89; - } - - correction = _10YR90[y] - _10YR90[x] ; - lbe = _10YR90[y]; - correctL = true; - } else if ( hue <= (_85YR90[x] + 0.035) && hue > (_85YR90[x] - 0.035) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _85YR90[y] - _85YR90[x] ; - lbe = _85YR90[y]; - correctL = true; - } else if (( hue <= (_55YR90[x] + 0.035) && (hue > (_55YR90[x] - 0.035) && x < 45))) { - if(y > 49) { - y = 49; - } - - correction = _55YR90[y] - _55YR90[x] ; - lbe = _55YR90[y]; - correctL = true; - } - } - } - } - //end red yellow - - //Green yellow correction - else if(zone == 3) { - if (lum >= 25.0) { - if (lum < 35.0) { - if( (hue <= (_7G30[x] + 0.035)) && (hue > (_7G30[x] + _5G30[x]) / 2.0) ) { - correction = _7G30[y] - _7G30[x] ; - lbe = _7G30[y]; - correctL = true; - } else if( (hue <= (_7G30[x] + _5G30[x]) / 2.0) && (hue > (_5G30[x] + _25G30[x]) / 2.0)) { - correction = _5G30[y] - _5G30[x] ; - lbe = _5G30[y]; - correctL = true; - } else if (( hue <= (_25G30[x] + _5G30[x]) / 2.0) && (hue > (_25G30[x] + _1G30[x]) / 2.0)) { - correction = _25G30[y] - _25G30[x] ; - lbe = _25G30[y]; - correctL = true; - } else if (( hue <= (_1G30[x] + _25G30[x]) / 2.0) && (hue > (_1G30[x] + _10GY30[x]) / 2.0)) { - correction = _1G30[y] - _1G30[x] ; - lbe = _1G30[y]; - correctL = true; - } else if (( hue <= (_1G30[x] + _10GY30[x]) / 2.0) && (hue > (_10GY30[x] + _75GY30[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _10GY30[y] - _10GY30[x] ; - lbe = _10GY30[y]; - correctL = true; - } else if (( hue <= (_10GY30[x] + _75GY30[x]) / 2.0) && (hue > (_75GY30[x] + _5GY30[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _75GY30[y] - _75GY30[x] ; - lbe = _75GY30[y]; - correctL = true; - } else if (( hue <= (_5GY30[x] + _75GY30[x]) / 2.0) && (hue > (_5GY30[x] - 0.035)) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _5GY30[y] - _5GY30[x] ; - lbe = _5GY30[y] ; - correctL = true; - } - } else if (lum < 45.0) { - if( (hue <= (_7G40[x] + 0.035)) && (hue > (_7G40[x] + _5G40[x]) / 2.0) ) { - correction = _7G40[y] - _7G40[x] ; - lbe = _7G40[y]; - correctL = true; - } else if( (hue <= (_7G40[x] + _5G40[x]) / 2.0) && (hue > (_5G40[x] + _25G40[x]) / 2.0)) { - correction = _5G40[y] - _5G40[x] ; - lbe = _5G40[y]; - correctL = true; - } else if (( hue <= (_25G40[x] + _5G40[x]) / 2.0) && (hue > (_25G40[x] + _1G40[x]) / 2.0)) { - correction = _25G40[y] - _25G40[x] ; - lbe = _25G40[y]; - correctL = true; - } else if (( hue <= (_1G40[x] + _25G40[x]) / 2.0) && (hue > (_1G40[x] + _10GY40[x]) / 2.0)) { - correction = _1G40[y] - _1G40[x] ; - lbe = _1G40[y]; - correctL = true; - } else if (( hue <= (_1G40[x] + _10GY40[x]) / 2.0) && (hue > (_10GY40[x] + _75GY40[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _10GY40[y] - _10GY40[x] ; - lbe = _10GY40[y]; - correctL = true; - } else if (( hue <= (_10GY40[x] + _75GY40[x]) / 2.0) && (hue > (_75GY40[x] + _5GY40[x]) / 2.0) && x < 85) { - if(y > 89) { - y = 89; - } - - correction = _75GY40[y] - _75GY40[x] ; - lbe = _75GY40[y]; - correctL = true; - } else if (( hue <= (_5GY40[x] + _75GY40[x]) / 2.0) && (hue > (_5GY40[x] - 0.035)) && x < 85) { - if(y > 89) { - y = 89; // - } - - correction = _5GY40[y] - _5GY40[x] ; - lbe = _5GY40[y]; - correctL = true; - } - } else if (lum < 55.0) { - if( (hue <= (_7G50[x] + 0.035)) && (hue > (_7G50[x] + _5G50[x]) / 2.0) ) { - correction = _7G50[y] - _7G50[x] ; - lbe = _7G50[y]; - correctL = true; - } else if( (hue <= (_7G50[x] + _5G50[x]) / 2.0) && (hue > (_5G50[x] + _25G50[x]) / 2.0)) { - correction = _5G50[y] - _5G50[x] ; - lbe = _5G50[y]; - correctL = true; - } else if (( hue <= (_25G50[x] + _5G50[x]) / 2.0) && (hue > (_25G50[x] + _1G50[x]) / 2.0)) { - correction = _25G50[y] - _25G50[x] ; - lbe = _25G50[y]; - correctL = true; - } else if (( hue <= (_1G50[x] + _25G50[x]) / 2.0) && (hue > (_1G50[x] + _10GY50[x]) / 2.0)) { - correction = _1G50[y] - _1G50[x] ; - lbe = _1G50[y]; - correctL = true; - } else if (( hue <= (_1G50[x] + _10GY50[x]) / 2.0) && (hue > (_10GY50[x] + _75GY50[x]) / 2.0)) { - correction = _10GY50[y] - _10GY50[x] ; - lbe = _10GY50[y]; - correctL = true; - } else if (( hue <= (_10GY50[x] + _75GY50[x]) / 2.0) && (hue > (_75GY50[x] + _5GY50[x]) / 2.0)) { - correction = _75GY50[y] - _75GY50[x] ; - lbe = _75GY50[y]; - correctL = true; - } else if (( hue <= (_5GY50[x] + _75GY50[x]) / 2.0) && (hue > (_5GY50[x] - 0.035))) { - correction = _5GY50[y] - _5GY50[x] ; - lbe = _5GY50[y]; - correctL = true; - } - } else if (lum < 65.0) { - if( (hue <= (_7G60[x] + 0.035)) && (hue > (_7G60[x] + _5G60[x]) / 2.0) ) { - correction = _7G60[y] - _7G60[x] ; - lbe = _7G60[y]; - correctL = true; - } else if( (hue <= (_7G60[x] + _5G60[x]) / 2.0) && (hue > (_5G60[x] + _25G60[x]) / 2.0)) { - correction = _5G60[y] - _5G60[x] ; - lbe = _5G60[y]; - correctL = true; - } else if (( hue <= (_25G60[x] + _5G60[x]) / 2.0) && (hue > (_25G60[x] + _1G60[x]) / 2.0)) { - correction = _25G60[y] - _25G60[x] ; - lbe = _25G60[y]; - correctL = true; - } else if (( hue <= (_1G60[x] + _25G60[x]) / 2.0) && (hue > (_1G60[x] + _10GY60[x]) / 2.0)) { - correction = _1G60[y] - _1G60[x] ; - lbe = _1G60[y]; - correctL = true; - } else if (( hue <= (_1G60[x] + _10GY60[x]) / 2.0) && (hue > (_10GY60[x] + _75GY60[x]) / 2.0)) { - correction = _10GY60[y] - _10GY60[x] ; - lbe = _10GY60[y]; - correctL = true; - } else if (( hue <= (_10GY60[x] + _75GY60[x]) / 2.0) && (hue > (_75GY60[x] + _5GY60[x]) / 2.0)) { - correction = _75GY60[y] - _75GY60[x] ; - lbe = _75GY60[y] ; - correctL = true; - } else if (( hue <= (_5GY60[x] + _75GY60[x]) / 2.0) && (hue > (_5GY60[x] - 0.035))) { - correction = _5GY60[y] - _5GY60[x] ; - lbe = _5GY60[y]; - correctL = true; - } - } else if (lum < 75.0) { - if( (hue <= (_7G70[x] + 0.035)) && (hue > (_7G70[x] + _5G70[x]) / 2.0) ) { - correction = _7G70[y] - _7G70[x] ; - lbe = _7G70[y]; - correctL = true; - } else if( (hue <= (_7G70[x] + _5G70[x]) / 2.0) && (hue > (_5G70[x] + _25G70[x]) / 2.0)) { - correction = _5G70[y] - _5G70[x] ; - lbe = _5G70[y]; - correctL = true; - } else if (( hue <= (_25G70[x] + _5G70[x]) / 2.0) && (hue > (_25G70[x] + _1G70[x]) / 2.0)) { - correction = _25G70[y] - _25G70[x] ; - lbe = _25G70[y]; - correctL = true; - } else if (( hue <= (_1G70[x] + _25G70[x]) / 2.0) && (hue > (_1G70[x] + _10GY70[x]) / 2.0)) { - correction = _1G70[y] - _1G70[x] ; - lbe = _1G70[y] ; - correctL = true; - } else if (( hue <= (_1G70[x] + _10GY70[x]) / 2.0) && (hue > (_10GY70[x] + _75GY70[x]) / 2.0)) { - correction = _10GY70[y] - _10GY70[x] ; - lbe = _10GY70[y]; - correctL = true; - } else if (( hue <= (_10GY70[x] + _75GY70[x]) / 2.0) && (hue > (_75GY70[x] + _5GY70[x]) / 2.0)) { - correction = _75GY70[y] - _75GY70[x] ; - lbe = _75GY70[y]; - correctL = true; - } else if (( hue <= (_5GY70[x] + _75GY70[x]) / 2.0) && (hue > (_5GY70[x] - 0.035))) { - correction = _5GY70[y] - _5GY70[x] ; - lbe = _5GY70[y]; - correctL = true; - } - } else if (lum < 85.0) { - if( (hue <= (_7G80[x] + 0.035)) && (hue > (_7G80[x] + _5G80[x]) / 2.0) ) { - correction = _7G80[y] - _7G80[x] ; - lbe = _7G80[y]; - correctL = true; - } else if( (hue <= (_7G80[x] + _5G80[x]) / 2.0) && (hue > (_5G80[x] + _25G80[x]) / 2.0)) { - correction = _5G80[y] - _5G80[x] ; - lbe = _5G80[y]; - correctL = true; - } else if (( hue <= (_25G80[x] + _5G80[x]) / 2.0) && (hue > (_25G80[x] + _1G80[x]) / 2.0)) { - correction = _25G80[y] - _25G80[x] ; - lbe = _25G80[y]; - correctL = true; - } else if (( hue <= (_1G80[x] + _25G80[x]) / 2.0) && (hue > (_1G80[x] + _10GY80[x]) / 2.0)) { - correction = _1G80[y] - _1G80[x] ; - lbe = _1G80[y]; - correctL = true; - } else if (( hue <= (_1G80[x] + _10GY80[x]) / 2.0) && (hue > (_10GY80[x] + _75GY80[x]) / 2.0)) { - correction = _10GY80[y] - _10GY80[x] ; - lbe = _10GY80[y]; - correctL = true; - } else if (( hue <= (_10GY80[x] + _75GY80[x]) / 2.0) && (hue > (_75GY80[x] + _5GY80[x]) / 2.0)) { - correction = _75GY80[y] - _75GY80[x] ; - lbe = _75GY80[y]; - correctL = true; - } else if (( hue <= (_5GY80[x] + _75GY80[x]) / 2.0) && (hue > (_5GY80[x] - 0.035))) { - correction = _5GY80[y] - _5GY80[x] ; - lbe = _5GY80[y]; - correctL = true; - } - } - } - } - //end green yellow - - //Red purple correction : only for L < 30 - else if(zone == 4) { - if (lum > 5.0) { - if (lum < 15.0) { - if( (hue <= (_5R10[x] + 0.035)) && (hue > (_5R10[x] - 0.043)) && x < 45) { - if(y > 44) { - y = 44; - } - - correction = _5R10[y] - _5R10[x] ; - lbe = _5R10[y]; - correctL = true; - } else if( (hue <= (_25R10[x] + 0.043)) && (hue > (_25R10[x] + _10RP10[x]) / 2.0) && x < 45 ) { - if(y > 44) { - y = 44; - } - - correction = _25R10[y] - _25R10[x] ; - lbe = _25R10[y]; - correctL = true; - } else if ( (hue <= (_25R10[x] + _10RP10[x]) / 2.0) && (hue > (_10RP10[x] - 0.035) ) && x < 45) { - if(y > 44) { - y = 44; - } - - correction = _10RP10[y] - _10RP10[x] ; - lbe = _10RP10[y]; - correctL = true; - } - } else if (lum < 25.0) { - if( (hue <= (_5R20[x] + 0.035)) && (hue > (_5R20[x] + _25R20[x]) / 2.0) && x < 70 ) { - if(y > 70) { - y = 70; - } - - correction = _5R20[y] - _5R20[x] ; - lbe = _5R20[y]; - correctL = true; - } else if( (hue <= (_5R20[x] + _25R20[x]) / 2.0) && (hue > (_10RP20[x] + _25R20[x]) / 2.0) && x < 70) { - if(y > 70) { - y = 70; - } - - correction = _25R20[y] - _25R20[x] ; - lbe = _25R20[y]; - correctL = true; - } else if (( hue <= (_10RP20[x] + _25R20[x]) / 2.0) && (hue > (_10RP20[x] - 0.035)) && x < 70) { - if(y > 70) { - y = 70; - } - - correction = _10RP20[y] - _10RP20[x] ; - lbe = _10RP20[y]; - correctL = true; - } - } else if (lum < 35.0) { - if( (hue <= (_5R30[x] + 0.035)) && (hue > (_5R30[x] + _25R30[x]) / 2.0) && x < 85 ) { - if(y > 85) { - y = 85; - } - - correction = _5R30[y] - _5R30[x] ; - lbe = _5R30[y]; - correctL = true; - } else if( (hue <= (_5R30[x] + _25R30[x]) / 2.0) && (hue > (_10RP30[x] + _25R30[x]) / 2.0) && x < 85) { - if(y > 85) { - y = 85; - } - - correction = _25R30[y] - _25R30[x] ; - lbe = _25R30[y]; - correctL = true; - } else if (( hue <= (_10RP30[x] + _25R30[x]) / 2.0) && (hue > (_10RP30[x] - 0.035)) && x < 85) { - if(y > 85) { - y = 85; - } - - correction = _10RP30[y] - _10RP30[x] ; - lbe = _10RP30[y]; - correctL = true; - } - } - } - } - - //end red purple -} - - /* * SkinSat * Copyright (c)2011 Jacques Desmis diff --git a/rtengine/color.h b/rtengine/color.h index 211615de1..c8aa571d3 100644 --- a/rtengine/color.h +++ b/rtengine/color.h @@ -20,15 +20,16 @@ #pragma once #include -#include #include "rt_math.h" #include "LUT.h" -#include "iccmatrices.h" #include "lcms2.h" #include "sleef.h" -#define SAT(a,b,c) ((float)max(a,b,c)-(float)min(a,b,c))/(float)max(a,b,c) +namespace Glib +{ +class ustring; +} namespace rtengine { @@ -132,7 +133,7 @@ public: constexpr static double sRGBGammaCurve = 2.4; constexpr static double eps = 216.0 / 24389.0; //0.008856 - constexpr static double eps_max = MAXVALF * eps; //580.40756; + constexpr static double eps_max = MAXVALD * eps; //580.40756; constexpr static double kappa = 24389.0 / 27.0; //903.29630; constexpr static double kappaInv = 27.0 / 24389.0; constexpr static double epsilonExpInv3 = 6.0 / 29.0; @@ -144,9 +145,10 @@ public: constexpr static float D50x = 0.9642f; //0.96422; constexpr static float D50z = 0.8249f; //0.82521; - constexpr static double u0 = 4.0 * D50x / (D50x + 15 + 3 * D50z); - constexpr static double v0 = 9.0 / (D50x + 15 + 3 * D50z); + constexpr static double u0 = 4.0 * static_cast(D50x) / (static_cast(D50x) + 15 + 3 * static_cast(D50z)); + constexpr static double v0 = 9.0 / (static_cast(D50x) + 15 + 3 * static_cast(D50z)); constexpr static double epskap = 8.0; + constexpr static float epskapf = epskap; constexpr static float c1By116 = 1.0 / 116.0; constexpr static float c16By116 = 16.0 / 116.0; @@ -206,7 +208,7 @@ public: static float rgbLuminance(float r, float g, float b, const double workingspace[3][3]) { - return r * workingspace[1][0] + g * workingspace[1][1] + b * workingspace[1][2]; + return static_cast(r) * workingspace[1][0] + static_cast(g) * workingspace[1][1] + static_cast(b) * workingspace[1][2]; } #ifdef __SSE2__ @@ -972,10 +974,10 @@ public: template static inline T interpolatePolarHue_PI (T h1, T h2, U balance) { - float d = h2 - h1; - float f; + T d = h2 - h1; + T f; f = T(balance); - double h; + T h; if (h1 > h2) { std::swap(h1, h2); @@ -986,7 +988,7 @@ public: 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, T(1.)); } else { h = h1 + f * d; } diff --git a/rtengine/colortemp.cc b/rtengine/colortemp.cc index 02d3e0e6d..525ed339e 100644 --- a/rtengine/colortemp.cc +++ b/rtengine/colortemp.cc @@ -1071,10 +1071,10 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double Xwb, Zwb; temp2mulxyz(temp, method, Xwb, Zwb); - float adj = 1.f; + double adj = 1.0; if(equal < 0.9999 || equal > 1.0001 ) { - adj = (100.f + ( 1000.f - (1000.f * (float)equal) ) / 20.f) / 100.f; + adj = (100.0 + ( 1000.0 - (1000.0 * equal) ) / 20.0) / 100.0; } @@ -1389,7 +1389,7 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, } for(int i = 0; i < 8; i++) { - CRIs[i] = 100 - 3.0 * DeltaEs[i]; //3.0 coef to adapt ==> same results than CRI "official" + CRIs[i] = 100 - 3.f * DeltaEs[i]; //3.0 coef to adapt ==> same results than CRI "official" } for(int i = 0; i < 8; i++) { @@ -1409,7 +1409,7 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, } for(int i = 0; i < N_c; i++) { - CRI[i] = 100 - 3.0 * DeltaE[i]; //3.0 coef to adapt ==> same results than CRI "official" + CRI[i] = 100 - 3.f * DeltaE[i]; //3.0 coef to adapt ==> same results than CRI "official" } for(int i = 0; i < N_c; i++) { @@ -1425,8 +1425,8 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, quadCRI /= N_c; if(settings->CRI_color != 0) { - printf("CRI_standard=%i CRI:1->8=%i %i %i %i %i %i %i %i Sigma=%2.1f\n", (int) CRI_RTs, (int) CRIs[0], (int) CRIs[1], (int) CRIs[2], (int) CRIs[3], (int) CRIs[4], (int) CRIs[5], (int) CRIs[6], (int) CRIs[7], sqrt(quadCRIs)); - printf("CRI_RT_exten=%i CRI:9->20=%i %i %i %i %i %i %i %i %i %i %i %i Sigma=%2.1f\n", (int) CRI_RT, (int) CRI[8], (int) CRI[9], (int) CRI[10], (int) CRI[11], (int) CRI[12], (int) CRI[13], (int) CRI[14], (int) CRI[15], (int) CRI[16], (int) CRI[17], (int) CRI[18], (int) CRI[19], sqrt(quadCRI)); + printf("CRI_standard=%i CRI:1->8=%i %i %i %i %i %i %i %i Sigma=%2.1f\n", (int) CRI_RTs, (int) CRIs[0], (int) CRIs[1], (int) CRIs[2], (int) CRIs[3], (int) CRIs[4], (int) CRIs[5], (int) CRIs[6], (int) CRIs[7], sqrt(static_cast(quadCRIs))); + printf("CRI_RT_exten=%i CRI:9->20=%i %i %i %i %i %i %i %i %i %i %i %i Sigma=%2.1f\n", (int) CRI_RT, (int) CRI[8], (int) CRI[9], (int) CRI[10], (int) CRI[11], (int) CRI[12], (int) CRI[13], (int) CRI[14], (int) CRI[15], (int) CRI[16], (int) CRI[17], (int) CRI[18], (int) CRI[19], static_cast(sqrt(quadCRI))); } } } diff --git a/rtengine/curves.cc b/rtengine/curves.cc index b2105a091..a2b5d1d2b 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -21,8 +21,7 @@ #include #include #include -#include -#include +#include #include "rt_math.h" @@ -33,6 +32,7 @@ #include "opthelper.h" #include "ciecam02.h" #include "color.h" +#include "iccmatrices.h" #include "iccstore.h" using namespace std; @@ -2186,7 +2186,7 @@ void PerceptualToneCurve::init() } } -void PerceptualToneCurve::initApplyState(PerceptualToneCurveState & state, Glib::ustring workingSpace) const +void PerceptualToneCurve::initApplyState(PerceptualToneCurveState & state, const Glib::ustring &workingSpace) const { // Get the curve's contrast value, and convert to a chroma scaling diff --git a/rtengine/curves.h b/rtengine/curves.h index bc8193b76..c5bb0c18f 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -22,21 +22,23 @@ #include #include -#include - #include "rt_math.h" #include "flatcurvetypes.h" #include "diagonalcurvetypes.h" -#include "pipettebuffer.h" #include "noncopyable.h" #include "LUT.h" #include "sleef.h" #define CURVES_MIN_POLY_POINTS 1000 -#include "rt_math.h" - #define CLIPI(a) ((a)>0?((a)<65534?(a):65534):0) +namespace Glib +{ + +class ustring; + +} + using namespace std; namespace rtengine @@ -292,11 +294,11 @@ public: } static inline float gamma2 (float x) { - return x <= 0.00304 ? x * 12.92310 : 1.055 * expf(logf(x) / sRGBGammaCurve) - 0.055; + return x <= 0.00304f ? x * 12.92310f : 1.055f * expf(logf(x) / static_cast(sRGBGammaCurve)) - 0.055f; } static inline float igamma2 (float x) { - return x <= 0.03928 ? x / 12.92310 : expf(logf((x + 0.055) / 1.055) * sRGBGammaCurve); + return x <= 0.03928f ? x / 12.92310f : expf(logf((x + 0.055f) / 1.055f) * static_cast(sRGBGammaCurve)); } // gamma function with adjustable parameters static inline double gamma (double x, double gamma, double start, double slope, double mul, double add) @@ -327,8 +329,8 @@ public: #endif static inline float hlcurve (const float exp_scale, const float comp, const float hlrange, float level) { - if (comp > 0.0) { - float val = level + (hlrange - 65536.0); + if (comp > 0.f) { + float val = level + (hlrange - 65536.f); if(val == 0.0f) { // to avoid division by zero val = 0.000001f; @@ -337,7 +339,7 @@ public: float Y = val * exp_scale / hlrange; Y *= comp; - if(Y <= -1.0) { // to avoid log(<=0) + if(Y <= -1.f) { // to avoid log(<=0) Y = -.999999f; } @@ -454,7 +456,7 @@ public: virtual bool isIdentity () const = 0; }; -class DiagonalCurve : public Curve +class DiagonalCurve final : public Curve { protected: @@ -476,7 +478,7 @@ public: }; }; -class FlatCurve : public Curve, public rtengine::NonCopyable +class FlatCurve final : public Curve, public rtengine::NonCopyable { private: @@ -940,7 +942,7 @@ private: float calculateToneCurveContrastValue() const; public: static void init(); - void initApplyState(PerceptualToneCurveState & state, Glib::ustring workingSpace) const; + void initApplyState(PerceptualToneCurveState & state, const Glib::ustring& workingSpace) const; void BatchApply(const size_t start, const size_t end, float *r, float *g, float *b, const PerceptualToneCurveState &state) const; }; diff --git a/rtengine/dcp.cc b/rtengine/dcp.cc index 11fe306b8..89256bba4 100644 --- a/rtengine/dcp.cc +++ b/rtengine/dcp.cc @@ -1064,9 +1064,11 @@ void DCPProfile::apply( for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { + double temp = 0.0; for (int k = 0; k < 3; ++k) { - mat[i][j] += work_matrix[i][k] * xyz_cam[k][j]; + temp += work_matrix[i][k] * xyz_cam[k][j]; } + mat[i][j] = temp; } } @@ -1092,9 +1094,11 @@ void DCPProfile::apply( for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { + double temp = 0.0; for (int k = 0; k < 3; ++k) { - pro_photo[i][j] += prophoto_xyz[i][k] * xyz_cam[k][j]; + temp += prophoto_xyz[i][k] * xyz_cam[k][j]; } + pro_photo[i][j] = temp; } } @@ -1102,9 +1106,11 @@ void DCPProfile::apply( for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { + double temp = 0.0; for (int k = 0; k < 3; ++k) { - work[i][j] += work_matrix[i][k] * xyz_prophoto[k][j]; + temp += work_matrix[i][k] * xyz_prophoto[k][j]; } + work[i][j] = temp; } } @@ -1173,27 +1179,35 @@ void DCPProfile::setStep2ApplyState(const Glib::ustring& working_space, bool use mWork = ICCStore::getInstance()->workingSpaceMatrix (working_space); memset(as_out.data->pro_photo, 0, sizeof(as_out.data->pro_photo)); - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + double temp = 0.0; for (int k = 0; k < 3; k++) { - as_out.data->pro_photo[i][j] += prophoto_xyz[i][k] * mWork[k][j]; + temp += prophoto_xyz[i][k] * mWork[k][j]; } + as_out.data->pro_photo[i][j] = temp; + } + } mWork = ICCStore::getInstance()->workingSpaceInverseMatrix (working_space); memset(as_out.data->work, 0, sizeof(as_out.data->work)); - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + double temp = 0.0; for (int k = 0; k < 3; k++) { - as_out.data->work[i][j] += mWork[i][k] * xyz_prophoto[k][j]; + temp += mWork[i][k] * xyz_prophoto[k][j]; } + as_out.data->work[i][j] = temp; + } + } } } void DCPProfile::step2ApplyTile(float* rc, float* gc, float* bc, int width, int height, int tile_width, const DCPProfileApplyState& as_in) const { -#define FCLIP(a) ((a)>0.0?((a)<65535.5?(a):65535.5):0.0) +#define FCLIP(a) ((a)>0.f?((a)<65535.5f?(a):65535.5f):0.f) #define CLIP01(a) ((a)>0?((a)<1?(a):1):0) float exp_scale = as_in.data->bl_scale; diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index 812f122b3..0858bdaaa 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -1,6 +1,7 @@ #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wunused-macros" #if (__GNUC__ >= 6) #pragma GCC diagnostic ignored "-Wmisleading-indentation" #endif @@ -94,7 +95,6 @@ #ifdef WIN32 #include #include -#define snprintf _snprintf #define strcasecmp stricmp #define strncasecmp strnicmp typedef __int64 INT64; @@ -158,7 +158,6 @@ const float d65_white[3] = { 0.950456, 1, 1.088754 }; #define MIN(a,b) rtengine::min(a,static_cast<__typeof__(a)>(b)) #define MAX(a,b) rtengine::max(a,static_cast<__typeof__(a)>(b)) #define LIM(x,min,max) rtengine::LIM(x,static_cast<__typeof__(x)>(min),static_cast<__typeof__(x)>(max)) -#define ULIM(x,y,z) rtengine::median(x,static_cast<__typeof__(x)>(y),static_cast<__typeof__(x)>(z)) #define CLIP(x) rtengine::CLIP(x) #define SWAP(a,b) { a=a+b; b=a-b; a=a-b; } @@ -9868,6 +9867,7 @@ void CLASS identify() filters = 0; tiff_samples = colors = 3; load_raw = &CLASS canon_sraw_load_raw; + FORC4 cblack[c] = 0; // ALB } else if (!strcmp(model,"PowerShot 600")) { height = 613; width = 854; @@ -11021,7 +11021,6 @@ void CLASS nikon_14bit_load_raw() /*RT*/#undef MIN /*RT*/#undef ABS /*RT*/#undef LIM -/*RT*/#undef ULIM /*RT*/#undef CLIP #ifdef __GNUC__ #pragma GCC diagnostic pop diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 1cacdb486..b9594a709 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -24,6 +24,7 @@ #include "dcrop.h" #include "image8.h" #include "imagefloat.h" +#include "improccoordinator.h" #include "labimage.h" #include "mytime.h" #include "procparams.h" diff --git a/rtengine/dcrop.h b/rtengine/dcrop.h index c65c1e72f..0b33854c5 100644 --- a/rtengine/dcrop.h +++ b/rtengine/dcrop.h @@ -18,11 +18,7 @@ */ #pragma once -#include "improccoordinator.h" #include "rtengine.h" -#include "improcfun.h" -#include "imagesource.h" -#include "procevents.h" #include "pipettebuffer.h" #include "../rtgui/threadutils.h" @@ -30,12 +26,13 @@ namespace rtengine { class Image8; +class CieImage; using namespace procparams; class ImProcCoordinator; -class Crop : public DetailedCrop, public PipetteBuffer +class Crop final : public DetailedCrop, public PipetteBuffer { protected: diff --git a/rtengine/demosaic_algos.cc b/rtengine/demosaic_algos.cc index 538858a9a..a31415968 100644 --- a/rtengine/demosaic_algos.cc +++ b/rtengine/demosaic_algos.cc @@ -1069,7 +1069,7 @@ void RawImageSource::dcb_hid(float (*image)[3], int x0, int y0) for (int col = colMin + (FC(y0 - TILEBORDER + row, x0 - TILEBORDER + colMin) & 1), indx = row * CACHESIZE + col; col < colMax; col += 2, indx += 2) { assert(indx - u - 1 >= 0 && indx + u + 1 < u * u); - image[indx][1] = 0.25*(image[indx-1][1]+image[indx+1][1]+image[indx-u][1]+image[indx+u][1]); + image[indx][1] = 0.25f * (image[indx-1][1]+image[indx+1][1]+image[indx-u][1]+image[indx+u][1]); } } diff --git a/rtengine/dfmanager.cc b/rtengine/dfmanager.cc index 1fb1d2e1b..6961a4b54 100644 --- a/rtengine/dfmanager.cc +++ b/rtengine/dfmanager.cc @@ -476,7 +476,7 @@ dfInfo* DFManager::find( const std::string &mak, const std::string &mod, int iso } } - return bestD != INFINITY ? &(bestMatch->second) : nullptr ; + return bestD != RT_INFINITY ? &(bestMatch->second) : nullptr ; } } diff --git a/rtengine/dfmanager.h b/rtengine/dfmanager.h index 216dcfc53..b23981ffb 100644 --- a/rtengine/dfmanager.h +++ b/rtengine/dfmanager.h @@ -31,7 +31,7 @@ namespace rtengine { class RawImage; -class dfInfo +class dfInfo final { public: @@ -74,7 +74,7 @@ protected: void updateRawImage(); }; -class DFManager +class DFManager final { public: void init(const Glib::ustring &pathname); diff --git a/rtengine/diagonalcurves.cc b/rtengine/diagonalcurves.cc index bb20b7cc1..622683ea2 100644 --- a/rtengine/diagonalcurves.cc +++ b/rtengine/diagonalcurves.cc @@ -16,8 +16,6 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#include -#include #include "curves.h" #include #include @@ -65,23 +63,23 @@ DiagonalCurve::DiagonalCurve (const std::vector& p, int poly_pn) } } - if (x[0] != 0.0f || x[N - 1] != 1.0f) + if (x[0] != 0.0 || x[N - 1] != 1.0) // Special (and very rare) case where all points are on the identity line but // not reaching the limits { identity = false; } - if(x[0] == 0.f && x[1] == 0.f) + if(x[0] == 0.0 && x[1] == 0.0) // Avoid crash when first two points are at x = 0 (git Issue 2888) { - x[1] = 0.01f; + x[1] = 0.01; } - if(x[0] == 1.f && x[1] == 1.f) + if(x[0] == 1.0 && x[1] == 1.0) // Avoid crash when first two points are at x = 1 (100 in gui) (git Issue 2923) { - x[0] = 0.99f; + x[0] = 0.99; } if (!identity) { @@ -97,7 +95,7 @@ DiagonalCurve::DiagonalCurve (const std::vector& p, int poly_pn) } } } else if (kind == DCT_Parametric) { - if ((p.size() == 8 || p.size() == 9) && (p.at(4) != 0.0f || p.at(5) != 0.0f || p.at(6) != 0.0f || p.at(7) != 0.0f)) { + if ((p.size() == 8 || p.size() == 9) && (p.at(4) != 0.0 || p.at(5) != 0.0 || p.at(6) != 0.0 || p.at(7) != 0.0)) { identity = false; x = new double[9]; diff --git a/rtengine/dirpyr_equalizer.cc b/rtengine/dirpyr_equalizer.cc index 1f62badcb..0624f4443 100644 --- a/rtengine/dirpyr_equalizer.cc +++ b/rtengine/dirpyr_equalizer.cc @@ -228,11 +228,11 @@ void fillLut(LUTf &irangefn, int level, double dirpyrThreshold, float mult, floa } const float offs = skinprot == 0.f ? 0.f : -1.f; - constexpr float noise = 2000.f; - const float noisehi = 1.33f * noise * dirpyrThreshold / expf(level * log(3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf(level * log(3.0)); + constexpr double noise = 2000.0; + const float noisehi = 1.33 * noise * dirpyrThreshold / exp(level * log(3.0)), noiselo = 0.66 * noise * dirpyrThreshold / exp(level * log(3.0)); for (int i = 0; i < 0x20000; i++) { - if (abs(i - 0x10000) > noisehi || multbis < 1.0) { + if (abs(i - 0x10000) > noisehi || multbis < 1.f) { irangefn[i] = multbis + offs; } else { if (abs(i - 0x10000) < noiselo) { @@ -262,7 +262,7 @@ void idirpyr_eq_channel(const float * const * data_coarse, const float * const * buffer[i][j] += irangefn[hipass + 0x10000] * hipass; } } - } else if (skinprot > 0.f) { + } else if (skinprot > 0.0) { #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif @@ -314,7 +314,7 @@ void idirpyr_eq_channelcam(const float * const * data_coarse, const float * cons buffer[i][j] += irangefn[hipass + 0x10000] * hipass; } } - } else if (skinprot > 0.f) { + } else if (skinprot > 0.0) { #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif diff --git a/rtengine/dual_demosaic_RT.cc b/rtengine/dual_demosaic_RT.cc index 93508808c..253468a76 100644 --- a/rtengine/dual_demosaic_RT.cc +++ b/rtengine/dual_demosaic_RT.cc @@ -45,7 +45,7 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams { BENCHFUN - if (contrast == 0.f && !autoContrast) { + if (contrast == 0.0 && !autoContrast) { // contrast == 0.0 means only first demosaicer will be used if(isBayer) { if (raw.bayersensor.method == procparams::RAWParams::BayerSensor::getMethodString(procparams::RAWParams::BayerSensor::Method::AMAZEVNG4) ) { @@ -103,7 +103,7 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams } // calculate contrast based blend factors to use vng4 in regions with low contrast JaggedArray blend(winw, winh); - float contrastf = contrast / 100.f; + float contrastf = contrast / 100.0; buildBlendMask(L, blend, winw, winh, contrastf, autoContrast); contrast = contrastf * 100.f; diff --git a/rtengine/ffmanager.cc b/rtengine/ffmanager.cc index ce60277e1..c55bc5108 100644 --- a/rtengine/ffmanager.cc +++ b/rtengine/ffmanager.cc @@ -428,7 +428,7 @@ ffInfo* FFManager::find( const std::string &mak, const std::string &mod, const s } } - return bestD != INFINITY ? &(bestMatch->second) : nullptr ; + return bestD != RT_INFINITY ? &(bestMatch->second) : nullptr ; } } diff --git a/rtengine/ffmanager.h b/rtengine/ffmanager.h index 80ef5fa1c..f3303f12b 100644 --- a/rtengine/ffmanager.h +++ b/rtengine/ffmanager.h @@ -29,7 +29,7 @@ namespace rtengine { class RawImage; -class ffInfo +class ffInfo final { public: @@ -71,7 +71,7 @@ protected: void updateRawImage(); }; -class FFManager +class FFManager final { public: void init(const Glib::ustring &pathname); diff --git a/rtengine/filmnegativeproc.cc b/rtengine/filmnegativeproc.cc index 1f27983ed..c7de3c483 100644 --- a/rtengine/filmnegativeproc.cc +++ b/rtengine/filmnegativeproc.cc @@ -122,8 +122,8 @@ bool rtengine::RawImageSource::getFilmNegativeExponents(Coord2D spotA, Coord2D s } if (settings->verbose) { - printf("Clear film values: R=%g G=%g B=%g\n", clearVals[0], clearVals[1], clearVals[2]); - printf("Dense film values: R=%g G=%g B=%g\n", denseVals[0], denseVals[1], denseVals[2]); + printf("Clear film values: R=%g G=%g B=%g\n", static_cast(clearVals[0]), static_cast(clearVals[1]), static_cast(clearVals[2])); + printf("Dense film values: R=%g G=%g B=%g\n", static_cast(denseVals[0]), static_cast(denseVals[1]), static_cast(denseVals[2])); } const float denseGreenRatio = clearVals[1] / denseVals[1]; @@ -141,12 +141,12 @@ bool rtengine::RawImageSource::getFilmNegativeExponents(Coord2D spotA, Coord2D s if (ch == 1) { newExps[ch] = 1.f; // Green is the reference channel } else { - newExps[ch] = CLAMP(logBase(clearVals[ch] / denseVals[ch], denseGreenRatio), 0.3f, 4.f); + newExps[ch] = rtengine::LIM(logBase(clearVals[ch] / denseVals[ch], denseGreenRatio), 0.3f, 4.f); } } if (settings->verbose) { - printf("New exponents: R=%g G=%g B=%g\n", newExps[0], newExps[1], newExps[2]); + printf("New exponents: R=%g G=%g B=%g\n", static_cast(newExps[0]), static_cast(newExps[1]), static_cast(newExps[2])); } return true; @@ -246,8 +246,8 @@ void rtengine::RawImageSource::filmNegativeProcess(const procparams::FilmNegativ if (settings->verbose) { printf("Sample count: %zu, %zu, %zu\n", cvs[0].size(), cvs[1].size(), cvs[2].size()); - printf("Medians: %g %g %g\n", medians[0], medians[1], medians[2] ); - printf("Computed multipliers: %g %g %g\n", mults[0], mults[1], mults[2] ); + printf("Medians: %g %g %g\n", static_cast(medians[0]), static_cast(medians[1]), static_cast(medians[2])); + printf("Computed multipliers: %g %g %g\n", static_cast(mults[0]), static_cast(mults[1]), static_cast(mults[2])); printf("Median calc time us: %d\n", t3.etime(t2)); } diff --git a/rtengine/filmnegativethumb.cc b/rtengine/filmnegativethumb.cc index b31432a55..003fab8e0 100644 --- a/rtengine/filmnegativethumb.cc +++ b/rtengine/filmnegativethumb.cc @@ -89,8 +89,8 @@ void rtengine::Thumbnail::processFilmNegative( const float bmult = (MAX_OUT_VALUE / (bmed * 24)) ; if (settings->verbose) { - printf("Thumbnail channel medians: %g %g %g\n", rmed, gmed, bmed); - printf("Thumbnail computed multipliers: %g %g %g\n", rmult, gmult, bmult); + printf("Thumbnail channel medians: %g %g %g\n", static_cast(rmed), static_cast(gmed), static_cast(bmed)); + printf("Thumbnail computed multipliers: %g %g %g\n", static_cast(rmult), static_cast(gmult), static_cast(bmult)); } #ifdef __SSE2__ diff --git a/rtengine/green_equil_RT.cc b/rtengine/green_equil_RT.cc index fc4f18548..a66bca160 100644 --- a/rtengine/green_equil_RT.cc +++ b/rtengine/green_equil_RT.cc @@ -47,7 +47,7 @@ void RawImageSource::green_equilibrate_global(array2D &rawData) for (int i = border; i < H - border; i++) { double avgg = 0.; for (int j = border + ((FC(i, border) & 1) ^ 1); j < W - border; j += 2) { - avgg += rawData[i][j]; + avgg += static_cast(rawData[i][j]); } int ng = (W - 2 * border + (FC(i, border) & 1)) / 2; @@ -71,15 +71,15 @@ void RawImageSource::green_equilibrate_global(array2D &rawData) avgg2 = 1.0; } - double corrg1 = (avgg1 / ng1 + avgg2 / ng2) / 2.0 / (avgg1 / ng1); - double corrg2 = (avgg1 / ng1 + avgg2 / ng2) / 2.0 / (avgg2 / ng2); + const float corrg1 = (avgg1 / ng1 + avgg2 / ng2) / 2.0 / (avgg1 / ng1); + const float corrg2 = (avgg1 / ng1 + avgg2 / ng2) / 2.0 / (avgg2 / ng2); #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif for (int i = border; i < H - border; i++) { - double corrg = (i & 1) ? corrg2 : corrg1; + const float corrg = (i & 1) ? corrg2 : corrg1; for (int j = border + ((FC(i, border) & 1) ^ 1); j < W - border; j += 2) { rawData[i][j] *= corrg; @@ -220,7 +220,7 @@ void RawImageSource::green_equilibrate(const GreenEqulibrateThreshold &thresh, a float tf = thresh(rr, cc); - if (c1 + c2 < 6 * tf * fabs(d1 - d2)) { + if (c1 + c2 < 6 * tf * std::fabs(d1 - d2)) { //pixel interpolation float gin = cfa[rr][cc >> 1]; diff --git a/rtengine/guidedfilter.cc b/rtengine/guidedfilter.cc index ad3beec51..f83560cfc 100644 --- a/rtengine/guidedfilter.cc +++ b/rtengine/guidedfilter.cc @@ -29,6 +29,7 @@ * available at https://arxiv.org/abs/1505.00996 */ +#include "array2D.h" #include "boxblur.h" #include "guidedfilter.h" #include "imagefloat.h" diff --git a/rtengine/hilite_recon.cc b/rtengine/hilite_recon.cc index 697a5e3d3..1ba42a68b 100644 --- a/rtengine/hilite_recon.cc +++ b/rtengine/hilite_recon.cc @@ -323,7 +323,7 @@ void RawImageSource::HLRecovery_inpaint(float** red, float** green, float** blue if (settings->verbose) { for (int c = 0; c < 3; ++c) { - printf("chmax[%d] : %f\tclmax[%d] : %f\tratio[%d] : %f\n", c, chmax[c], c, clmax[c], c, chmax[c] / clmax[c]); + printf("chmax[%d] : %f\tclmax[%d] : %f\tratio[%d] : %f\n", c, static_cast(chmax[c]), c, static_cast(clmax[c]), c, static_cast(chmax[c] / clmax[c])); } } @@ -366,7 +366,7 @@ void RawImageSource::HLRecovery_inpaint(float** red, float** green, float** blue if (settings->verbose) { for (int c = 0; c < 3; ++c) { - printf("correction factor[%d] : %f\n", c, factor[c]); + printf("correction factor[%d] : %f\n", c, static_cast(factor[c])); } } @@ -496,7 +496,7 @@ void RawImageSource::HLRecovery_inpaint(float** red, float** green, float** blue && blue[i + miny][j + minx] < max_f[2] ) { // if one or more channels is highlight but none are blown, add to highlight accumulator - hipass_sum += channelblur[0][i][j]; + hipass_sum += static_cast(channelblur[0][i][j]); ++hipass_norm; hilite_full[0][i][j] = red[i + miny][j + minx]; @@ -507,7 +507,7 @@ void RawImageSource::HLRecovery_inpaint(float** red, float** green, float** blue } } - const float hipass_ave = 2.f * hipass_sum / (hipass_norm + epsilon); + const float hipass_ave = 2.0 * hipass_sum / (hipass_norm + static_cast(epsilon)); if (plistener) { progress += 0.05; diff --git a/rtengine/histmatching.cc b/rtengine/histmatching.cc index f5d16866e..0053cb0d4 100644 --- a/rtengine/histmatching.cc +++ b/rtengine/histmatching.cc @@ -179,7 +179,7 @@ void mappingToCurve(const std::vector &mapping, std::vector &curve) }; idx = -1; for (ssize_t i = curve.size()-1; i > 0; i -= 2) { - if (curve[i] <= 0.f) { + if (curve[i] <= 0.0) { idx = i+1; break; } @@ -328,7 +328,7 @@ void RawImageSource::getAutoMatchedToneCurve(const ColorManagementParams &cp, st int tw = target->getWidth(), th = target->getHeight(); float thumb_ratio = float(std::max(sw, sh)) / float(std::min(sw, sh)); float target_ratio = float(std::max(tw, th)) / float(std::min(tw, th)); - if (std::abs(thumb_ratio - target_ratio) > 0.01) { + if (std::abs(thumb_ratio - target_ratio) > 0.01f) { int cx = 0, cy = 0; if (thumb_ratio > target_ratio) { // crop the height @@ -342,7 +342,7 @@ void RawImageSource::getAutoMatchedToneCurve(const ColorManagementParams &cp, st tw -= cw; } if (settings->verbose) { - std::cout << "histogram matching: cropping target to get an aspect ratio of " << round(thumb_ratio * 100)/100.0 << ":1, new size is " << tw << "x" << th << std::endl; + std::cout << "histogram matching: cropping target to get an aspect ratio of " << round(thumb_ratio * 100)/100.f << ":1, new size is " << tw << "x" << th << std::endl; } if (cx || cy) { diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index aea03664e..9d7024bff 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -43,7 +43,6 @@ #include "color.h" #include "cJSON.h" -#define inkc_constant 0x696E6B43 namespace { diff --git a/rtengine/iccstore.h b/rtengine/iccstore.h index 731a155bb..117124122 100644 --- a/rtengine/iccstore.h +++ b/rtengine/iccstore.h @@ -39,7 +39,7 @@ namespace procparams typedef const double(*TMatrix)[3]; -class ProfileContent +class ProfileContent final { public: ProfileContent(); @@ -54,7 +54,7 @@ private: std::string data; }; -class ICCStore +class ICCStore final { public: enum class ProfileType { diff --git a/rtengine/iimage.h b/rtengine/iimage.h index 7309dd91f..247d0cdaa 100644 --- a/rtengine/iimage.h +++ b/rtengine/iimage.h @@ -20,7 +20,6 @@ #include -#include #include #include "alignedbuffer.h" @@ -41,6 +40,13 @@ #define CHECK_BOUNDS 0 +namespace Glib +{ + +class ustring; + +} + namespace rtengine { @@ -658,7 +664,7 @@ public: /* If any of the required allocation fails, "width" and "height" are set to -1, and all remaining buffer are freed * Can be safely used to reallocate an existing image */ - void allocate (int W, int H) override + void allocate (int W, int H) final { if (W == width && H == height) { @@ -746,7 +752,7 @@ public: } } - void rotate (int deg) override + void rotate (int deg) final { if (deg == 90) { @@ -873,7 +879,7 @@ public: } } - void hflip () override + void hflip () final { int width2 = width / 2; @@ -905,7 +911,7 @@ public: #endif } - void vflip () override + void vflip () final { int height2 = height / 2; @@ -989,7 +995,7 @@ public: } } - void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, const int compression) const override + void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, const int compression) const final { histogram.clear(); avg_r = avg_g = avg_b = 0.; @@ -1328,7 +1334,7 @@ public: * If any of the required allocation fails, "width" and "height" are set to -1, and all remaining buffer are freed * Can be safely used to reallocate an existing image or to free up it's memory with "allocate (0,0);" */ - void allocate (int W, int H) override + void allocate (int W, int H) final { if (W == width && H == height) { @@ -1382,7 +1388,7 @@ public: memcpy (dest->data, data, 3 * width * height * sizeof(T)); } - void rotate (int deg) override + void rotate (int deg) final { if (deg == 90) { @@ -1516,7 +1522,7 @@ public: } } - void hflip () override + void hflip () final { int width2 = width / 2; @@ -1552,7 +1558,7 @@ public: } } - void vflip () override + void vflip () final { AlignedBuffer lBuffer(3 * width); @@ -1619,7 +1625,7 @@ public: } } - void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, const int compression) const override + void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, const int compression) const final { histogram.clear(); avg_r = avg_g = avg_b = 0.; diff --git a/rtengine/image16.cc b/rtengine/image16.cc index a98d64d51..07fc66fad 100644 --- a/rtengine/image16.cc +++ b/rtengine/image16.cc @@ -147,10 +147,10 @@ void Image16::getStdImage(const ColorTemp &ctemp, int tran, Imagefloat* image, P gm = dgm; bm = dbm; - rm = 1.0 / rm; - gm = 1.0 / gm; - bm = 1.0 / bm; - float mul_lum = 0.299 * rm + 0.587 * gm + 0.114 * bm; + rm = 1.f / rm; + gm = 1.f / gm; + bm = 1.f / bm; + float mul_lum = 0.299f * rm + 0.587f * gm + 0.114f * bm; rm /= mul_lum; gm /= mul_lum; bm /= mul_lum; @@ -187,8 +187,6 @@ void Image16::getStdImage(const ColorTemp &ctemp, int tran, Imagefloat* image, P gm /= area; bm /= area; -#define GCLIP( x ) Color::gamma_srgb(CLIP(x)) - #ifdef _OPENMP #pragma omp parallel { diff --git a/rtengine/image16.h b/rtengine/image16.h index d0053cbfc..de9288f2d 100644 --- a/rtengine/image16.h +++ b/rtengine/image16.h @@ -29,7 +29,7 @@ namespace rtengine class Image8; class Imagefloat; -class Image16 : public IImage16, public ImageIO +class Image16 final : public IImage16, public ImageIO { public: diff --git a/rtengine/image8.cc b/rtengine/image8.cc index 66ad8b60f..67b38d0c1 100644 --- a/rtengine/image8.cc +++ b/rtengine/image8.cc @@ -111,10 +111,10 @@ void Image8::getStdImage (const ColorTemp &ctemp, int tran, Imagefloat* image, P gm = dgm; bm = dbm; - rm = 1.0 / rm; - gm = 1.0 / gm; - bm = 1.0 / bm; - float mul_lum = 0.299 * rm + 0.587 * gm + 0.114 * bm; + rm = 1.f / rm; + gm = 1.f / gm; + bm = 1.f / bm; + float mul_lum = 0.299f * rm + 0.587f * gm + 0.114f * bm; rm /= mul_lum; gm /= mul_lum; bm /= mul_lum; @@ -151,8 +151,6 @@ void Image8::getStdImage (const ColorTemp &ctemp, int tran, Imagefloat* image, P gm /= area; bm /= area; -#define GCLIP( x ) Color::gamma_srgb(CLIP(x)) - #ifdef _OPENMP #pragma omp parallel { diff --git a/rtengine/image8.h b/rtengine/image8.h index f125dccf8..c11d9d7fc 100644 --- a/rtengine/image8.h +++ b/rtengine/image8.h @@ -27,7 +27,7 @@ namespace rtengine { class Imagefloat; -class Image8 : public IImage8, public ImageIO +class Image8 final : public IImage8, public ImageIO { public: diff --git a/rtengine/imagedata.cc b/rtengine/imagedata.cc index 24cfefde9..a631a6c8d 100644 --- a/rtengine/imagedata.cc +++ b/rtengine/imagedata.cc @@ -502,11 +502,11 @@ FrameData::FrameData(rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* } else if (!make.compare (0, 6, "PENTAX") || (!make.compare (0, 5, "RICOH") && !model.compare (0, 6, "PENTAX"))) { // ISO at max value supported, check manufacturer specific if (iso_speed == 65535 || iso_speed == 0) { - rtexif::Tag* baseIsoTag = mnote->getTag("ISO"); + const rtexif::Tag* const baseIsoTag = mnote->getTag("ISO"); if (baseIsoTag) { - std::string isoData = baseIsoTag->valueToString(); + const std::string isoData = baseIsoTag->valueToString(); if (isoData.size() > 1) { - iso_speed = stoi(isoData); + iso_speed = std::stoi(isoData); } } } diff --git a/rtengine/imagedata.h b/rtengine/imagedata.h index ff8ed4b86..4bf9bdf5b 100644 --- a/rtengine/imagedata.h +++ b/rtengine/imagedata.h @@ -23,12 +23,18 @@ #include #include -#include #include #include "imageio.h" +namespace Glib +{ + +class ustring; + +} + namespace rtexif { @@ -38,7 +44,7 @@ class TagDirectory; namespace rtengine { -class FrameData +class FrameData final { protected: @@ -95,7 +101,7 @@ public: int getRating () const; }; -class FramesData : public FramesMetaData { +class FramesData final : public FramesMetaData { private: // frame's root IFD, can be a file root IFD or a SUB-IFD std::vector> frames; diff --git a/rtengine/imagefloat.cc b/rtengine/imagefloat.cc index 1da91a4b4..f905134a0 100644 --- a/rtengine/imagefloat.cc +++ b/rtengine/imagefloat.cc @@ -178,10 +178,10 @@ void Imagefloat::getStdImage (const ColorTemp &ctemp, int tran, Imagefloat* imag gm = dgm; bm = dbm; - rm = 1.0 / rm; - gm = 1.0 / gm; - bm = 1.0 / bm; - float mul_lum = 0.299 * rm + 0.587 * gm + 0.114 * bm; + rm = 1.f / rm; + gm = 1.f / gm; + bm = 1.f / bm; + float mul_lum = 0.299f * rm + 0.587f * gm + 0.114f * bm; rm /= mul_lum; gm /= mul_lum; bm /= mul_lum; @@ -368,7 +368,7 @@ Imagefloat::to16() const void Imagefloat::normalizeFloat(float srcMinVal, float srcMaxVal) { - float scale = MAXVALD / (srcMaxVal - srcMinVal); + float scale = MAXVALF / (srcMaxVal - srcMinVal); int w = width; int h = height; diff --git a/rtengine/imagefloat.h b/rtengine/imagefloat.h index 4a2b2f7e1..cd08daf70 100644 --- a/rtengine/imagefloat.h +++ b/rtengine/imagefloat.h @@ -34,7 +34,7 @@ class LabImage; /* * Image type used by most tools; expected range: [0.0 ; 65535.0] */ -class Imagefloat : public IImagefloat, public ImageIO +class Imagefloat final : public IImagefloat, public ImageIO { public: diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index e0c26aa9f..96711c1a0 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -25,7 +25,6 @@ #include "coord2d.h" #include "imagedata.h" -#include "LUT.h" #include "rtengine.h" template @@ -86,7 +85,7 @@ protected: public: ImageSource () : references (1), redAWBMul(-1.), greenAWBMul(-1.), blueAWBMul(-1.), - embProfile(nullptr), idata(nullptr), dirpyrdenoiseExpComp(INFINITY) {} + embProfile(nullptr), idata(nullptr), dirpyrdenoiseExpComp(RT_INFINITY) {} ~ImageSource () override {} virtual int load (const Glib::ustring &fname) = 0; @@ -143,11 +142,11 @@ public: virtual void setProgressListener (ProgressListener* pl) {} - void increaseRef () override + void increaseRef () final { references++; } - void decreaseRef () override + void decreaseRef () final { references--; @@ -175,15 +174,15 @@ public: return dirpyrdenoiseExpComp; } // functions inherited from the InitialImage interface - Glib::ustring getFileName () override + Glib::ustring getFileName () final { return fileName; } - cmsHPROFILE getEmbeddedProfile () override + cmsHPROFILE getEmbeddedProfile () final { return embProfile; } - const FramesMetaData* getMetaData () override + const FramesMetaData* getMetaData () final { return idata; } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index f5015cd73..82dfddb81 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -744,7 +744,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) if (params->blackwhite.enabled && params->blackwhite.autoc && abwListener) { if (settings->verbose) { - printf("ImProcCoordinator / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", bwAutoR, bwAutoG, bwAutoB); + printf("ImProcCoordinator / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", static_cast(bwAutoR), static_cast(bwAutoG), static_cast(bwAutoB)); } abwListener->BWChanged((float) rrm, (float) ggm, (float) bbm); @@ -1086,7 +1086,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) double E_V = fcomp + log2(double ((fnum * fnum) / fspeed / (fiso / 100.f))); E_V += params->toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV E_V += log2(params->raw.expos); // exposure raw white point ; log2 ==> linear to EV - adap = powf(2.f, E_V - 3.f); // cd / m2 + adap = pow(2.0, E_V - 3.0); // cd / m2 // end calculation adaptation scene luminosity } diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index 96d1f80ce..37318c64b 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -27,7 +27,6 @@ #include "imagesource.h" #include "improcfun.h" #include "LUT.h" -#include "procevents.h" #include "rtengine.h" #include "../rtgui/threadutils.h" @@ -55,7 +54,7 @@ class Crop; * but using this class' LUT and other precomputed parameters. The main preview area is displaying a non framed Crop object, * while detail windows are framed Crop objects. */ -class ImProcCoordinator : public StagedImageProcessor +class ImProcCoordinator final : public StagedImageProcessor { friend class Crop; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 10962b7f9..9fe16769c 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -31,15 +31,16 @@ #include "cieimage.h" #include "clutstore.h" #include "color.h" +#include "colortemp.h" #include "curves.h" #include "dcp.h" #include "EdgePreservingDecomposition.h" #include "iccmatrices.h" #include "iccstore.h" #include "imagesource.h" -#include "improccoordinator.h" #include "improcfun.h" #include "labimage.h" +#include "pipettebuffer.h" #include "procparams.h" #include "rt_math.h" #include "rtengine.h" @@ -54,9 +55,6 @@ #include "mytime.h" #endif -#undef CLIPD -#define CLIPD(a) ((a)>0.0f?((a)<1.0f?(a):1.0f):0.0f) - namespace { using namespace rtengine; @@ -137,7 +135,7 @@ void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, flo float b = btemp[ti * tileSize + tj + k]; float tonefactor = ((r < MAXVALF ? hltonecurve[r] : CurveFactory::hlcurve(exp_scale, comp, hlrange, r)) + (g < MAXVALF ? hltonecurve[g] : CurveFactory::hlcurve(exp_scale, comp, hlrange, g)) + - (b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve(exp_scale, comp, hlrange, b))) / 3.0; + (b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve(exp_scale, comp, hlrange, b))) / 3.f; // note: tonefactor includes exposure scaling, that is here exposure slider and highlight compression takes place rtemp[ti * tileSize + tj + k] = r * tonefactor; @@ -165,7 +163,7 @@ void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, flo //float tonefactor = hltonecurve[(0.299f*r+0.587f*g+0.114f*b)]; float tonefactor = ((r < MAXVALF ? hltonecurve[r] : CurveFactory::hlcurve(exp_scale, comp, hlrange, r)) + (g < MAXVALF ? hltonecurve[g] : CurveFactory::hlcurve(exp_scale, comp, hlrange, g)) + - (b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve(exp_scale, comp, hlrange, b))) / 3.0; + (b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve(exp_scale, comp, hlrange, b))) / 3.f; // note: tonefactor includes exposure scaling, that is here exposure slider and highlight compression takes place rtemp[ti * tileSize + tj] = r * tonefactor; @@ -518,8 +516,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw int width = lab->W, height = lab->H; float minQ = 10000.f; float maxQ = -1000.f; - float Yw; - Yw = 1.0; + double Yw = 1.0; double Xw, Zw; float f = 0.f, nc = 0.f, la, c = 0.f, xw, yw, zw, f2 = 1.f, c2 = 1.f, nc2 = 1.f, yb2; float fl, n, nbb, ncb, aw; //d @@ -596,13 +593,13 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw algepd = true; } - xwd = 100.f * Xwout; - zwd = 100.f * Zwout; - ywd = 100.f / params->colorappearance.greenout;//approximation to simplify + xwd = 100.0 * Xwout; + zwd = 100.0 * Zwout; + ywd = 100.0 / params->colorappearance.greenout;//approximation to simplify - xws = 100.f * Xwsc; - zws = 100.f * Zwsc; - yws = 100.f / params->colorappearance.greensc;//approximation to simplify + xws = 100.0 * Xwsc; + zws = 100.0 * Zwsc; + yws = 100.0 / params->colorappearance.greensc;//approximation to simplify /* @@ -699,20 +696,20 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw if (alg == 3 || alg == 1) { schr = params->colorappearance.schroma; - if (schr > 0.0) { - schr = schr / 2.0f; //divide sensibility for saturation + if (schr > 0.f) { + schr = schr / 2.f; //divide sensibility for saturation } if (alg == 3) { - if (schr == -100.0f) { + if (schr == -100.f) { schr = -99.f; } - if (schr == 100.0f) { + if (schr == 100.f) { schr = 98.f; } } else { - if (schr == -100.0f) { + if (schr == -100.f) { schr = -99.8f; } } @@ -751,7 +748,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw LUTu hist16J; LUTu hist16Q; - if ((needJ && CAMBrightCurveJ.dirty) || (needQ && CAMBrightCurveQ.dirty) || (std::isnan (mean) && settings->viewinggreySc != 0)) { + if ((needJ && CAMBrightCurveJ.dirty) || (needQ && CAMBrightCurveQ.dirty) || (std::isnan(mean) && settings->viewinggreySc != 0)) { if (needJ) { hist16J (32768); @@ -788,7 +785,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw #endif - for (int i = 0; i < height; i++) + for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { //rough correspondence between L and J float currL = lab->L[i][j] / 327.68f; float koef; //rough correspondence between L and J @@ -849,10 +846,11 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw //hist16Qthr[ (int) (sqrtf ((koef * (lab->L[i][j])) * 32768.f))]++; //for brightness Q : approximation for Q=wh*sqrt(J/100) J not equal L } - sum += koef * lab->L[i][j]; //evaluate mean J to calculate Yb + sum += static_cast(koef) * static_cast(lab->L[i][j]); //evaluate mean J to calculate Yb //sumQ += whestim * sqrt ((koef * (lab->L[i][j])) / 32768.f); //can be used in case of... } + } #ifdef _OPENMP #pragma omp critical @@ -868,8 +866,8 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw } - if (std::isnan (mean)) { - mean = (sum / ((height) * width)) / 327.68f; //for Yb for all image...if one day "pipette" we can adapt Yb for each zone + if (std::isnan(mean)) { + mean = (sum / ((height) * width)) / 327.68; //for Yb for all image...if one day "pipette" we can adapt Yb for each zone } } #ifdef _OPENMP @@ -916,9 +914,9 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw const bool highlight = params->toneCurve.hrenabled; //Get the value if "highlight reconstruction" is activated const int gamu = (params->colorappearance.gamut) ? 1 : 0; - xw = 100.0f * Xw; - yw = 100.0f * Yw; - zw = 100.0f * Zw; + xw = 100.0 * Xw; + yw = 100.0 * Yw; + zw = 100.0 * Zw; float xw1 = 0.f, yw1 = 0.f, zw1 = 0.f, xw2 = 0.f, yw2 = 0.f, zw2 = 0.f; // settings of WB: scene and viewing @@ -2002,9 +2000,9 @@ void ImProcFunctions::moyeqt (Imagefloat* working, float &moyS, float &eqty) for (int i = 0; i < tHh; i++) { for (int j = 0; j < tWw; j++) { - float s = Color::rgb2s (CLIP (working->r (i, j)), CLIP (working->g (i, j)), CLIP (working->b (i, j))); + double s = Color::rgb2s (CLIP (working->r (i, j)), CLIP (working->g (i, j)), CLIP (working->b (i, j))); moy += s; - sqrs += SQR (s); + sqrs += SQR(s); } } @@ -2108,17 +2106,17 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float toxyz[3][3] = { { - static_cast ( wprof[0][0] / Color::D50x), - static_cast ( wprof[0][1] / Color::D50x), - static_cast ( wprof[0][2] / Color::D50x) + static_cast(wprof[0][0] / static_cast(Color::D50x)), + static_cast(wprof[0][1] / static_cast(Color::D50x)), + static_cast(wprof[0][2] / static_cast(Color::D50x)) }, { - static_cast ( wprof[1][0]), - static_cast ( wprof[1][1]), - static_cast ( wprof[1][2]) + static_cast(wprof[1][0]), + static_cast(wprof[1][1]), + static_cast(wprof[1][2]) }, { - static_cast ( wprof[2][0] / Color::D50z), - static_cast ( wprof[2][1] / Color::D50z), - static_cast ( wprof[2][2] / Color::D50z) + static_cast(wprof[2][0] / static_cast(Color::D50z)), + static_cast(wprof[2][1] / static_cast(Color::D50z)), + static_cast(wprof[2][2] / static_cast(Color::D50z)) } }; float maxFactorToxyz = max (toxyz[1][0], toxyz[1][1], toxyz[1][2]); @@ -2238,10 +2236,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer const float film_simulation_strength = static_cast (params->filmSimulation.strength) / 100.0f; - const float exp_scale = pow (2.0, expcomp); - const float comp = (max (0.0, expcomp) + 1.0) * hlcompr / 100.0; - const float shoulder = ((65536.0 / max (1.0f, exp_scale)) * (hlcomprthresh / 200.0)) + 0.1; - const float hlrange = 65536.0 - shoulder; + const float exp_scale = pow(2.0, expcomp); + const float comp = (max(0.0, expcomp) + 1.0) * hlcompr / 100.0; + const float shoulder = ((65536.f / max(1.0f, exp_scale)) * (hlcomprthresh / 200.f)) + 0.1f; + const float hlrange = 65536.f - shoulder; const bool isProPhoto = (params->icm.workingProfile == "ProPhoto"); // extracting data from 'params' to avoid cache flush (to be confirmed) ToneCurveMode curveMode = params->toneCurve.curveMode; @@ -2303,43 +2301,43 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } */ - float RedLow = params->colorToning.redlow / 100.f; - float GreenLow = params->colorToning.greenlow / 100.f; - float BlueLow = params->colorToning.bluelow / 100.f; - float RedMed = params->colorToning.redmed / 100.f; - float GreenMed = params->colorToning.greenmed / 100.f; - float BlueMed = params->colorToning.bluemed / 100.f; - float RedHigh = params->colorToning.redhigh / 100.f; - float GreenHigh = params->colorToning.greenhigh / 100.f; - float BlueHigh = params->colorToning.bluehigh / 100.f; - float SatLow = float (params->colorToning.shadowsColSat.getBottom()) / 100.f; - float SatHigh = float (params->colorToning.hlColSat.getBottom()) / 100.f; + float RedLow = params->colorToning.redlow / 100.0; + float GreenLow = params->colorToning.greenlow / 100.0; + float BlueLow = params->colorToning.bluelow / 100.0; + float RedMed = params->colorToning.redmed / 100.0; + float GreenMed = params->colorToning.greenmed / 100.0; + float BlueMed = params->colorToning.bluemed / 100.0; + float RedHigh = params->colorToning.redhigh / 100.0; + float GreenHigh = params->colorToning.greenhigh / 100.0; + float BlueHigh = params->colorToning.bluehigh / 100.0; + float SatLow = params->colorToning.shadowsColSat.getBottom() / 100.f; + float SatHigh = params->colorToning.hlColSat.getBottom() / 100.f; - float Balan = float (params->colorToning.balance); + float Balan = params->colorToning.balance; - float chMixRR = float (params->chmixer.red[0])/10.f; - float chMixRG = float (params->chmixer.red[1])/10.f; - float chMixRB = float (params->chmixer.red[2])/10.f; - float chMixGR = float (params->chmixer.green[0])/10.f; - float chMixGG = float (params->chmixer.green[1])/10.f; - float chMixGB = float (params->chmixer.green[2])/10.f; - float chMixBR = float (params->chmixer.blue[0])/10.f; - float chMixBG = float (params->chmixer.blue[1])/10.f; - float chMixBB = float (params->chmixer.blue[2])/10.f; + float chMixRR = params->chmixer.red[0] / 10.f; + float chMixRG = params->chmixer.red[1] / 10.f; + float chMixRB = params->chmixer.red[2] / 10.f; + float chMixGR = params->chmixer.green[0] / 10.f; + float chMixGG = params->chmixer.green[1] / 10.f; + float chMixGB = params->chmixer.green[2] / 10.f; + float chMixBR = params->chmixer.blue[0] / 10.f; + float chMixBG = params->chmixer.blue[1] / 10.f; + float chMixBB = params->chmixer.blue[2] / 10.f; bool blackwhite = params->blackwhite.enabled; bool complem = params->blackwhite.enabledcc; - float bwr = float (params->blackwhite.mixerRed); - float bwg = float (params->blackwhite.mixerGreen); - float bwb = float (params->blackwhite.mixerBlue); - float bwrgam = float (params->blackwhite.gammaRed); - float bwggam = float (params->blackwhite.gammaGreen); - float bwbgam = float (params->blackwhite.gammaBlue); - float mixerOrange = float (params->blackwhite.mixerOrange); - float mixerYellow = float (params->blackwhite.mixerYellow); - float mixerCyan = float (params->blackwhite.mixerCyan); - float mixerMagenta = float (params->blackwhite.mixerMagenta); - float mixerPurple = float (params->blackwhite.mixerPurple); + float bwr = params->blackwhite.mixerRed; + float bwg = params->blackwhite.mixerGreen; + float bwb = params->blackwhite.mixerBlue; + float bwrgam = params->blackwhite.gammaRed; + float bwggam = params->blackwhite.gammaGreen; + float bwbgam = params->blackwhite.gammaBlue; + float mixerOrange = params->blackwhite.mixerOrange; + float mixerYellow = params->blackwhite.mixerYellow; + float mixerCyan = params->blackwhite.mixerCyan; + float mixerMagenta = params->blackwhite.mixerMagenta; + float mixerPurple = params->blackwhite.mixerPurple; int algm = 0; if (params->blackwhite.method == "Desaturation") { @@ -2720,7 +2718,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer //HSV equalizer if (hCurveEnabled) { - h = (hCurve->getVal (double (h)) - 0.5) * 2.f + h; + h = (hCurve->getVal(h) - 0.5) * 2.0 + static_cast(h); if (h > 1.0f) { h -= 1.0f; @@ -2751,7 +2749,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } //shift value - float valparam = vCurve->getVal ((double)h) - 0.5f; + float valparam = vCurve->getVal(h) - 0.5; valparam *= (1.f - SQR (SQR (1.f - min (s, 1.0f)))); if (valparam > 0.00001f) { @@ -3063,7 +3061,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer if (bwlCurveEnabled) { L /= 32768.f; double hr = Color::huelab_to_huehsv2 (HH); - float valparam = float ((bwlCurve->getVal (hr) - 0.5f) * 2.0f); //get l_r=f(H) + float valparam = (bwlCurve->getVal(hr) - 0.5) * 2.0; //get l_r=f(H) float kcc = (CC / 70.f); //take Chroma into account...70 "middle" of chromaticity (arbitrary and simple), one can imagine other algorithme //reduct action for low chroma and increase action for high chroma valparam *= kcc; @@ -3317,9 +3315,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { for (int j = 0; j < tW; j++) { - nr += tmpImage->r (i, j); - ng += tmpImage->g (i, j); - nb += tmpImage->b (i, j); + nr += static_cast(tmpImage->r(i, j)); + ng += static_cast(tmpImage->g(i, j)); + nb += static_cast(tmpImage->b(i, j)); } } @@ -4386,8 +4384,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW float factnoise = 1.f; if (params->dirpyrDenoise.enabled) { - factnoise = (1.f + params->dirpyrDenoise.chroma / 500.f); //levels=5 -// if(yyyy) factnoise=(1.f+params->dirpyrDenoise.chroma/100.f);//levels=7 + factnoise = 1.0 + params->dirpyrDenoise.chroma / 500.0; //levels=5 } const float scaleConst = 100.0f / 100.1f; @@ -4565,7 +4562,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW float l_r;//Luminance Lab in 0..1 l_r = Lprov1 / 100.f; { - float valparam = float ((lhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f)); //get l_r=f(H) + float valparam = lhCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5; //get l_r=f(H) float valparamneg; valparamneg = valparam; float kcc = (CC / amountchroma); //take Chroma into account...40 "middle low" of chromaticity (arbitrary and simple), one can imagine other algorithme @@ -4598,9 +4595,9 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW float fx = (0.002f * aprov1) + fy; float fz = fy - (0.005f * bprov1); - float x_ = 65535.0f * Color::f2xyz (fx) * Color::D50x; - float z_ = 65535.0f * Color::f2xyz (fz) * Color::D50z; - float y_ = (Lprov1 > Color::epskap) ? 65535.0 * fy * fy * fy : 65535.0 * Lprov1 / Color::kappa; + float x_ = 65535.f * Color::f2xyz (fx) * Color::D50x; + float z_ = 65535.f * Color::f2xyz (fz) * Color::D50z; + float y_ = Lprov1 > Color::epskapf ? 65535.f * fy * fy * fy : 65535.f * Lprov1 / Color::kappaf; float R, G, B; Color::xyz2rgb (x_, y_, z_, R, G, B, wip); @@ -4628,7 +4625,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW // calculate C=f(H) if (chutili) { double hr = Color::huelab_to_huehsv2 (HH); - float chparam = float ((chCurve->getVal (hr) - 0.5f) * 2.0f); //get C=f(H) + float chparam = (chCurve->getVal(hr) - 0.5) * 2.0; //get C=f(H) float chromaChfactor = 1.0f + chparam; atmp *= chromaChfactor;//apply C=f(H) btmp *= chromaChfactor; @@ -4636,9 +4633,9 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW if (hhutili) { // H=f(H) //hue Lab in -PI +PI - float valparam = float ((hhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f) * 1.7f) + HH; //get H=f(H) 1.7 optimisation ! + float valparam = (hhCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5) * 1.7 + static_cast(HH); //get H=f(H) 1.7 optimisation ! HH = valparam; - sincosval = xsincosf (HH); + sincosval = xsincosf(HH); } if (!bwToning) { @@ -4714,11 +4711,11 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW deltaHH = protect_redhcur; //transition hue - if (chromaCfactor > 0.0) { + if (chromaCfactor > 0.f) { Color::scalered ( rstprotection, chromaCfactor, 0.0, HH, deltaHH, scale, scaleext); //1.0 } - if (chromaCfactor > 1.0) { + if (chromaCfactor > 1.f) { float interm = (chromaCfactor - 1.0f) * 100.0f; factorskin = 1.0f + (interm * scale) / 100.0f; factorskinext = 1.0f + (interm * scaleext) / 100.0f; @@ -4775,11 +4772,11 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW deltaHH = protect_redhcur; //transition hue - if (chromaCfactor > 0.0) { + if (chromaCfactor > 0.f) { Color::scalered ( rstprotection, chromaCfactor, 0.0, HH, deltaHH, scale, scaleext); //1.0 } - if (chromaCfactor > 1.0) { + if (chromaCfactor > 1.f) { float interm = (chromaCfactor - 1.0f) * 100.0f; factorskin = 1.0f + (interm * scale) / 100.0f; factorskinext = 1.0f + (interm * scaleext) / 100.0f; @@ -5062,7 +5059,7 @@ void ImProcFunctions::impulsedenoise (LabImage* lab) if (params->impulseDenoise.enabled && lab->W >= 8 && lab->H >= 8) { - impulse_nr (lab, (float)params->impulseDenoise.thresh / 20.0 ); + impulse_nr(lab, params->impulseDenoise.thresh / 20.0); } } @@ -5072,7 +5069,7 @@ void ImProcFunctions::impulsedenoisecam (CieImage* ncie, float **buffers[3]) if (params->impulseDenoise.enabled && ncie->W >= 8 && ncie->H >= 8) { - impulse_nrcam (ncie, (float)params->impulseDenoise.thresh / 20.0, buffers ); + impulse_nrcam(ncie, params->impulseDenoise.thresh / 20.0, buffers); } } @@ -5142,11 +5139,11 @@ void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, int Wi float sca = params->epd.scale; float gamm = params->epd.gamma; float rew = params->epd.reweightingIterates; - float Qpro = ( 4.0 / c_) * ( a_w + 4.0 ) ; //estimate Q max if J=100.0 + float Qpro = (4.f / c_) * (a_w + 4.f) ; //estimate Q max if J=100.0 float *Qpr = ncie->Q_p[0]; if (settings->verbose) { - printf ("minQ=%f maxQ=%f Qpro=%f\n", minQ, maxQ, Qpro); + printf ("minQ=%f maxQ=%f Qpro=%f\n", static_cast(minQ), static_cast(maxQ), static_cast(Qpro)); } if (maxQ > Qpro) { @@ -5173,7 +5170,7 @@ void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, int Wi //Auto select number of iterates. Note that p->EdgeStopping = 0 makes a Gaussian blur. if (Iterates == 0) { - Iterates = (unsigned int) (edgest * 15.0); + Iterates = edgest * 15.f; } //Jacques Desmis : always Iterates=5 for compatibility images between preview and output @@ -5400,7 +5397,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double octile[count] += histogram[j]; if (octile[count] > sum / 8.f || (count == 7 && octile[count] > sum / 16.f)) { - octile[count] = xlog (1. + j) / log (2.f); + octile[count] = xlog(1. + j) / log(2.0); count++;// = min(count+1,7); } } @@ -5413,7 +5410,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double octile[count] += histogram[j]; if (octile[count] > sum / 8.f || (count == 7 && octile[count] > sum / 16.f)) { - octile[count] = xlog (1. + j) / log (2.f); + octile[count] = xlog(1. + j) / log(2.0); count++;// = min(count+1,7); } } @@ -5488,7 +5485,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double } //compute clipped white point - unsigned int clippable = (int) (sum * clip / 100.f ); + unsigned int clippable = (int) (static_cast(sum) * clip / 100.0 ); clipped = 0; int whiteclip = (imax) - 1; @@ -5547,8 +5544,8 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double hlcomprthresh = 0; //this is a series approximation of the actual formula for comp, //which is a transcendental equation - float comp = (gain * ((float)whiteclip) / scale - 1.f) * 2.3f; // 2.3 instead of 2 to increase slightly comp - hlcompr = (int) (100.*comp / (max (0.0, expcomp) + 1.0)); + double comp = (gain * whiteclip / scale - 1.f) * 2.3f; // 2.3 instead of 2 to increase slightly comp + hlcompr = 100.0 * comp / (max(0.0, expcomp) + 1.0); hlcompr = max (0, min (100, hlcompr)); //now find brightness if gain didn't bring ave to midgray using @@ -5556,9 +5553,9 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double float midtmp = gain * sqrt (median * ave) / scale; if (midtmp < 0.1f) { - bright = (midgray - midtmp) * 15.0 / (midtmp); + bright = (midgray - midtmp) * 15.f / (midtmp); } else { - bright = (midgray - midtmp) * 15.0 / (0.10833 - 0.0833 * midtmp); + bright = (midgray - midtmp) * 15.f / (0.10833f - 0.0833f * midtmp); } bright = 0.25 */*(median/ave)*(hidev/lodev)*/max (0, bright); @@ -5567,7 +5564,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double contr = (int) 50.0f * (1.1f - ospread); contr = max (0, min (100, contr)); //take gamma into account - double whiteclipg = (int) (CurveFactory::gamma2 (whiteclip * corr / 65536.0) * 65536.0); + double whiteclipg = (int) (CurveFactory::gamma2(whiteclip * static_cast(corr) / 65536.0) * 65536.0); float gavg = 0.; @@ -5589,7 +5586,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double } } - whiteclipg = CurveFactory::igamma2 ((float) (whiteclipg / 65535.0)) * 65535.0; //need to inverse gamma transform to get correct exposure compensation parameter + whiteclipg = CurveFactory::igamma2(whiteclipg / 65535.0) * 65535.0; //need to inverse gamma transform to get correct exposure compensation parameter //correction with gamma black = (int) ((65535 * black) / whiteclipg); @@ -5824,8 +5821,8 @@ void ImProcFunctions::lab2rgb (const LabImage &src, Imagefloat &dst, const Glib: */ void ImProcFunctions::colorToningLabGrid(LabImage *lab, int xstart, int xend, int ystart, int yend, bool MultiThread) { - const float factor = ColorToningParams::LABGRID_CORR_MAX * 3.f; - const float scaling = ColorToningParams::LABGRID_CORR_SCALE; + const double factor = ColorToningParams::LABGRID_CORR_MAX * 3.0; + const double scaling = ColorToningParams::LABGRID_CORR_SCALE; float a_scale = (params->colorToning.labgridAHigh - params->colorToning.labgridALow) / factor / scaling; float a_base = params->colorToning.labgridALow / scaling; float b_scale = (params->colorToning.labgridBHigh - params->colorToning.labgridBLow) / factor / scaling; diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 9cef35974..39a229c7e 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -19,11 +19,17 @@ #pragma once #include +#include #include "coord2d.h" #include "gamutwarning.h" -#include "pipettebuffer.h" +namespace Glib +{ + +class ustring; + +} template class LUT; @@ -44,6 +50,7 @@ class FramesMetaData; class LensCorrection; class NoiseCurve; class OpacityCurve; +class PipetteBuffer; class ToneCurve; class WavCurve; class WavOpacityCurveBY; diff --git a/rtengine/ipdehaze.cc b/rtengine/ipdehaze.cc index 28a0f2d57..53939b5c0 100644 --- a/rtengine/ipdehaze.cc +++ b/rtengine/ipdehaze.cc @@ -32,6 +32,7 @@ #include #include +#include "array2D.h" #include "color.h" #include "guidedfilter.h" #include "iccstore.h" @@ -240,9 +241,9 @@ float estimate_ambient_light(const array2D &R, const array2D &G, c float g = G[y][x]; float b = B[y][x]; if (r + g + b >= bright_lim) { - rr += r; - gg += g; - bb += b; + rr += static_cast(r); + gg += static_cast(g); + bb += static_cast(b); ++n; } } diff --git a/rtengine/iplabregions.cc b/rtengine/iplabregions.cc index 6526419f5..786d42e56 100644 --- a/rtengine/iplabregions.cc +++ b/rtengine/iplabregions.cc @@ -139,7 +139,7 @@ BENCHFUN auto &hm = hmask[i]; auto &cm = cmask[i]; auto &lm = lmask[i]; - float blend = LIM01((hm ? hm->getVal(h) : 1.f) * (cm ? cm->getVal(c) : 1.f) * (lm ? lm->getVal(l) : 1.f)); + float blend = LIM01((hm ? hm->getVal(h) : 1.0) * (cm ? cm->getVal(c) : 1.0) * (lm ? lm->getVal(l) : 1.0)); Lmask[i][y][x] = abmask[i][y][x] = blend; } } @@ -147,8 +147,8 @@ BENCHFUN } for (int i = begin_idx; i < end_idx; ++i) { - float blur = params->colorToning.labregions[i].maskBlur; - blur = blur < 0.f ? -1.f/blur : 1.f + blur; + double blur = params->colorToning.labregions[i].maskBlur; + blur = blur < 0.0 ? -1.0 / blur : 1.0 + blur; int r1 = max(int(4 / scale * blur + 0.5), 1); int r2 = max(int(25 / scale * blur + 0.5), 1); rtengine::guidedFilter(guide, abmask[i], abmask[i], r1, 0.001, multiThread); @@ -188,7 +188,7 @@ BENCHFUN auto &r = params->colorToning.labregions[i]; abca[i] = abcoord(r.a); abcb[i] = abcoord(r.b); - rs[i] = 1.f + r.saturation / (SGN(r.saturation) > 0 ? 50.f : 100.f); + rs[i] = 1.0 + r.saturation / (SGN(r.saturation) > 0 ? 50.0 : 100.0); slope[i] = r.slope; offset[i] = r.offset; power[i] = r.power; diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index 84f33482f..6768eca93 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -110,8 +110,8 @@ void mean_stddv2( float **dst, float &mean, float &stddv, int W_L, int H_L, floa for (int i = 0; i < H_L; i++ ) for (int j = 0; j < W_L; j++) { - sum += dst[i][j]; - vsquared += (dst[i][j] * dst[i][j]); + sum += static_cast(dst[i][j]); + vsquared += rtengine::SQR(dst[i][j]); lmax = dst[i][j] > lmax ? dst[i][j] : lmax; lmin = dst[i][j] < lmin ? dst[i][j] : lmin; @@ -128,8 +128,8 @@ void mean_stddv2( float **dst, float &mean, float &stddv, int W_L, int H_L, floa } mean = sum / (double) (W_L * H_L); vsquared /= (double) W_L * H_L; - stddv = ( vsquared - (mean * mean) ); - stddv = (float)sqrt(stddv); + stddv = vsquared - rtengine::SQR(mean); + stddv = std::sqrt(stddv); } } @@ -678,9 +678,9 @@ BENCHFUN float valparam; if(useHsl || useHslLin) { - valparam = shcurve->getVal(HH) - 0.5f; + valparam = shcurve->getVal(HH) - 0.5; } else { - valparam = shcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f; + valparam = shcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5; } str *= (1.f + 2.f * valparam); diff --git a/rtengine/ipshadowshighlights.cc b/rtengine/ipshadowshighlights.cc index f6656fbef..0eb3df9c5 100644 --- a/rtengine/ipshadowshighlights.cc +++ b/rtengine/ipshadowshighlights.cc @@ -45,6 +45,7 @@ void ImProcFunctions::shadowsHighlights(LabImage *lab, bool ena, int labmode, in array2D mask(width, height); array2D L(width, height); +// const float radius = params->sh.radius * 10 / scale; const float radius = float(rad) * 10 / scal; LUTf f(lab_mode ? 32768 : 65536); diff --git a/rtengine/ipsharpen.cc b/rtengine/ipsharpen.cc index 7198b76c5..0e46cd596 100644 --- a/rtengine/ipsharpen.cc +++ b/rtengine/ipsharpen.cc @@ -103,7 +103,7 @@ void sharpenHaloCtrl (float** luminance, float** blurmap, float** base, float** void dcdamping (float** aI, float** aO, float damping, int W, int H) { - const float dampingFac = -2.0 / (damping * damping); + const float dampingFac = -2.f / (damping * damping); #ifdef __SSE2__ vfloat Iv, Ov, Uv, zerov, onev, fourv, fivev, dampingFacv, Tv, Wv, Lv; @@ -163,7 +163,7 @@ namespace rtengine void ImProcFunctions::deconvsharpening (float** luminance, float** tmp, const float * const * blend, int W, int H, const procparams::SharpeningParams &sharpenParam, double Scale) { - if (sharpenParam.deconvamount == 0 && sharpenParam.blurradius < 0.25f) { + if (sharpenParam.deconvamount == 0 && sharpenParam.blurradius < 0.25) { return; } BENCHFUN @@ -180,7 +180,7 @@ BENCHFUN JaggedArray* blurbuffer = nullptr; - if (sharpenParam.blurradius >= 0.25f) { + if (sharpenParam.blurradius >= 0.25) { blurbuffer = new JaggedArray(W, H); JaggedArray &blur = *blurbuffer; #ifdef _OPENMP @@ -229,7 +229,7 @@ BENCHFUN } } - if (sharpenParam.blurradius >= 0.25f) { + if (sharpenParam.blurradius >= 0.25) { JaggedArray &blur = *blurbuffer; #ifdef _OPENMP #pragma omp for @@ -255,7 +255,7 @@ void ImProcFunctions::sharpening (LabImage* lab, const procparams::SharpeningPar // calculate contrast based blend factors to reduce sharpening in regions with low contrast JaggedArray blend(W, H); - float contrast = sharpenParam.contrast / 100.f; + float contrast = sharpenParam.contrast / 100.0; buildBlendMask(lab->L, blend, W, H, contrast); if(showMask) { @@ -292,7 +292,7 @@ BENCHFUN JaggedArray blur(W, H); - if (sharpenParam.blurradius >= 0.25f) { + if (sharpenParam.blurradius >= 0.25) { #ifdef _OPENMP #pragma omp parallel #endif @@ -372,7 +372,7 @@ BENCHFUN delete [] b3; } - if (sharpenParam.blurradius >= 0.25f) { + if (sharpenParam.blurradius >= 0.25) { #ifdef _OPENMP #pragma omp parallel for #endif @@ -385,241 +385,6 @@ BENCHFUN } -// To the extent possible under law, Manuel Llorens -// has waived all copyright and related or neighboring rights to this work. -// This work is published from: Spain. - -// Thanks to Manuel for this excellent job (Jacques Desmis JDC or frej83) -void ImProcFunctions::MLsharpen (LabImage* lab) -{ - // JD: this algorithm maximize clarity of images; it does not play on accutance. It can remove (partially) the effects of the AA filter) - // I think we can use this algorithm alone in most cases, or first to clarify image and if you want a very little USM (unsharp mask sharpening) after... - if (!params->sharpenEdge.enabled) { - return; - } - - MyTime t1e, t2e; - t1e.set(); - - int offset, c, i, j, p, width2; - int width = lab->W, height = lab->H; - float *L, lumH, lumV, lumD1, lumD2, v, contrast, s; - float difL, difR, difT, difB, difLT, difRB, difLB, difRT, wH, wV, wD1, wD2, chmax[3]; - float f1, f2, f3, f4; - float templab; - int iii, kkk; - width2 = 2 * width; - const float epsil = 0.01f; //prevent divide by zero - const float eps2 = 0.001f; //prevent divide by zero - float amount; - amount = params->sharpenEdge.amount / 100.0f; - - if (amount < 0.00001f) { - return; - } - - if (settings->verbose) { - printf ("SharpenEdge amount %f\n", amount); - } - - L = new float[width * height]; - - chmax[0] = 8.0f; - chmax[1] = 3.0f; - chmax[2] = 3.0f; - - int channels; - - if (params->sharpenEdge.threechannels) { - channels = 0; - } else { - channels = 2; - } - - if (settings->verbose) { - printf ("SharpenEdge channels %d\n", channels); - } - - int passes = params->sharpenEdge.passes; - - if (settings->verbose) { - printf ("SharpenEdge passes %d\n", passes); - } - - for (p = 0; p < passes; p++) - for (c = 0; c <= channels; c++) { // c=0 Luminance only - -#ifdef _OPENMP - #pragma omp parallel for private(offset) shared(L) -#endif - - for (offset = 0; offset < width * height; offset++) { - int ii = offset / width; - int kk = offset - ii * width; - - if (c == 0) { - L[offset] = lab->L[ii][kk] / 327.68f; // adjust to RT and to 0..100 - } else if (c == 1) { - L[offset] = lab->a[ii][kk] / 327.68f; - } else { /*if (c==2) */ - L[offset] = lab->b[ii][kk] / 327.68f; - } - } - -#ifdef _OPENMP - #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++) { - // weight functions - 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 = wD1; - wD1 /= wD2; - wD2 /= s; - - // initial values - int ii = offset / width; - int kk = offset - ii * width; - - if (c == 0) { - lumH = lumV = lumD1 = lumD2 = v = lab->L[ii][kk] / 327.68f; - } else if (c == 1) { - lumH = lumV = lumD1 = lumD2 = v = lab->a[ii][kk] / 327.68f; - } else { /* if (c==2) */ - lumH = lumV = lumD1 = lumD2 = v = lab->b[ii][kk] / 327.68f; - } - - - // 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]; - - if (contrast > 1.0f) { - contrast = 1.0f; - } - - // 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])); - 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])); - difR = f1 * f2 * f2 * f3 * f3 * f4; - - if ((difR > epsil) && (difL > epsil)) { - lumH = (L[offset - 1] * difR + L[offset + 1] * difL) / (difL + difR); - lumH = v * (1.f - contrast) + lumH * contrast; - } - } - - 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])); - 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])); - difB = f1 * f2 * f2 * f3 * f3 * f4; - - if ((difB > epsil) && (difT > epsil)) { - lumV = (L[offset - width] * difB + L[offset + width] * difT) / (difT + difB); - lumV = v * (1.f - contrast) + lumV * contrast; - } - } - - 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])); - 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])); - difRB = f1 * f2 * f2 * f3 * f3 * f4; - - if ((difLT > epsil) && (difRB > epsil)) { - lumD1 = (L[offset - 1 - width] * difRB + L[offset + 1 + width] * difLT) / (difLT + difRB); - lumD1 = v * (1.f - contrast) + lumD1 * contrast; - } - } - - 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])); - 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])); - difRT = f1 * f2 * f2 * f3 * f3 * f4; - - if ((difLB > epsil) && (difRT > epsil)) { - lumD2 = (L[offset + 1 - width] * difLB + L[offset - 1 + width] * difRT) / (difLB + difRT); - lumD2 = v * (1.f - contrast) + lumD2 * contrast; - } - } - - 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))) { - s = amount / 3.0f; - } - - // final mix - if ((wH != 0.0f) && (wV != 0.0f) && (wD1 != 0.0f) && (wD2 != 0.0f)) { - iii = offset / width; - kkk = offset - iii * width; - float provL = lab->L[iii][kkk] / 327.68f; - - 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; - } - } else { - templab = v * (1.f - s) + (lumH * wH + lumV * wV + lumD1 * wD1 + lumD2 * wD2) / (wH + wV + wD1 + wD2) * s; - } - - if (c == 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) { - lab->b[iii][kkk] = 327.68f * templab ; - } - } - - } - } - - delete [] L; - - t2e.set(); - - if (settings->verbose) { - printf("SharpenEdge gradient %d usec\n", t2e.etime(t1e)); - } -} - // To the extent possible under law, Manuel Llorens // has waived all copyright and related or neighboring rights to this work. // This code is licensed under CC0 v1.0, see license information at @@ -640,10 +405,10 @@ BENCHFUN // k=2 matrix 5x5 k=1 matrix 3x3 const int width = W, height = H; const int unif = params->sharpenMicro.uniformity; - const float amount = (k == 1 ? 2.7f : 1.f) * params->sharpenMicro.amount / 1500.0f; //amount 2000.0 quasi no artifacts ==> 1500 = maximum, after artifacts, 25/9 if 3x3 + const float amount = (k == 1 ? 2.7 : 1.) * params->sharpenMicro.amount / 1500.0; //amount 2000.0 quasi no artifacts ==> 1500 = maximum, after artifacts, 25/9 if 3x3 if (settings->verbose) { - printf ("Micro-contrast amount %f\n", amount); + printf ("Micro-contrast amount %f\n", static_cast(amount)); printf ("Micro-contrast uniformity %i\n", unif); } @@ -674,7 +439,7 @@ BENCHFUN // calculate contrast based blend factors to reduce sharpening in regions with low contrast JaggedArray blend(W, H); - float contrast = params->sharpenMicro.contrast / 100.f; + float contrast = params->sharpenMicro.contrast / 100.0; buildBlendMask(luminance, blend, W, H, contrast); #ifdef _OPENMP @@ -883,7 +648,7 @@ void ImProcFunctions::sharpeningcam (CieImage* ncie, float** b2, bool showMask) // calculate contrast based blend factors to reduce sharpening in regions with low contrast JaggedArray blend(W, H); - float contrast = params->sharpening.contrast / 100.f; + float contrast = params->sharpening.contrast / 100.0; buildBlendMask(ncie->sh_p, blend, W, H, contrast); if(showMask) { #ifdef _OPENMP diff --git a/rtengine/ipsharpenedges.cc b/rtengine/ipsharpenedges.cc new file mode 100644 index 000000000..6a44ee40a --- /dev/null +++ b/rtengine/ipsharpenedges.cc @@ -0,0 +1,217 @@ +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2020 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . +*/ + +#include +#include "improcfun.h" +#include "labimage.h" +#include "procparams.h" +#include "rt_math.h" + +namespace { +#ifdef __SSE2__ +bool inintervalLoRo(float a, float b, float c) +{ + return a < std::max(b, c) && a > std::min(b, c); +} + +float selectweight(float a, float b, float low, float high) +{ + const float minVal = std::min(a,b); + const float maxVal = std::max(a,b); + const float res = (minVal < 0.45f * maxVal) ? low : high; + return (minVal > 0.05f * maxVal) ? res : high; +} + +#else +bool inintervalLoRo(float a, float b, float c) +{ + return (a < b && a > c) || (a < c && a > b); +} + +float selectweight(float a, float b, float low, float high) +{ + if ((a < 0.45f * b && a > 0.05f * b) || (b < 0.45f * a && b > 0.05f * a)) { + return low; + } else { + return high; + } +} + +#endif +} +namespace rtengine +{ + +// To the extent possible under law, Manuel Llorens +// has waived all copyright and related or neighboring rights to this work. +// This work is published from: Spain. + +// Thanks to Manuel for this excellent job (Jacques Desmis JDC or frej83) +void ImProcFunctions::MLsharpen (LabImage* lab) +{ + // JD: this algorithm maximize clarity of images; it does not play on accutance. It can remove (partially) the effects of the AA filter) + // I think we can use this algorithm alone in most cases, or first to clarify image and if you want a very little USM (unsharp mask sharpening) after... + if (!params->sharpenEdge.enabled || params->sharpenEdge.amount == 0) { + return; + } + + const int width = lab->W, height = lab->H; + constexpr float chmax[3] = {1.f / 8.f, 1.f / 3.f, 1.f / 3.f}; + const int width2 = 2 * width; + constexpr float eps2 = 0.001f; //prevent divide by zero + const float amount = params->sharpenEdge.amount / 100.0; + const float amountby3 = params->sharpenEdge.amount / 300.0; + + std::unique_ptr L(new float[width * height]); + + const int channels = params->sharpenEdge.threechannels ? 1 : 3; + const int passes = params->sharpenEdge.passes; + + for (int c = 0; c < channels; ++c) { // c=0 Luminance only + float** channel = c == 0 ? lab->L : c == 1 ? lab->a : lab->b; + for (int p = 0; p < passes; ++p) { +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = 0; i < height; ++i) { + for (int j = 0; j < width; ++j) { + L[i * width + j] = channel[i][j] / 327.68f; + } + } + +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int j = 2; j < height - 2; j++) { + for (int i = 2, offset = j * width + i; i < width - 2; i++, offset++) { + // weight functions + const float wH = eps2 + std::fabs(L[offset + 1] - L[offset - 1]); + const float wV = eps2 + std::fabs(L[offset + width] - L[offset - width]); + + float s = 2.f / (2.f + std::fabs(wH - wV)); + float wD1 = eps2 + std::fabs(L[offset + width + 1] - L[offset - width - 1]) * s; + float wD2 = eps2 + std::fabs(L[offset + width - 1] - L[offset - width + 1]) * s; + s = wD1; + wD1 /= wD2; + wD2 /= s; + + const float v = L[offset]; + float lumH, lumV, lumD1, lumD2; + lumH = lumV = lumD1 = lumD2 = v; + + // contrast detection + const float contrast = std::min(std::sqrt(SQR(L[offset + 1] - L[offset - 1]) + SQR(L[offset + width] - L[offset - width])) * chmax[c], 1.f); + + // new possible values + if (inintervalLoRo(v, L[offset - 1], L[offset + 1])) { + float f1 = std::fabs(L[offset - 2] - L[offset - 1]); + float f2 = L[offset - 1] - v; + float f3 = (L[offset - 1] - L[offset - width]) * (L[offset - 1] - L[offset + width]); + float f4 = std::sqrt(std::fabs((L[offset - 1] - L[offset - width2]) * (L[offset - 1] - L[offset + width2]))); + const float difL = f1 * SQR(f2 * f3) * f4; + if (difL > 0.f) { + f1 = std::fabs(L[offset + 2] - L[offset + 1]); + f2 = L[offset + 1] - v; + f3 = (L[offset + 1] - L[offset - width]) * (L[offset + 1] - L[offset + width]); + f4 = std::sqrt(std::fabs((L[offset + 1] - L[offset - width2]) * (L[offset + 1] - L[offset + width2]))); + const float difR = f1 * SQR(f2 * f3) * f4; + if (difR > 0.f) { + lumH = (L[offset - 1] * difR + L[offset + 1] * difL) / (difL + difR); + lumH = intp(contrast, lumH, v); + } + } + } + + if (inintervalLoRo(v, L[offset - width], L[offset + width])) { + float f1 = std::fabs(L[offset - width2] - L[offset - width]); + float f2 = L[offset - width] - v; + float f3 = (L[offset - width] - L[offset - 1]) * (L[offset - width] - L[offset + 1]); + float f4 = std::sqrt(std::fabs((L[offset - width] - L[offset - 2]) * (L[offset - width] - L[offset + 2]))); + const float difT = f1 * SQR(f2 * f3) * f4; + if (difT > 0.f) { + f1 = std::fabs(L[offset + width2] - L[offset + width]); + f2 = L[offset + width] - v; + f3 = (L[offset + width] - L[offset - 1]) * (L[offset + width] - L[offset + 1]); + f4 = std::sqrt(std::fabs((L[offset + width] - L[offset - 2]) * (L[offset + width] - L[offset + 2]))); + const float difB = f1 * SQR(f2 * f3) * f4; + if (difB > 0.f) { + lumV = (L[offset - width] * difB + L[offset + width] * difT) / (difT + difB); + lumV = intp(contrast, lumV, v); + } + } + } + + if (inintervalLoRo(v, L[offset - 1 - width], L[offset + 1 + width])) { + float f1 = std::fabs(L[offset - 2 - width2] - L[offset - 1 - width]); + float f2 = L[offset - 1 - width] - v; + float f3 = (L[offset - 1 - width] - L[offset - width + 1]) * (L[offset - 1 - width] - L[offset + width - 1]); + float f4 = std::sqrt(std::fabs((L[offset - 1 - width] - L[offset - width2 + 2]) * (L[offset - 1 - width] - L[offset + width2 - 2]))); + const float difLT = f1 * SQR(f2 * f3) * f4; + if (difLT > 0.f) { + f1 = std::fabs(L[offset + 2 + width2] - L[offset + 1 + width]); + f2 = L[offset + 1 + width] - v; + f3 = (L[offset + 1 + width] - L[offset - width + 1]) * (L[offset + 1 + width] - L[offset + width - 1]); + f4 = std::sqrt(std::fabs((L[offset + 1 + width] - L[offset - width2 + 2]) * (L[offset + 1 + width] - L[offset + width2 - 2]))); + const float difRB = f1 * SQR(f2 * f3) * f4; + if (difRB > 0.f) { + lumD1 = (L[offset - 1 - width] * difRB + L[offset + 1 + width] * difLT) / (difLT + difRB); + lumD1 = intp(contrast, lumD1, v); + } + } + } + + if (inintervalLoRo(v, L[offset + 1 - width], L[offset - 1 + width])) { + float f1 = std::fabs(L[offset - 2 + width2] - L[offset - 1 + width]); + float f2 = L[offset - 1 + width] - v; + float f3 = (L[offset - 1 + width] - L[offset - width - 1]) * (L[offset - 1 + width] - L[offset + width + 1]); + float f4 = std::sqrt(std::fabs((L[offset - 1 + width] - L[offset - width2 - 2]) * (L[offset - 1 + width] - L[offset + width2 + 2]))); + const float difLB = f1 * SQR(f2 * f3) * f4; + if (difLB > 0.f) { + f1 = std::fabs(L[offset + 2 - width2] - L[offset + 1 - width]); + f2 = L[offset + 1 - width] - v; + f3 = (L[offset + 1 - width] - L[offset + width + 1]) * (L[offset + 1 - width] - L[offset - width - 1]); + f4 = std::sqrt(std::fabs((L[offset + 1 - width] - L[offset + width2 + 2]) * (L[offset + 1 - width] - L[offset - width2 - 2]))); + const float difRT = f1 * SQR(f2 * f3) * f4; + if (difRT > 0.f) { + lumD2 = (L[offset + 1 - width] * difLB + L[offset - 1 + width] * difRT) / (difLB + difRT); + lumD2 = intp(contrast, lumD2, v); + } + } + } + + // final mix + // avoid sharpening diagonals too much + const float weight = selectweight(wH, wV, amountby3, amount); + + if (c == 0) { + if (v < 92.f) { + channel[j][i] = std::fabs(327.68f * intp(weight, (lumH * wH + lumV * wV + lumD1 * wD1 + lumD2 * wD2) / (wH + wV + wD1 + wD2), v)); // fabs because lab->L always > 0 + } + } else { + channel[j][i] = 327.68f * intp(weight, (lumH * wH + lumV * wV + lumD1 * wD1 + lumD2 * wD2) / (wH + wV + wD1 + wD2), v); + } + } + } + } + } +} + +} diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 9e7c61dcf..b0dc55b2f 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -689,11 +689,11 @@ static void calcGradientParams (int oW, int oH, const GradientParams& gradient, gp.ta = tan (gradient_angle); gp.xc = w * gradient_center_x; gp.yc = h * gradient_center_y; - gp.ys = sqrt ((float)h * h + (float)w * w) * (gradient_span / cos (gradient_angle)); - gp.ys_inv = 1.0 / gp.ys; - gp.top_edge_0 = gp.yc - gp.ys / 2.0; + gp.ys = rtengine::norm2(static_cast(h), static_cast(w)) * (gradient_span / cos(gradient_angle)); + gp.ys_inv = 1.f / gp.ys; + gp.top_edge_0 = gp.yc - gp.ys / 2.f; - if (gp.ys < 1.0 / h) { + if (h * gp.ys < 1.f) { gp.ys_inv = 0; gp.ys = 0; } @@ -723,7 +723,7 @@ static float calcGradientFactor (const struct grad_params& gp, int x, int y) val = 1.f - pow3 (xcosf (val)); } - return gp.scale + val * (1.0 - gp.scale); + return gp.scale + val * (1.f - gp.scale); } } else { int gy = gp.transpose ? x : y; @@ -747,7 +747,7 @@ static float calcGradientFactor (const struct grad_params& gp, int x, int y) val = 1.f - pow3 (xcosf (val)); } - return gp.scale + val * (1.0 - gp.scale); + return gp.scale + val * (1.f - gp.scale); } } } @@ -766,7 +766,7 @@ static void calcPCVignetteParams (int fW, int fH, int oW, int oH, const PCVignet { // ellipse formula: (x/a)^2 + (y/b)^2 = 1 - double roundness = pcvignette.roundness / 100.0; + float roundness = pcvignette.roundness / 100.f; pcv.feather = pcvignette.feather / 100.0; if (crop.enabled) { @@ -783,42 +783,40 @@ static void calcPCVignetteParams (int fW, int fH, int oW, int oH, const PCVignet pcv.h = oH; } - pcv.fadeout_mul = 1.0 / (0.05 * sqrtf (oW * oW + oH * oH)); + pcv.fadeout_mul = 20.0 / rtengine::norm2(static_cast(oW), static_cast(oW)); float short_side = (pcv.w < pcv.h) ? pcv.w : pcv.h; float long_side = (pcv.w > pcv.h) ? pcv.w : pcv.h; pcv.sep = 2; pcv.sepmix = 0; - pcv.oe_a = sqrt (2.0) * long_side * 0.5; + pcv.oe_a = std::sqrt(2.f) * long_side * 0.5f; pcv.oe_b = pcv.oe_a * short_side / long_side; - pcv.ie_mul = (1.0 / sqrt (2.0)) * (1.0 - pcv.feather); + pcv.ie_mul = (1.f - pcv.feather) / std::sqrt(2.f); pcv.is_super_ellipse_mode = false; pcv.is_portrait = (pcv.w < pcv.h); - if (roundness < 0.5) { + if (roundness < 0.5f) { // make super-ellipse of higher and higher degree pcv.is_super_ellipse_mode = true; - float sepf = 2 + 4 * powf (1.0 - 2 * roundness, 1.3); // gamma 1.3 used to balance the effect in the 0.0...0.5 roundness range + float sepf = 2 + 4 * std::pow(1.f - 2 * roundness, 1.3f); // gamma 1.3 used to balance the effect in the 0.0...0.5 roundness range pcv.sep = ((int)sepf) & ~0x1; - pcv.sepmix = (sepf - pcv.sep) * 0.5; // 0.0 to 1.0 - pcv.oe1_a = powf (2.0, 1.0 / pcv.sep) * long_side * 0.5; + pcv.sepmix = (sepf - pcv.sep) * 0.5f; // 0.0 to 1.0 + pcv.oe1_a = std::pow(2.f, 1.f / pcv.sep) * long_side * 0.5f; pcv.oe1_b = pcv.oe1_a * short_side / long_side; - pcv.ie1_mul = (1.0 / powf (2.0, 1.0 / pcv.sep)) * (1.0 - pcv.feather); - pcv.oe2_a = powf (2.0, 1.0 / (pcv.sep + 2)) * long_side * 0.5; + pcv.ie1_mul = (1.f - pcv.feather) / std::pow(2.f, 1.f / pcv.sep); + pcv.oe2_a = std::pow(2.f, 1.f / (pcv.sep + 2)) * long_side * 0.5f; pcv.oe2_b = pcv.oe2_a * short_side / long_side; - pcv.ie2_mul = (1.0 / powf (2.0, 1.0 / (pcv.sep + 2))) * (1.0 - pcv.feather); - } - - if (roundness > 0.5) { + pcv.ie2_mul = (1.f - pcv.feather) / std::pow(2.f, 1.f / (pcv.sep + 2)); + } else if (roundness > 0.5f) { // scale from fitted ellipse towards circle - float rad = sqrtf (pcv.w * pcv.w + pcv.h * pcv.h) / 2.0; + float rad = rtengine::norm2(static_cast(pcv.w), static_cast(pcv.h)) / 2.f; float diff_a = rad - pcv.oe_a; float diff_b = rad - pcv.oe_b; - pcv.oe_a = pcv.oe_a + diff_a * 2 * (roundness - 0.5); - pcv.oe_b = pcv.oe_b + diff_b * 2 * (roundness - 0.5); + pcv.oe_a = pcv.oe_a + diff_a * 2 * (roundness - 0.5f); + pcv.oe_b = pcv.oe_b + diff_b * 2 * (roundness - 0.5f); } - pcv.scale = powf (2, -pcvignette.strength); + pcv.scale = std::pow(2, -pcvignette.strength); if (pcvignette.strength >= 6.0) { pcv.scale = 0.0; @@ -954,23 +952,23 @@ void ImProcFunctions::transformLuminanceOnly (Imagefloat* original, Imagefloat* double r = sqrt (vig_x_d * vig_x_d + vig_y_d * vig_y_d); if (darkening) { - factor /= std::max (v + mul * tanh (b * (maxRadius - r) / maxRadius), 0.001); + factor /= std::max (v + mul * tanh(b * (maxRadius - r) / maxRadius), 0.001); } else { - factor = v + mul * tanh (b * (maxRadius - r) / maxRadius); + factor = v + mul * tanh(b * (maxRadius - r) / maxRadius); } } if (applyGradient) { - factor *= calcGradientFactor (gp, cx + x, cy + y); + factor *= static_cast(calcGradientFactor(gp, cx + x, cy + y)); } if (applyPCVignetting) { - factor *= calcPCVignetteFactor (pcv, cx + x, cy + y); + factor *= static_cast(calcPCVignetteFactor(pcv, cx + x, cy + y)); } - transformed->r (y, x) = original->r (y, x) * factor; - transformed->g (y, x) = original->g (y, x) * factor; - transformed->b (y, x) = original->b (y, x) * factor; + transformed->r(y, x) = static_cast(original->r(y, x)) * factor; + transformed->g(y, x) = static_cast(original->g(y, x)) * factor; + transformed->b(y, x) = static_cast(original->b(y, x)) * factor; } } } @@ -1147,11 +1145,11 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I } if (enableGradient) { - vignmul *= calcGradientFactor(gp, cx + x, cy + y); + vignmul *= static_cast(calcGradientFactor(gp, cx + x, cy + y)); } if (enablePCVignetting) { - vignmul *= calcPCVignetteFactor(pcv, cx + x, cy + y); + vignmul *= static_cast(calcPCVignetteFactor(pcv, cx + x, cy + y)); } if (yc > 0 && yc < original->getHeight() - 2 && xc > 0 && xc < original->getWidth() - 2) { diff --git a/rtengine/ipvibrance.cc b/rtengine/ipvibrance.cc index 14e5f3c44..8636ecb95 100644 --- a/rtengine/ipvibrance.cc +++ b/rtengine/ipvibrance.cc @@ -48,7 +48,7 @@ void fillCurveArrayVib (DiagonalCurve* diagCurve, LUTf &outCurve) // change to [0,1] range // apply custom/parametric/NURBS curve, if any // and store result in a temporary array - outCurve[i] = 65535.f * diagCurve->getVal ( double (i) / 65535.0 ); + outCurve[i] = 65535.0 * diagCurve->getVal(i / 65535.0); } } else { outCurve.makeIdentity(); @@ -606,7 +606,7 @@ void ImProcFunctions::vibrance (LabImage* lab) bool inGamut; const float fyy = Color::c1By116 * Lprov + Color::c16By116; - const float yy_ = (Lprov > Color::epskap) ? fyy * fyy*fyy : Lprov / Color::kappaf; + const float yy_ = (Lprov > static_cast(Color::epskap)) ? fyy * fyy*fyy : Lprov / Color::kappaf; float ChprovOld = std::numeric_limits::min(); do { inGamut = true; diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index f2c8c8182..b9a8132e4 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -51,13 +51,6 @@ #include "cplx_wavelet_dec.h" -#define TS 64 // Tile size -#define offset 25 // shift between tiles -#define fTS ((TS/2+1)) // second dimension of Fourier tiles -#define blkrad 1 // radius of block averaging - -#define epsilon 0.001f/(TS*TS) //tolerance - namespace rtengine { @@ -916,10 +909,10 @@ void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const //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.f) * (1.f + cp.lev0n / 25.f)); + vari[1] = 8.f * SQR((cp.lev1n / 125.f) * (1.f + cp.lev1n / 25.f)); + vari[2] = 8.f * SQR((cp.lev2n / 125.f) * (1.f + cp.lev2n / 25.f)); + vari[3] = 8.f * SQR((cp.lev3n / 125.f) * (1.f + cp.lev3n / 25.f)); if ((cp.lev0n > 0.1f || cp.lev1n > 0.1f || cp.lev2n > 0.1f || cp.lev3n > 0.1f) && cp.noiseena) { int edge = 1; @@ -1135,7 +1128,7 @@ void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const 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; + chprovBuffer[col] = Chprov1 / 327.68f; } } @@ -1374,7 +1367,7 @@ void ImProcFunctions::Aver(float * RESTRICT DataList, int datalen, float &avera for (int i = 0; i < datalen; i++) { if (DataList[i] >= thres) { - averaP += DataList[i]; + averaP += static_cast(DataList[i]); if (DataList[i] > lmax) { lmax = DataList[i]; @@ -1382,7 +1375,7 @@ void ImProcFunctions::Aver(float * RESTRICT DataList, int datalen, float &avera countP++; } else if (DataList[i] < -thres) { - averaN += DataList[i]; + averaN += static_cast(DataList[i]); if (DataList[i] < lmin) { lmin = DataList[i]; @@ -1428,10 +1421,10 @@ void ImProcFunctions::Sigma(float * RESTRICT DataList, int datalen, float avera for (int i = 0; i < datalen; i++) { if (DataList[i] >= thres) { - variP += SQR(DataList[i] - averagePlus); + variP += static_cast(SQR(DataList[i] - averagePlus)); countP++; } else if (DataList[i] <= -thres) { - variN += SQR(DataList[i] - averageNeg); + variN += static_cast(SQR(DataList[i] - averageNeg)); countN++; } } @@ -1703,7 +1696,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * #endif for (int i = 0; i < W_L * H_L; i++) { - avedbl += WavCoeffs_L0[i]; + avedbl += static_cast(WavCoeffs_L0[i]); } #ifdef _OPENMP @@ -1796,7 +1789,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float * #pragma omp parallel num_threads(wavNestedLevels) if(wavNestedLevels>1) #endif { - if (contrast != 0.f && cp.resena && max0 > 0.0) { // contrast = 0.f means that all will be multiplied by 1.f, so we can skip this step + if(contrast != 0.f && cp.resena && max0 > 0.f) { // contrast = 0.f means that all will be multiplied by 1.f, so we can skip this step { #ifdef _OPENMP @@ -2084,7 +2077,7 @@ void ImProcFunctions::WaveletAandBAllAB(wavelet_decomposition &WaveletCoeffs_a, 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 ! + float valparam = (static_cast(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; @@ -3103,9 +3096,8 @@ void ImProcFunctions::ContAllL(float *koeLi[12], float *maxkoeLi, bool lipschitz 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 = static_cast(ChCurve->getVal(Color::huelab_to_huehsv2(modhue2))) - 0.5f; //get valparam=f(H) if (valparam > 0.f) { scale2 = 1.f + 3.f * valparam; //arbitrary value diff --git a/rtengine/jdatasrc.cc b/rtengine/jdatasrc.cc index 8c04a14a2..e461b60f5 100644 --- a/rtengine/jdatasrc.cc +++ b/rtengine/jdatasrc.cc @@ -25,11 +25,6 @@ #define JFREAD(file,buf,sizeofbuf) \ ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) -#define JFWRITE(file,buf,sizeofbuf) \ - ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) - - - /* Expanded data source object for stdio input */ namespace diff --git a/rtengine/klt/selectGoodFeatures.cc b/rtengine/klt/selectGoodFeatures.cc index 20e67fb2e..ccd7681db 100644 --- a/rtengine/klt/selectGoodFeatures.cc +++ b/rtengine/klt/selectGoodFeatures.cc @@ -9,7 +9,6 @@ #include /* fflush() */ #include /* memset() */ #include /* fsqrt() */ -#define fsqrt(X) sqrt(X) /* Our includes */ #include "base.h" diff --git a/rtengine/labimage.h b/rtengine/labimage.h index 79f003b07..7140d9de0 100644 --- a/rtengine/labimage.h +++ b/rtengine/labimage.h @@ -23,7 +23,7 @@ namespace rtengine { -class LabImage +class LabImage final { private: void allocLab(size_t w, size_t h); diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index c80a126f5..1826101e7 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -42,7 +42,6 @@ class rtengine::LCPProfile::LCPPersModel public: LCPPersModel(); bool hasModeData(LCPCorrectionMode mode) const; - void print() const; float focLen; float focDist; @@ -82,27 +81,18 @@ bool rtengine::LCPModelCommon::empty() const && param[2] == 0.0f; } -void rtengine::LCPModelCommon::print() const -{ - std::printf("focLen %g/%g; imgCenter %g/%g; scale %g; err %g\n", foc_len_x, foc_len_y, img_center_x, img_center_y, scale_factor, mean_error); - std::printf("xy0 %g/%g fxy %g/%g\n", x0, y0, fx, fy); - std::printf("param: %g/%g/%g/%g/%g\n", param[0], param[1], param[2], param[3], param[4]); -} - // weighted merge two parameters void rtengine::LCPModelCommon::merge(const LCPModelCommon& a, const LCPModelCommon& b, float facA) { - const float facB = 1.0f - facA; - - foc_len_x = facA * a.foc_len_x + facB * b.foc_len_x; - foc_len_y = facA * a.foc_len_y + facB * b.foc_len_y; - img_center_x = facA * a.img_center_x + facB * b.img_center_x; - img_center_y = facA * a.img_center_y + facB * b.img_center_y; - scale_factor = facA * a.scale_factor + facB * b.scale_factor; - mean_error = facA * a.mean_error + facB * b.mean_error; + foc_len_x = rtengine::intp(facA, a.foc_len_x, b.foc_len_x); + foc_len_y = rtengine::intp(facA, a.foc_len_y, b.foc_len_y); + img_center_x = rtengine::intp(facA, a.img_center_x, b.img_center_x); + img_center_y = rtengine::intp(facA, a.img_center_y, b.img_center_y); + scale_factor = rtengine::intp(facA, a.scale_factor, b.scale_factor); + mean_error = rtengine::intp(facA, a.mean_error, b.mean_error); for (int i = 0; i < 5; ++i) { - param[i] = facA * a.param[i] + facB * b.param[i]; + param[i] = rtengine::intp(facA, a.param[i], b.param[i]); } const float param0Sqr = param[0] * param[0]; @@ -152,7 +142,6 @@ void rtengine::LCPModelCommon::prepareParams( rfx = 1.0f / fx; rfy = 1.0f / fy; - //std::printf("FW %i /X0 %g FH %i /Y0 %g %g\n",fullWidth,x0,fullHeight,y0, imgYCenter); } rtengine::LCPProfile::LCPPersModel::LCPPersModel() : @@ -188,35 +177,6 @@ bool rtengine::LCPProfile::LCPPersModel::hasModeData(LCPCorrectionMode mode) con return false; } -void rtengine::LCPProfile::LCPPersModel::print() const -{ - std::printf("--- PersModel focLen %g; focDist %g; aperture %g\n", focLen, focDist, aperture); - std::printf("Base:\n"); - base.print(); - - if (!chromRG.empty()) { - std::printf("ChromRG:\n"); - chromRG.print(); - } - - if (!chromG.empty()) { - std::printf("ChromG:\n"); - chromG.print(); - } - - if (!chromBG.empty()) { - std::printf("ChromBG:\n"); - chromBG.print(); - } - - if (!vignette.empty()) { - std::printf("Vignette:\n"); - vignette.print(); - } - - std::printf("\n"); -} - rtengine::LCPProfile::LCPProfile(const Glib::ustring& fname) : isFisheye(false), sensorFormatFactor(1.f), @@ -522,7 +482,7 @@ void rtengine::LCPProfile::calcParams( ) { // Mix in aperture const float facAperLow = (pHigh->aperture - aperture) / (pHigh->aperture - pLow->aperture); - facLow = focLenOnSpot ? facAperLow : (0.5 * facLow + 0.5 * facAperLow); + facLow = focLenOnSpot ? facAperLow : (0.5f * (facLow + facAperLow)); } else if ( mode != LCPCorrectionMode::VIGNETTE @@ -532,7 +492,7 @@ void rtengine::LCPProfile::calcParams( ) { // focus distance for all else (if focus distance is given) const float facDistLow = (std::log(pHigh->focDist) + euler - focusDistLog) / (std::log(pHigh->focDist) - std::log(pLow->focDist)); - facLow = focLenOnSpot ? facDistLow : (0.8 * facLow + 0.2 * facDistLow); + facLow = focLenOnSpot ? facDistLow : (0.8f * facLow + 0.2f * facDistLow); } switch (mode) { @@ -555,7 +515,16 @@ void rtengine::LCPProfile::calcParams( } if (settings->verbose) { - std::printf("LCP mode=%i, dist: %g found frames: Fno %g-%g; FocLen %g-%g; Dist %g-%g with weight %g\n", toUnderlying(mode), focusDist, pLow->aperture, pHigh->aperture, pLow->focLen, pHigh->focLen, pLow->focDist, pHigh->focDist, facLow); + std::printf("LCP mode=%i, dist: %g found frames: Fno %g-%g; FocLen %g-%g; Dist %g-%g with weight %g\n", + toUnderlying(mode), + static_cast(focusDist), + static_cast(pLow->aperture), + static_cast(pHigh->aperture), + static_cast(pLow->focLen), + static_cast(pHigh->focLen), + static_cast(pLow->focDist), + static_cast(pHigh->focDist), + static_cast(facLow)); } } else { if (settings->verbose) { @@ -564,15 +533,6 @@ void rtengine::LCPProfile::calcParams( } } -void rtengine::LCPProfile::print() const -{ - std::printf("=== Profile %s\n", profileName.c_str()); - std::printf("Frames: %i, RAW: %i; Fisheye: %i; Sensorformat: %f\n", persModelCount, isRaw, isFisheye, sensorFormatFactor); - - for (int pm = 0; pm < persModelCount; ++pm) { - aPersModel[pm]->print(); - } -} // from all frames not marked as bad already, take average and filter out frames with higher deviation than this if there are enough values int rtengine::LCPProfile::filterBadFrames(LCPCorrectionMode mode, double maxAvgDevFac, int minFramesLeft) @@ -649,7 +609,7 @@ int rtengine::LCPProfile::filterBadFrames(LCPCorrectionMode mode, double maxAvgD } if (settings->verbose && count) { - std::printf("Filtered %.1f%% frames for maxAvgDevFac %g leaving %i\n", filtered * 100.f / count, maxAvgDevFac, count - filtered); + std::printf("Filtered %.1f%% frames for maxAvgDevFac %g leaving %i\n", filtered * 100.0 / count, maxAvgDevFac, count - filtered); } } @@ -1007,7 +967,7 @@ rtengine::LCPMapper::LCPMapper( const bool mirrorX = (rot == 90 || rot == 180); const bool mirrorY = (rot == 180 || rot == 270); if (settings->verbose) { - std::printf("Vign: %i, fullWidth: %i/%i, focLen %g SwapXY: %i / MirX/Y %i / %i on rot:%i from %i\n",vignette, fullWidth, fullHeight, focalLength, swapXY, mirrorX, mirrorY, rot, rawRotationDeg); + std::printf("Vign: %i, fullWidth: %i/%i, focLen %g SwapXY: %i / MirX/Y %i / %i on rot:%i from %i\n",vignette, fullWidth, fullHeight, static_cast(focalLength), swapXY, mirrorX, mirrorY, rot, rawRotationDeg); } pProf->calcParams(vignette ? LCPCorrectionMode::VIGNETTE : LCPCorrectionMode::DISTORTION, focalLength, focusDist, aperture, &mc, nullptr, nullptr); @@ -1038,8 +998,8 @@ void rtengine::LCPMapper::correctDistortion(double &x, double &y, int cx, int cy if (isFisheye) { const double u = x * scale; const double v = y * scale; - const double u0 = mc.x0 * scale; - const double v0 = mc.y0 * scale; + const double u0 = static_cast(mc.x0) * scale; + const double v0 = static_cast(mc.y0) * scale; const double du = (u - u0); const double dv = (v - v0); const double fx = mc.fx; @@ -1059,22 +1019,22 @@ void rtengine::LCPMapper::correctDistortion(double &x, double &y, int cx, int cy } else { x *= scale; y *= scale; - const double x0 = mc.x0 * scale; - const double y0 = mc.y0 * scale; - const double xd = (x - x0) / mc.fx, yd = (y - y0) / mc.fy; + const double x0 = static_cast(mc.x0) * scale; + const double y0 = static_cast(mc.y0) * scale; + const double xd = (x - x0) / static_cast(mc.fx), yd = (y - y0) / static_cast(mc.fy); - const LCPModelCommon::Param aDist = mc.param; + const auto& aDist = mc.param; const double rsqr = xd * xd + yd * yd; - const double xfac = aDist[swapXY ? 3 : 4], yfac = aDist[swapXY ? 4 : 3]; + const double xfac = static_cast(aDist[swapXY ? 3 : 4]), yfac = static_cast(aDist[swapXY ? 4 : 3]); - const double commonFac = (((aDist[2] * rsqr + aDist[1]) * rsqr + aDist[0]) * rsqr + 1.) + const double commonFac = (((static_cast(aDist[2]) * rsqr + static_cast(aDist[1])) * rsqr + static_cast(aDist[0])) * rsqr + 1.) + 2. * (yfac * yd + xfac * xd); const double xnew = xd * commonFac + xfac * rsqr; const double ynew = yd * commonFac + yfac * rsqr; - x = xnew * mc.fx + x0; - y = ynew * mc.fy + y0; + x = xnew * static_cast(mc.fx) + x0; + y = ynew * static_cast(mc.fy) + y0; } x -= cx * scale; @@ -1094,20 +1054,20 @@ void rtengine::LCPMapper::correctCA(double& x, double& y, int cx, int cy, int ch // First calc the green channel like normal distortion // the other are just deviations from it - double xd = (x - chrom[1].x0) / chrom[1].fx; - double yd = (y - chrom[1].y0) / chrom[1].fy; + double xd = (x - static_cast(chrom[1].x0)) / static_cast(chrom[1].fx); + double yd = (y - static_cast(chrom[1].y0)) / static_cast(chrom[1].fy); // Green contains main distortion, just like base if (useCADist) { - const LCPModelCommon::Param aDist = chrom[1].param; - double rsqr = xd * xd + yd * yd; - double xfac = aDist[swapXY ? 3 : 4], yfac = aDist[swapXY ? 4 : 3]; + const auto& aDist = chrom[1].param; + double rsqr = xd * xd + yd * yd; + double xfac = static_cast(aDist[swapXY ? 3 : 4]), yfac = static_cast(aDist[swapXY ? 4 : 3]); - double commonFac = (((aDist[2] * rsqr + aDist[1]) * rsqr + aDist[0]) * rsqr + 1.) + double commonFac = (((static_cast(aDist[2]) * rsqr + static_cast(aDist[1])) * rsqr + static_cast(aDist[0])) * rsqr + 1.) + 2. * (yfac * yd + xfac * xd); - xgreen = xd * commonFac + aDist[4] * rsqr; - ygreen = yd * commonFac + aDist[3] * rsqr; + xgreen = xd * commonFac + static_cast(aDist[4]) * rsqr; + ygreen = yd * commonFac + static_cast(aDist[3]) * rsqr; } else { xgreen = xd; ygreen = yd; @@ -1115,20 +1075,20 @@ void rtengine::LCPMapper::correctCA(double& x, double& y, int cx, int cy, int ch if (channel == 1) { // green goes directly - x = xgreen * chrom[1].fx + chrom[1].x0; - y = ygreen * chrom[1].fy + chrom[1].y0; + x = xgreen * static_cast(chrom[1].fx) + static_cast(chrom[1].x0); + y = ygreen * static_cast(chrom[1].fy) + static_cast(chrom[1].y0); } else { // others are diffs from green xd = xgreen; yd = ygreen; const double rsqr = xd * xd + yd * yd; - const LCPModelCommon::Param aCA = chrom[channel].param; - const double xfac = aCA[swapXY ? 3 : 4], yfac = aCA[swapXY ? 4 : 3]; - const double commonSum = 1. + rsqr * (aCA[0] + rsqr * (aCA[1] + aCA[2] * rsqr)) + 2. * (yfac * yd + xfac * xd); + const auto& aCA = chrom[channel].param; + const double xfac = static_cast(aCA[swapXY ? 3 : 4]), yfac = static_cast(aCA[swapXY ? 4 : 3]); + const double commonSum = 1. + rsqr * (static_cast(aCA[0]) + rsqr * (static_cast(aCA[1]) + static_cast(aCA[2] )* rsqr)) + 2. * (yfac * yd + xfac * xd); - x = (chrom[channel].scale_factor * ( xd * commonSum + xfac * rsqr )) * chrom[channel].fx + chrom[channel].x0; - y = (chrom[channel].scale_factor * ( yd * commonSum + yfac * rsqr )) * chrom[channel].fy + chrom[channel].y0; + x = (static_cast(chrom[channel].scale_factor) * ( xd * commonSum + xfac * rsqr )) * static_cast(chrom[channel].fx) + static_cast(chrom[channel].x0); + y = (static_cast(chrom[channel].scale_factor) * ( yd * commonSum + yfac * rsqr )) * static_cast(chrom[channel].fy) + static_cast(chrom[channel].y0); } x -= cx; diff --git a/rtengine/lcp.h b/rtengine/lcp.h index 2e36fe113..4c1e09865 100644 --- a/rtengine/lcp.h +++ b/rtengine/lcp.h @@ -54,7 +54,6 @@ public: LCPModelCommon(); bool empty() const; // is it empty - void print() const; // printf all values void merge(const LCPModelCommon& a, const LCPModelCommon& b, float facA); void prepareParams( int fullWidth, @@ -106,7 +105,6 @@ public: LCPModelCommon *pCorr3 ) const; // Interpolates between the persModels frames - void print() const; //private: // Common data diff --git a/rtengine/lmmse_demosaic.cc b/rtengine/lmmse_demosaic.cc index f4af1b801..5c4ddffed 100644 --- a/rtengine/lmmse_demosaic.cc +++ b/rtengine/lmmse_demosaic.cc @@ -334,7 +334,7 @@ void RawImageSource::lmmse_interpolate_omp(int winw, int winh, const array2D +* +* RawTherapee is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* RawTherapee is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with RawTherapee. If not, see . +*/ + +#include "color.h" + +using namespace std; + +namespace rtengine +{ + +/* + * MunsellLch correction + * Copyright (c) 2012 Jacques Desmis + * Copyright (c) 2020 Ingo Weyrich + * + * Find the right LUT and calculate the correction + */ +void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, float &correction, int zone, float &lbe, bool &correctL) +{ + + const int x = memChprov; + int y = chrom; + + //begin PB correction + sky + if (zone == 1) { + if (lum > 5.f) { + if (lum < 15.f) { + if (x <= 45 && (hue >= (_15PB10[x] - 0.035f)) && (hue < (_15PB10[x] + 0.052f))) { + if (y > 49) { + y = 49; + } + correction = _15PB10[y] - _15PB10[x] ; + lbe = _15PB10[y]; + correctL = true; + } else if (x <= 85 && (hue >= ( _3PB10[x] - 0.052f)) && (hue < (_45PB10[x] + _3PB10[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _3PB10[y] - _3PB10[x]; + lbe = _3PB10[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_45PB10[x] + _3PB10[x]) * 0.5f) && (hue < (_45PB10[x] + 0.052f))) { + if (y > 89) { + y = 89; + } + correction = _45PB10[y] - _45PB10[x] ; + lbe = _45PB10[y]; + correctL = true; + } else if ((hue >= (_6PB10[x] - 0.052f) && (hue < (_6PB10[x] + _75PB10[x]) * 0.5f))) { + correction = _6PB10[y] - _6PB10[x] ; + lbe = _6PB10[y]; + correctL = true; + } else if ((hue >= (_6PB10[x] + _75PB10[x]) * 0.5f) && (hue < (_9PB10[x] + _75PB10[x]) * 0.5f)) { + correction = _75PB10[y] - _75PB10[x] ; + lbe = _75PB10[y]; + correctL = true; + } else if ((hue >= (_9PB10[x] + _75PB10[x]) * 0.5f) && (hue < (_9PB10[x] + _10PB10[x]) * 0.5f)) { + correction = _9PB10[y] - _9PB10[x] ; + lbe = _9PB10[y]; + correctL = true; + } else if ((hue >= (_10PB10[x] + _9PB10[x]) * 0.5f) && (hue < (_1P10[x] + _10PB10[x]) * 0.5f)) { + correction = _10PB10[y] - _10PB10[x] ; + lbe = _10PB10[y]; + correctL = true; + } else if ((hue >= (_10PB10[x] + _1P10[x]) * 0.5f) && (hue < (_1P10[x] + _4P10[x]) * 0.5f)) { + correction = _1P10[y] - _1P10[x]; + lbe = _1P10[y]; + correctL = true; + } else if ((hue >= (_1P10[x] + _4P10[x]) * 0.5f) && (hue < (0.035f + _4P10[x]) * 0.5f)) { + correction = _4P10[y] - _4P10[x] ; + lbe = _4P10[y]; + correctL = true; + } + } else if (lum < 25.f) { + if (x <= 85 && (hue >= (_15PB20[x] - 0.035f)) && (hue < (_15PB20[x] + _3PB20[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _15PB20[y] - _15PB20[x] ; + lbe = _15PB20[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_15PB20[x] + _3PB20[x]) * 0.5f) && (hue < (_45PB20[x] + _3PB20[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _3PB20[y] - _3PB20[x] ; + lbe = _3PB20[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_45PB20[x] + _3PB20[x]) * 0.5f) && (hue < ( _45PB20[x] + 0.052f))) { + if (y > 89) { + y = 89; + } + correction = _45PB20[y] - _45PB20[x] ; + lbe = _45PB20[y]; + correctL = true; + } else if ((hue >= (_45PB20[x] + 0.052f)) && (hue < (_6PB20[x] + _75PB20[x]) * 0.5f)) { + correction = _6PB20[y] - _6PB20[x]; + lbe = _6PB20[y]; + correctL = true; + } else if ((hue >= (_6PB20[x] + _75PB20[x]) * 0.5f) && (hue < (_9PB20[x] + _75PB20[x]) * 0.5f)) { + correction = _75PB20[y] - _75PB20[x] ; + lbe = _75PB20[y]; + correctL = true; + } else if ((hue >= (_9PB20[x] + _75PB20[x]) * 0.5f) && (hue < (_9PB20[x] + _10PB20[x]) * 0.5f)) { + correction = _9PB20[y] - _9PB20[x] ; + lbe = _9PB20[y]; + correctL = true; + } else if ((hue >= (_10PB20[x] + _9PB20[x]) * 0.5f) && (hue < (_1P20[x] + _10PB20[x]) * 0.5f)) { + correction = _10PB20[y] - _10PB20[x] ; + lbe = _10PB20[y]; + correctL = true; + } else if ((hue >= (_10PB20[x] + _1P20[x]) * 0.5f) && (hue < (_1P20[x] + _4P20[x]) * 0.5f)) { + correction = _1P20[y] - _1P20[x] ; + lbe = _1P20[y]; + correctL = true; + } else if ((hue >= (_1P20[x] + _4P20[x]) * 0.5f) && (hue < (0.035f + _4P20[x]) * 0.5f)) { + correction = _4P20[y] - _4P20[x] ; + lbe = _4P20[y]; + correctL = true; + } + } else if (lum < 35.f) { + if (x <= 85 && (hue >= (_15PB30[x] - 0.035f)) && (hue < (_15PB30[x] + _3PB30[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _15PB30[y] - _15PB30[x] ; + lbe = _15PB30[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_15PB30[x] + _3PB30[x]) * 0.5f) && (hue < (_45PB30[x] + _3PB30[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _3PB30[y] - _3PB30[x] ; + lbe = _3PB30[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_45PB30[x] + _3PB30[x]) * 0.5f) && (hue < (_45PB30[x] + 0.052f))) { + if (y > 89) { + y = 89; + } + correction = _45PB30[y] - _45PB30[x] ; + lbe = _45PB30[y]; + correctL = true; + } else if ((hue >= ( _45PB30[x] + 0.052f)) && (hue < (_6PB30[x] + _75PB30[x]) * 0.5f)) { + correction = _6PB30[y] - _6PB30[x] ; + lbe = _6PB30[y]; + correctL = true; + } else if ((hue >= (_6PB30[x] + _75PB30[x]) * 0.5f) && (hue < (_9PB30[x] + _75PB30[x]) * 0.5f)) { + correction = _75PB30[y] - _75PB30[x] ; + lbe = _75PB30[y] ; + correctL = true; + } else if ((hue >= (_9PB30[x] + _75PB30[x]) * 0.5f) && (hue < (_9PB30[x] + _10PB30[x]) * 0.5f)) { + correction = _9PB30[y] - _9PB30[x] ; + lbe = _9PB30[y]; + correctL = true; + } else if ((hue >= (_10PB30[x] + _9PB30[x]) * 0.5f) && (hue < (_1P30[x] + _10PB30[x]) * 0.5f)) { + correction = _10PB30[y] - _10PB30[x] ; + lbe = _10PB30[y]; + correctL = true; + } else if ((hue >= (_10PB30[x] + _1P30[x]) * 0.5f) && (hue < (_1P30[x] + _4P30[x]) * 0.5f)) { + correction = _1P30[y] - _1P30[x] ; + lbe = _1P30[y]; + correctL = true; + } else if ((hue >= (_1P30[x] + _4P30[x]) * 0.5f) && (hue < (0.035f + _4P30[x]) * 0.5f)) { + correction = _4P30[y] - _4P30[x] ; + lbe = _4P30[y]; + correctL = true; + } + } else if (lum < 45.f) { + if (x < 75 && (hue <= (_05PB40[x] + _15PB40[x]) * 0.5f) && (hue > (_05PB40[x] + _10B40[x]) * 0.5f)) { + if (y > 75) { + y = 75; + } + correction = _05PB40[y] - _05PB40[x] ; + lbe = _05PB40[y]; + correctL = true; + } else if (x < 70 && (hue <= (_05PB40[x] + _10B40[x]) * 0.5f) && (hue > (_10B40[x] + _9B40[x]) * 0.5f)) { + if (y > 70) { + y = 70; + } + correction = _10B40[y] - _10B40[x] ; + lbe = _10B40[y]; + correctL = true; + } else if (x < 70 && (hue <= (_10B40[x] + _9B40[x]) * 0.5f) && (hue > (_9B40[x] + _7B40[x]) * 0.5f)) { + if (y > 70) { + y = 70; + } + correction = _9B40[y] - _9B40[x] ; + lbe = _9B40[y]; + correctL = true; + } else if (x < 70 && (hue <= (_9B40[x] + _7B40[x]) * 0.5f) && (hue > (_5B40[x] + _7B40[x]) * 0.5f)) { + if (y > 70) { + y = 70; + } + correction = _7B40[y] - _7B40[x] ; + lbe = _7B40[y]; + correctL = true; + } else if (x < 70 && (hue <= (_5B40[x] + _7B40[x]) * 0.5f) && (hue > (_5B40[x] - 0.035f))) { + if (y > 70) { + y = 70; // + } + correction = _5B40[y] - _5B40[x] ; + lbe = _5B40[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_15PB40[x] - 0.035f)) && (hue < (_15PB40[x] + _3PB40[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _15PB40[y] - _15PB40[x] ; + lbe = _15PB40[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_15PB40[x] + _3PB40[x]) * 0.5f) && (hue < (_45PB40[x] + _3PB40[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _3PB40[y] - _3PB40[x] ; + lbe = _3PB40[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_45PB40[x] + _3PB40[x]) * 0.5f) && (hue < (_45PB40[x] + 0.052f))) { + if (y > 89) { + y = 89; + } + correction = _45PB40[y] - _45PB40[x] ; + lbe = _45PB40[y] ; + correctL = true; + } else if ((hue >= (_45PB40[x] + 0.052f)) && (hue < (_6PB40[x] + _75PB40[x]) * 0.5f)) { + correction = _6PB40[y] - _6PB40[x] ; + lbe = _6PB40[y]; + correctL = true; + } else if ((hue >= (_6PB40[x] + _75PB40[x]) * 0.5f) && (hue < (_9PB40[x] + _75PB40[x]) * 0.5f)) { + correction = _75PB40[y] - _75PB40[x] ; + lbe = _75PB40[y]; + correctL = true; + } else if ((hue >= (_9PB40[x] + _75PB40[x]) * 0.5f) && (hue < (_9PB40[x] + _10PB40[x]) * 0.5f)) { + correction = _9PB40[y] - _9PB40[x] ; + lbe = _9PB40[y]; + correctL = true; + } else if ((hue >= (_10PB40[x] + _9PB40[x]) * 0.5f) && (hue < (_1P40[x] + _10PB40[x]) * 0.5f)) { + correction = _10PB40[y] - _10PB40[x] ; + lbe = _10PB40[y]; + correctL = true; + } else if ((hue >= (_10PB40[x] + _1P40[x]) * 0.5f) && (hue < (_1P40[x] + _4P40[x]) * 0.5f)) { + correction = _1P40[y] - _1P40[x] ; + lbe = _1P40[y]; + correctL = true; + } else if ((hue >= (_1P40[x] + _4P40[x]) * 0.5f) && (hue < (0.035f + _4P40[x]) * 0.5f)) { + correction = _4P40[y] - _4P40[x] ; + lbe = _4P40[y]; + correctL = true; + } + } else if (lum < 55.f) { + if (x < 79 && (hue <= (_05PB50[x] + _15PB50[x]) * 0.5f) && (hue > (_05PB50[x] + _10B50[x]) * 0.5f)) { + if (y > 79) { + y = 79; + } + correction = _05PB50[y] - _05PB50[x] ; + lbe = _05PB50[y]; + correctL = true; + } else if (x < 79 && (hue <= (_05PB50[x] + _10B50[x]) * 0.5f) && (hue > (_10B50[x] + _9B50[x]) * 0.5f)) { + if (y > 79) { + y = 79; + } + correction = _10B50[y] - _10B50[x] ; + lbe = _10B50[y]; + correctL = true; + } else if (x < 79 && (hue <= (_10B50[x] + _9B50[x]) * 0.5f) && (hue > (_9B50[x] + _7B50[x]) * 0.5f)) { + if (y > 79) { + y = 79; + } + correction = _9B50[y] - _9B50[x] ; + lbe = _9B50[y]; + correctL = true; + } else if (x < 79 && (hue <= (_9B50[x] + _7B50[x]) * 0.5f) && (hue > (_5B50[x] + _7B50[x]) * 0.5f)) { + if (y > 79) { + y = 79; + } + correction = _7B50[y] - _7B50[x] ; + lbe = _7B50[y]; + correctL = true; + } else if (x < 79 && (hue <= (_5B50[x] + _7B50[x]) * 0.5f) && (hue > (_5B50[x] - 0.035f))) { + if (y > 79) { + y = 79; // + } + correction = _5B50[y] - _5B50[x] ; + lbe = _5B50[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_15PB50[x] - 0.035f)) && (hue < (_15PB50[x] + _3PB50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _15PB50[y] - _15PB50[x] ; + lbe = _15PB50[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_15PB50[x] + _3PB50[x]) * 0.5f) && (hue < (_45PB50[x] + _3PB50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _3PB50[y] - _3PB50[x] ; + lbe = _3PB50[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_45PB50[x] + _3PB50[x]) * 0.5f) && (hue < (_6PB50[x] + _45PB50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _45PB50[y] - _45PB50[x] ; + lbe = _45PB50[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_6PB50[x] + _45PB50[x]) * 0.5f) && (hue < (_6PB50[x] + _75PB50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _6PB50[y] - _6PB50[x] ; + lbe = _6PB50[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_6PB50[x] + _75PB50[x]) * 0.5f) && (hue < (_9PB50[x] + _75PB50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _75PB50[y] - _75PB50[x] ; + lbe = _75PB50[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_9PB50[x] + _75PB50[x]) * 0.5f) && (hue < (_9PB50[x] + _10PB50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _9PB50[y] - _9PB50[x] ; + lbe = _9PB50[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_10PB50[x] + _9PB50[x]) * 0.5f) && (hue < (_1P50[x] + _10PB50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _10PB50[y] - _10PB50[x] ; + lbe = _10PB50[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_10PB50[x] + _1P50[x]) * 0.5f) && (hue < (_1P50[x] + _4P50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _1P50[y] - _1P50[x] ; + lbe = _1P50[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_1P50[x] + _4P50[x]) * 0.5f) && (hue < (0.035f + _4P50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _4P50[y] - _4P50[x] ; + lbe = _4P50[y]; + correctL = true; + } + } else if (lum < 65.f) { + if (x < 79 && (hue <= (_05PB60[x] + _15PB60[x]) * 0.5f) && (hue > (_05PB60[x] + _10B60[x]) * 0.5f)) { + if (y > 79) { + y = 79; + } + correction = _05PB60[y] - _05PB60[x] ; + lbe = _05PB60[y]; + correctL = true; + } else if (x < 79 && (hue <= (_05PB60[x] + _10B60[x]) * 0.5f) && (hue > (_10B60[x] + _9B60[x]) * 0.5f)) { + if (y > 79) { + y = 79; + } + correction = _10B60[y] - _10B60[x] ; + lbe = _10B60[y]; + correctL = true; + } else if (x < 79 && (hue <= (_10B60[x] + _9B60[x]) * 0.5f) && (hue > (_9B60[x] + _7B60[x]) * 0.5f)) { + if (y > 79) { + y = 79; + } + correction = _9B60[y] - _9B60[x] ; + lbe = _9B60[y]; + correctL = true; + } else if (x < 79 && (hue <= (_9B60[x] + _7B60[x]) * 0.5f) && (hue > (_5B60[x] + _7B60[x]) * 0.5f)) { + if (y > 79) { + y = 79; + } + correction = _7B60[y] - _7B60[x] ; + lbe = _7B60[y]; + correctL = true; + } else if (x < 79 && (hue <= (_5B60[x] + _7B60[x]) * 0.5f) && (hue > (_5B60[x] - 0.035f))) { + if (y > 79) { + y = 79; // + } + correction = _5B60[y] - _5B60[x] ; + lbe = _5B60[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_15PB60[x] - 0.035f)) && (hue < (_15PB60[x] + _3PB60[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _15PB60[y] - _15PB60[x] ; + lbe = _15PB60[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_15PB60[x] + _3PB60[x]) * 0.5f) && (hue < (_45PB60[x] + _3PB60[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _3PB60[y] - _3PB60[x] ; + lbe = _3PB60[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_45PB60[x] + _3PB60[x]) * 0.5f) && (hue < (_6PB60[x] + _45PB60[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _45PB60[y] - _45PB60[x] ; + lbe = _45PB60[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_6PB60[x] + _45PB60[x]) * 0.5f) && (hue < (_6PB60[x] + _75PB60[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _6PB60[y] - _6PB60[x] ; + lbe = _6PB60[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_6PB60[x] + _75PB60[x]) * 0.5f) && (hue < (_9PB60[x] + _75PB60[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _75PB60[y] - _75PB60[x] ; + lbe = _75PB60[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_9PB60[x] + _75PB60[x]) * 0.5f) && (hue < (_9PB60[x] + _10PB60[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _9PB60[y] - _9PB60[x] ; + lbe = _9PB60[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_10PB60[x] + _9PB60[x]) * 0.5f) && (hue < (_1P60[x] + _10PB60[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _10PB60[y] - _10PB60[x] ; + lbe = _10PB60[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_10PB60[x] + _1P60[x]) * 0.5f) && (hue < (_1P60[x] + _4P60[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _1P60[y] - _1P60[x] ; + lbe = _1P60[y]; + correctL = true; + } else if (x <= 85 && (hue >= (_1P60[x] + _4P60[x]) * 0.5f) && (hue < (0.035f + _4P60[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _4P60[y] - _4P60[x] ; + lbe = _4P60[y]; + correctL = true; + } + } else if (lum < 75.f) { + if (x < 50 && (hue <= (_05PB70[x] + _15PB70[x]) * 0.5f) && (hue > (_05PB70[x] + _10B70[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _05PB70[y] - _05PB70[x] ; + lbe = _05PB70[y]; + correctL = true; + } else if (x < 50 && (hue <= (_05PB70[x] + _10B70[x]) * 0.5f) && (hue > (_10B70[x] + _9B70[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _10B70[y] - _10B70[x] ; + lbe = _10B70[y]; + correctL = true; + } else if (x < 50 && (hue <= (_10B70[x] + _9B70[x]) * 0.5f) && (hue > (_9B70[x] + _7B70[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _9B70[y] - _9B70[x] ; + lbe = _9B70[y]; + correctL = true; + } else if (x < 50 && (hue <= (_9B70[x] + _7B70[x]) * 0.5f) && (hue > (_5B70[x] + _7B70[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _7B70[y] - _7B70[x] ; + lbe = _7B70[y]; + correctL = true; + } else if (x < 50 && (hue <= (_5B70[x] + _7B70[x]) * 0.5f) && (hue > (_5B70[x] - 0.035f))) { + if (y > 49) { + y = 49; // + } + correction = _5B70[y] - _5B70[x] ; + lbe = _5B70[y]; + correctL = true; + } else if (x < 50 && (hue >= (_15PB70[x] - 0.035f)) && (hue < (_15PB70[x] + _3PB70[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _15PB70[y] - _15PB70[x] ; + lbe = _15PB70[y]; + correctL = true; + } else if (x < 50 && (hue >= (_45PB70[x] + _3PB70[x]) * 0.5f) && (hue < (_6PB70[x] + _45PB70[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _45PB70[y] - _45PB70[x] ; + lbe = _45PB70[y]; + correctL = true; + } else if (x < 50 && (hue >= (_6PB70[x] + _45PB70[x]) * 0.5f) && (hue < (_6PB70[x] + _75PB70[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _6PB70[y] - _6PB70[x] ; + lbe = _6PB70[y]; + correctL = true; + } else if (x < 50 && (hue >= (_6PB70[x] + _75PB70[x]) * 0.5f) && (hue < (_9PB70[x] + _75PB70[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _75PB70[y] - _75PB70[x] ; + lbe = _75PB70[y]; + correctL = true; + } else if (x < 50 && (hue >= (_9PB70[x] + _75PB70[x]) * 0.5f) && (hue < (_9PB70[x] + 0.035f))) { + if (y > 49) { + y = 49; + } + correction = _9PB70[y] - _9PB70[x] ; + lbe = _9PB70[y]; + correctL = true; + } + } else if (lum < 85.f) { + if (x < 40 && (hue <= (_05PB80[x] + _15PB80[x]) * 0.5f) && (hue > (_05PB80[x] + _10B80[x]) * 0.5f)) { + if (y > 39) { + y = 39; + } + correction = _05PB80[y] - _05PB80[x] ; + lbe = _05PB80[y] ; + correctL = true; + } else if (x < 40 && (hue <= (_05PB80[x] + _10B80[x]) * 0.5f) && (hue > (_10B80[x] + _9B80[x]) * 0.5f)) { + if (y > 39) { + y = 39; + } + correction = _10B80[y] - _10B80[x] ; + lbe = _10B80[y]; + correctL = true; + } else if (x < 40 && (hue <= (_10B80[x] + _9B80[x]) * 0.5f) && (hue > (_9B80[x] + _7B80[x]) * 0.5f)) { + if (y > 39) { + y = 39; + } + correction = _9B80[y] - _9B80[x] ; + lbe = _9B80[y]; + correctL = true; + } else if (x < 50 &&(hue <= (_9B80[x] + _7B80[x]) * 0.5f) && (hue > (_5B80[x] + _7B80[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _7B80[y] - _7B80[x] ; + lbe = _7B80[y]; + correctL = true; + } else if (x < 50 && (hue <= (_5B80[x] + _7B80[x]) * 0.5f) && (hue > (_5B80[x] - 0.035f))) { + if (y > 49) { + y = 49; // + } + correction = _5B80[y] - _5B80[x] ; + lbe = _5B80[y]; + correctL = true; + } else if (x < 50 && (hue >= (_15PB80[x] - 0.035f)) && (hue < (_15PB80[x] + _3PB80[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _15PB80[y] - _15PB80[x] ; + lbe = _15PB80[y]; + correctL = true; + } else if (x < 50 && (hue >= (_45PB80[x] + _3PB80[x]) * 0.5f) && (hue < (_6PB80[x] + _45PB80[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _45PB80[y] - _45PB80[x] ; + lbe = _45PB80[y]; + correctL = true; + } else if (x < 50 && (hue >= (_6PB80[x] + _45PB80[x]) * 0.5f) && (hue < (_6PB80[x] + _75PB80[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _6PB80[y] - _6PB80[x] ; + lbe = _6PB80[y]; + correctL = true; + } else if (x < 50 && (hue >= (_6PB80[x] + _75PB80[x]) * 0.5f) && (hue < (_9PB80[x] + _75PB80[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _75PB80[y] - _75PB80[x] ; + lbe = _75PB80[y]; + correctL = true; + } else if (x < 50 && (hue >= (_9PB80[x] + _75PB80[x]) * 0.5f) && (hue < (_9PB80[x] + 0.035f))) { + if (y > 49) { + y = 49; + } + correction = _9PB80[y] - _9PB80[x] ; + lbe = _9PB80[y]; + correctL = true; + } + } + } + } else if (zone == 2) { //red yellow correction + if (lum > 15.f) { + if (lum < 25.f) { + if (x <= 45 && (hue <= (_10YR20[x] + 0.035f)) && (hue > (_10YR20[x] + _85YR20[x]) * 0.5f)) { + if (y > 49) { + y = 49; + } + correction = _10YR20[y] - _10YR20[x] ; + lbe = _10YR20[y]; + correctL = true; + } else if (x <= 45 && (hue <= (_85YR20[x] + _10YR20[x]) * 0.5f) && (hue > (_85YR20[x] + 0.035f))) { + if (y > 49) { + y = 49; + } + correction = _85YR20[y] - _85YR20[x] ; + lbe = _85YR20[y]; + correctL = true; + } + } else if (lum < 35.f) { + if (x < 85 && (hue <= (_10YR30[x] + 0.035f)) && (hue > (_10YR30[x] + _85YR30[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _10YR30[y] - _10YR30[x] ; + lbe = _10YR30[y]; + correctL = true; + } else if (x < 85 && (hue <= (_10YR30[x] + _85YR30[x]) * 0.5f) && (hue > (_85YR30[x] + _7YR30[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _85YR30[y] - _85YR30[x] ; + lbe = _85YR30[y]; + correctL = true; + } else if (x < 85 && (hue <= (_85YR30[x] + _7YR30[x]) * 0.5f) && (hue > (_7YR30[x] + _55YR30[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _7YR30[y] - _7YR30[x] ; + lbe = _7YR30[y]; + correctL = true; + } else if (x < 85 && (hue <= (_7YR30[x] + _55YR30[x]) * 0.5f) && (hue > (_55YR30[x] + _4YR30[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _55YR30[y] - _55YR30[x] ; + lbe = _55YR30[y]; + correctL = true; + } else if (x < 85 && (hue <= (_55YR30[x] + _4YR30[x]) * 0.5f) && (hue > (_4YR30[x] + _25YR30[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _4YR30[y] - _4YR30[x] ; + lbe = _4YR30[y]; + correctL = true; + } else if (x < 85 && (hue <= (_4YR30[x] + _25YR30[x]) * 0.5f) && (hue > (_25YR30[x] + _10R30[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _25YR30[y] - _25YR30[x] ; + lbe = _25YR30[y]; + correctL = true; + } else if (x < 85 && (hue <= (_25YR30[x] + _10R30[x]) * 0.5f) && (hue > (_10R30[x] + _9R30[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _10R30[y] - _10R30[x] ; + lbe = _10R30[y]; + correctL = true; + } else if (x < 85 && (hue <= (_10R30[x] + _9R30[x]) * 0.5f) && (hue > (_9R30[x] + _7R30[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _9R30[y] - _9R30[x] ; + lbe = _9R30[y]; + correctL = true; + } else if (x < 85 && (hue <= (_9R30[x] + _7R30[x]) * 0.5f) && (hue > (_7R30[x] - 0.035f))) { + if (y > 89) { + y = 89; + } + + correction = _7R30[y] - _7R30[x] ; + lbe = _7R30[y] ; + correctL = true; + } + } else if (lum < 45.f) { + if (x < 85 && (hue <= (_10YR40[x] + 0.035f)) && (hue > (_10YR40[x] + _85YR40[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _10YR40[y] - _10YR40[x] ; + lbe = _10YR40[y]; + correctL = true; + } else if (x < 85 && (hue <= (_10YR40[x] + _85YR40[x]) * 0.5f) && (hue > (_85YR40[x] + _7YR40[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _85YR40[y] - _85YR40[x] ; + lbe = _85YR40[y]; + correctL = true; + } else if (x < 85 && (hue <= (_85YR40[x] + _7YR40[x]) * 0.5f) && (hue > (_7YR40[x] + _55YR40[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _7YR40[y] - _7YR40[x] ; + lbe = _7YR40[y]; + correctL = true; + } else if (x < 85 && (hue <= (_7YR40[x] + _55YR40[x]) * 0.5f) && (hue > (_55YR40[x] + _4YR40[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _55YR40[y] - _55YR40[x] ; + lbe = _55YR40[y]; + correctL = true; + } else if (x < 85 && (hue <= (_55YR40[x] + _4YR40[x]) * 0.5f) && (hue > (_4YR40[x] + _25YR40[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _4YR40[y] - _4YR40[x] ; + lbe = _4YR40[y]; + correctL = true; + } else if (x < 85 && (hue <= (_4YR40[x] + _25YR40[x]) * 0.5f) && (hue > (_25YR40[x] + _10R40[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _25YR40[y] - _25YR40[x] ; + lbe = _25YR40[y] ; + correctL = true; + } else if (x < 85 && (hue <= (_25YR40[x] + _10R40[x]) * 0.5f) && (hue > (_10R40[x] + _9R40[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _10R40[y] - _10R40[x] ; + lbe = _10R40[y]; + correctL = true; + } else if (x < 85 && (hue <= (_10R40[x] + _9R40[x]) * 0.5f) && (hue > (_9R40[x] + _7R40[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _9R40[y] - _9R40[x] ; + lbe = _9R40[y]; + correctL = true; + } else if (x < 85 && (hue <= (_9R40[x] + _7R40[x]) * 0.5f) && (hue > (_7R40[x] - 0.035f))) { + if (y > 89) { + y = 89; + } + correction = _7R40[y] - _7R40[x] ; + lbe = _7R40[y]; + correctL = true; + } + } else if (lum < 55.f) { + if (x < 85 && (hue <= (_10YR50[x] + 0.035f)) && (hue > (_10YR50[x] + _85YR50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _10YR50[y] - _10YR50[x] ; + lbe = _10YR50[y]; + correctL = true; + } else if (x < 85 && (hue <= (_10YR50[x] + _85YR50[x]) * 0.5f) && (hue > (_85YR50[x] + _7YR50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _85YR50[y] - _85YR50[x] ; + lbe = _85YR50[y]; + correctL = true; + } else if (x < 85 && (hue <= (_85YR50[x] + _7YR50[x]) * 0.5f) && (hue > (_7YR50[x] + _55YR50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _7YR50[y] - _7YR50[x] ; + lbe = _7YR50[y]; + correctL = true; + } else if (x < 85 && (hue <= (_7YR50[x] + _55YR50[x]) * 0.5f) && (hue > (_55YR50[x] + _4YR50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _55YR50[y] - _55YR50[x] ; + lbe = _55YR50[y]; + correctL = true; + } else if (x < 85 && (hue <= (_55YR50[x] + _4YR50[x]) * 0.5f) && (hue > (_4YR50[x] + _25YR50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _4YR50[y] - _4YR50[x] ; + lbe = _4YR50[y]; + correctL = true; + } else if (x < 85 && (hue <= (_4YR50[x] + _25YR50[x]) * 0.5f) && (hue > (_25YR50[x] + _10R50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _25YR50[y] - _25YR50[x] ; + lbe = _25YR50[y]; + correctL = true; + } else if (x < 85 && (hue <= (_25YR50[x] + _10R50[x]) * 0.5f) && (hue > (_10R50[x] + _9R50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _10R50[y] - _10R50[x] ; + lbe = _10R50[y]; + correctL = true; + } else if (x < 85 && (hue <= (_10R50[x] + _9R50[x]) * 0.5f) && (hue > (_9R50[x] + _7R50[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _9R50[y] - _9R50[x] ; + lbe = _9R50[y]; + correctL = true; + } else if (x < 85 && (hue <= (_9R50[x] + _7R50[x]) * 0.5f) && (hue > (_7R50[x] - 0.035f))) { + if (y > 89) { + y = 89; + } + correction = _7R50[y] - _7R50[x] ; + lbe = _7R50[y]; + correctL = true; + } + } else if (lum < 65.f) { + if ((hue <= (_10YR60[x] + 0.035f)) && (hue > (_10YR60[x] + _85YR60[x]) * 0.5f)) { + correction = _10YR60[y] - _10YR60[x] ; + lbe = _10YR60[y]; + correctL = true; + } else if ((hue <= (_10YR60[x] + _85YR60[x]) * 0.5f) && (hue > (_85YR60[x] + _7YR60[x]) * 0.5f)) { + correction = _85YR60[y] - _85YR60[x] ; + lbe = _85YR60[y]; + correctL = true; + } else if ((hue <= (_85YR60[x] + _7YR60[x]) * 0.5f) && (hue > (_7YR60[x] + _55YR60[x]) * 0.5f)) { + correction = _7YR60[y] - _7YR60[x] ; + lbe = _7YR60[y]; + correctL = true; + } else if ((hue <= (_7YR60[x] + _55YR60[x]) * 0.5f) && (hue > (_55YR60[x] + _4YR60[x]) * 0.5f)) { + correction = _55YR60[y] - _55YR60[x] ; + lbe = _55YR60[y]; + correctL = true; + } else if ((hue <= (_55YR60[x] + _4YR60[x]) * 0.5f) && (hue > (_4YR60[x] + _25YR60[x]) * 0.5f)) { + correction = _4YR60[y] - _4YR60[x] ; + lbe = _4YR60[y]; + correctL = true; + } else if (x < 85 && (hue <= (_4YR60[x] + _25YR60[x]) * 0.5f) && (hue > (_25YR60[x] + _10R60[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _25YR60[y] - _25YR60[x] ; + lbe = _25YR60[y]; + correctL = true; + } else if (x < 85 && (hue <= (_25YR60[x] + _10R60[x]) * 0.5f) && (hue > (_10R60[x] + _9R60[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _10R60[y] - _10R60[x] ; + lbe = _10R60[y]; + correctL = true; + } else if (x < 85 && (hue <= (_10R60[x] + _9R60[x]) * 0.5f) && (hue > (_9R60[x] + _7R60[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _9R60[y] - _9R60[x] ; + lbe = _9R60[y]; + correctL = true; + } else if (x < 85 && (hue <= (_9R60[x] + _7R60[x]) * 0.5f) && (hue > (_7R60[x] - 0.035f))) { + if (y > 89) { + y = 89; + } + correction = _7R60[y] - _7R60[x] ; + lbe = _7R60[y]; + correctL = true; + } + } else if (lum < 75.f) { + if ((hue <= (_10YR70[x] + 0.035f)) && (hue > (_10YR70[x] + _85YR70[x]) * 0.5f)) { + correction = _10YR70[y] - _10YR70[x] ; + lbe = _10YR70[y]; + correctL = true; + } else if ((hue <= (_10YR70[x] + _85YR70[x]) * 0.5f) && (hue > (_85YR70[x] + _7YR70[x]) * 0.5f)) { + correction = _85YR70[y] - _85YR70[x] ; + lbe = _85YR70[y]; + correctL = true; + } else if ((hue <= (_85YR70[x] + _7YR70[x]) * 0.5f) && (hue > (_7YR70[x] + _55YR70[x]) * 0.5f)) { + correction = _7YR70[y] - _7YR70[x] ; + lbe = _7YR70[y]; + correctL = true; + } else if ((hue <= (_7YR70[x] + _55YR70[x]) * 0.5f) && (hue > (_55YR70[x] + _4YR70[x]) * 0.5f)) { + correction = _55YR70[y] - _55YR70[x] ; + lbe = _55YR70[y]; + correctL = true; + } else if ((hue <= (_55YR70[x] + _4YR70[x]) * 0.5f) && (hue > (_4YR70[x] + _25YR70[x]) * 0.5f)) { + correction = _4YR70[y] - _4YR70[x] ; + lbe = _4YR70[y]; + correctL = true; + } else if (x < 85 && (hue <= (_4YR70[x] + _25YR70[x]) * 0.5f) && (hue > (_25YR70[x] + _10R70[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _25YR70[y] - _25YR70[x] ; + lbe = _25YR70[y]; + correctL = true; + } else if (x < 85 && (hue <= (_25YR70[x] + _10R70[x]) * 0.5f) && (hue > (_10R70[x] + _9R70[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _10R70[y] - _10R70[x] ; + lbe = _10R70[y]; + correctL = true; + } else if (x < 85 && (hue <= (_10R70[x] + _9R70[x]) * 0.5f) && (hue > (_9R70[x] + _7R70[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _9R70[y] - _9R70[x] ; + lbe = _9R70[y] ; + correctL = true; + } else if (x < 85 && (hue <= (_9R70[x] + _7R70[x]) * 0.5f) && (hue > (_7R70[x] - 0.035f))) { + if (y > 89) { + y = 89; + } + correction = _7R70[y] - _7R70[x] ; + lbe = _7R70[y]; + correctL = true; + } + } else if (lum < 85.f) { + if ((hue <= (_10YR80[x] + 0.035f)) && (hue > (_10YR80[x] + _85YR80[x]) * 0.5f)) { + correction = _10YR80[y] - _10YR80[x] ; + lbe = _10YR80[y]; + correctL = true; + } else if ((hue <= (_10YR80[x] + _85YR80[x]) * 0.5f) && (hue > (_85YR80[x] + _7YR80[x]) * 0.5f)) { + correction = _85YR80[y] - _85YR80[x] ; + lbe = _85YR80[y]; + } else if (x < 85 && (hue <= (_85YR80[x] + _7YR80[x]) * 0.5f) && (hue > (_7YR80[x] + _55YR80[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _7YR80[y] - _7YR80[x] ; + lbe = _7YR80[y]; + correctL = true; + } else if (x < 45 && (hue <= (_7YR80[x] + _55YR80[x]) * 0.5f) && (hue > (_55YR80[x] + _4YR80[x]) * 0.5f)) { + correction = _55YR80[y] - _55YR80[x] ; + lbe = _55YR80[y]; + correctL = true; + } else if (x < 45 && (hue <= (_55YR80[x] + _4YR80[x]) * 0.5f) && (hue > (_4YR80[x] - 0.035f))) { + if (y > 49) { + y = 49; + } + correction = _4YR80[y] - _4YR80[x] ; + lbe = _4YR80[y] ; + correctL = true; + } + } else if (lum < 95.f) { + if (x < 85 && (hue <= (_10YR90[x] + 0.035f)) && (hue > (_10YR90[x] - 0.035f))) { + if (y > 89) { + y = 89; + } + correction = _10YR90[y] - _10YR90[x] ; + lbe = _10YR90[y]; + correctL = true; + } else if (x < 85 && hue <= (_85YR90[x] + 0.035f) && hue > (_85YR90[x] - 0.035f)) { + if (y > 89) { + y = 89; + } + correction = _85YR90[y] - _85YR90[x] ; + lbe = _85YR90[y]; + correctL = true; + } else if (x < 45 && (hue <= (_55YR90[x] + 0.035f) && (hue > (_55YR90[x] - 0.035f)))) { + if (y > 49) { + y = 49; + } + correction = _55YR90[y] - _55YR90[x] ; + lbe = _55YR90[y]; + correctL = true; + } + } + } + } else if (zone == 3) { // //Green yellow correction + if (lum >= 25.f) { + if (lum < 35.f) { + if ((hue <= (_7G30[x] + 0.035f)) && (hue > (_7G30[x] + _5G30[x]) * 0.5f)) { + correction = _7G30[y] - _7G30[x] ; + lbe = _7G30[y]; + correctL = true; + } else if ((hue <= (_7G30[x] + _5G30[x]) * 0.5f) && (hue > (_5G30[x] + _25G30[x]) * 0.5f)) { + correction = _5G30[y] - _5G30[x] ; + lbe = _5G30[y]; + correctL = true; + } else if ((hue <= (_25G30[x] + _5G30[x]) * 0.5f) && (hue > (_25G30[x] + _1G30[x]) * 0.5f)) { + correction = _25G30[y] - _25G30[x] ; + lbe = _25G30[y]; + correctL = true; + } else if ((hue <= (_1G30[x] + _25G30[x]) * 0.5f) && (hue > (_1G30[x] + _10GY30[x]) * 0.5f)) { + correction = _1G30[y] - _1G30[x] ; + lbe = _1G30[y]; + correctL = true; + } else if (x < 85 && (hue <= (_1G30[x] + _10GY30[x]) * 0.5f) && (hue > (_10GY30[x] + _75GY30[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _10GY30[y] - _10GY30[x] ; + lbe = _10GY30[y]; + correctL = true; + } else if (x < 85 && (hue <= (_10GY30[x] + _75GY30[x]) * 0.5f) && (hue > (_75GY30[x] + _5GY30[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _75GY30[y] - _75GY30[x] ; + lbe = _75GY30[y]; + correctL = true; + } else if (x < 85 && (hue <= (_5GY30[x] + _75GY30[x]) * 0.5f) && (hue > (_5GY30[x] - 0.035f))) { + if (y > 89) { + y = 89; + } + correction = _5GY30[y] - _5GY30[x] ; + lbe = _5GY30[y] ; + correctL = true; + } + } else if (lum < 45.f) { + if ((hue <= (_7G40[x] + 0.035f)) && (hue > (_7G40[x] + _5G40[x]) * 0.5f)) { + correction = _7G40[y] - _7G40[x] ; + lbe = _7G40[y]; + correctL = true; + } else if ((hue <= (_7G40[x] + _5G40[x]) * 0.5f) && (hue > (_5G40[x] + _25G40[x]) * 0.5f)) { + correction = _5G40[y] - _5G40[x] ; + lbe = _5G40[y]; + correctL = true; + } else if ((hue <= (_25G40[x] + _5G40[x]) * 0.5f) && (hue > (_25G40[x] + _1G40[x]) * 0.5f)) { + correction = _25G40[y] - _25G40[x] ; + lbe = _25G40[y]; + correctL = true; + } else if ((hue <= (_1G40[x] + _25G40[x]) * 0.5f) && (hue > (_1G40[x] + _10GY40[x]) * 0.5f)) { + correction = _1G40[y] - _1G40[x] ; + lbe = _1G40[y]; + correctL = true; + } else if (x < 85 && (hue <= (_1G40[x] + _10GY40[x]) * 0.5f) && (hue > (_10GY40[x] + _75GY40[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _10GY40[y] - _10GY40[x] ; + lbe = _10GY40[y]; + correctL = true; + } else if (x < 85 && (hue <= (_10GY40[x] + _75GY40[x]) * 0.5f) && (hue > (_75GY40[x] + _5GY40[x]) * 0.5f)) { + if (y > 89) { + y = 89; + } + correction = _75GY40[y] - _75GY40[x] ; + lbe = _75GY40[y]; + correctL = true; + } else if (x < 85 && (hue <= (_5GY40[x] + _75GY40[x]) * 0.5f) && (hue > (_5GY40[x] - 0.035f))) { + if (y > 89) { + y = 89; // + } + correction = _5GY40[y] - _5GY40[x] ; + lbe = _5GY40[y]; + correctL = true; + } + } else if (lum < 55.f) { + if ((hue <= (_7G50[x] + 0.035f)) && (hue > (_7G50[x] + _5G50[x]) * 0.5f)) { + correction = _7G50[y] - _7G50[x] ; + lbe = _7G50[y]; + correctL = true; + } else if ((hue <= (_7G50[x] + _5G50[x]) * 0.5f) && (hue > (_5G50[x] + _25G50[x]) * 0.5f)) { + correction = _5G50[y] - _5G50[x] ; + lbe = _5G50[y]; + correctL = true; + } else if ((hue <= (_25G50[x] + _5G50[x]) * 0.5f) && (hue > (_25G50[x] + _1G50[x]) * 0.5f)) { + correction = _25G50[y] - _25G50[x] ; + lbe = _25G50[y]; + correctL = true; + } else if ((hue <= (_1G50[x] + _25G50[x]) * 0.5f) && (hue > (_1G50[x] + _10GY50[x]) * 0.5f)) { + correction = _1G50[y] - _1G50[x] ; + lbe = _1G50[y]; + correctL = true; + } else if ((hue <= (_1G50[x] + _10GY50[x]) * 0.5f) && (hue > (_10GY50[x] + _75GY50[x]) * 0.5f)) { + correction = _10GY50[y] - _10GY50[x] ; + lbe = _10GY50[y]; + correctL = true; + } else if ((hue <= (_10GY50[x] + _75GY50[x]) * 0.5f) && (hue > (_75GY50[x] + _5GY50[x]) * 0.5f)) { + correction = _75GY50[y] - _75GY50[x] ; + lbe = _75GY50[y]; + correctL = true; + } else if ((hue <= (_5GY50[x] + _75GY50[x]) * 0.5f) && (hue > (_5GY50[x] - 0.035f))) { + correction = _5GY50[y] - _5GY50[x] ; + lbe = _5GY50[y]; + correctL = true; + } + } else if (lum < 65.f) { + if ((hue <= (_7G60[x] + 0.035f)) && (hue > (_7G60[x] + _5G60[x]) * 0.5f)) { + correction = _7G60[y] - _7G60[x] ; + lbe = _7G60[y]; + correctL = true; + } else if ((hue <= (_7G60[x] + _5G60[x]) * 0.5f) && (hue > (_5G60[x] + _25G60[x]) * 0.5f)) { + correction = _5G60[y] - _5G60[x] ; + lbe = _5G60[y]; + correctL = true; + } else if ((hue <= (_25G60[x] + _5G60[x]) * 0.5f) && (hue > (_25G60[x] + _1G60[x]) * 0.5f)) { + correction = _25G60[y] - _25G60[x] ; + lbe = _25G60[y]; + correctL = true; + } else if ((hue <= (_1G60[x] + _25G60[x]) * 0.5f) && (hue > (_1G60[x] + _10GY60[x]) * 0.5f)) { + correction = _1G60[y] - _1G60[x] ; + lbe = _1G60[y]; + correctL = true; + } else if ((hue <= (_1G60[x] + _10GY60[x]) * 0.5f) && (hue > (_10GY60[x] + _75GY60[x]) * 0.5f)) { + correction = _10GY60[y] - _10GY60[x] ; + lbe = _10GY60[y]; + correctL = true; + } else if ((hue <= (_10GY60[x] + _75GY60[x]) * 0.5f) && (hue > (_75GY60[x] + _5GY60[x]) * 0.5f)) { + correction = _75GY60[y] - _75GY60[x] ; + lbe = _75GY60[y] ; + correctL = true; + } else if ((hue <= (_5GY60[x] + _75GY60[x]) * 0.5f) && (hue > (_5GY60[x] - 0.035f))) { + correction = _5GY60[y] - _5GY60[x] ; + lbe = _5GY60[y]; + correctL = true; + } + } else if (lum < 75.f) { + if ((hue <= (_7G70[x] + 0.035f)) && (hue > (_7G70[x] + _5G70[x]) * 0.5f)) { + correction = _7G70[y] - _7G70[x] ; + lbe = _7G70[y]; + correctL = true; + } else if ((hue <= (_7G70[x] + _5G70[x]) * 0.5f) && (hue > (_5G70[x] + _25G70[x]) * 0.5f)) { + correction = _5G70[y] - _5G70[x] ; + lbe = _5G70[y]; + correctL = true; + } else if ((hue <= (_25G70[x] + _5G70[x]) * 0.5f) && (hue > (_25G70[x] + _1G70[x]) * 0.5f)) { + correction = _25G70[y] - _25G70[x] ; + lbe = _25G70[y]; + correctL = true; + } else if ((hue <= (_1G70[x] + _25G70[x]) * 0.5f) && (hue > (_1G70[x] + _10GY70[x]) * 0.5f)) { + correction = _1G70[y] - _1G70[x] ; + lbe = _1G70[y] ; + correctL = true; + } else if ((hue <= (_1G70[x] + _10GY70[x]) * 0.5f) && (hue > (_10GY70[x] + _75GY70[x]) * 0.5f)) { + correction = _10GY70[y] - _10GY70[x] ; + lbe = _10GY70[y]; + correctL = true; + } else if ((hue <= (_10GY70[x] + _75GY70[x]) * 0.5f) && (hue > (_75GY70[x] + _5GY70[x]) * 0.5f)) { + correction = _75GY70[y] - _75GY70[x] ; + lbe = _75GY70[y]; + correctL = true; + } else if ((hue <= (_5GY70[x] + _75GY70[x]) * 0.5f) && (hue > (_5GY70[x] - 0.035f))) { + correction = _5GY70[y] - _5GY70[x] ; + lbe = _5GY70[y]; + correctL = true; + } + } else if (lum < 85.f) { + if ((hue <= (_7G80[x] + 0.035f)) && (hue > (_7G80[x] + _5G80[x]) * 0.5f)) { + correction = _7G80[y] - _7G80[x] ; + lbe = _7G80[y]; + correctL = true; + } else if ((hue <= (_7G80[x] + _5G80[x]) * 0.5f) && (hue > (_5G80[x] + _25G80[x]) * 0.5f)) { + correction = _5G80[y] - _5G80[x] ; + lbe = _5G80[y]; + correctL = true; + } else if ((hue <= (_25G80[x] + _5G80[x]) * 0.5f) && (hue > (_25G80[x] + _1G80[x]) * 0.5f)) { + correction = _25G80[y] - _25G80[x] ; + lbe = _25G80[y]; + correctL = true; + } else if ((hue <= (_1G80[x] + _25G80[x]) * 0.5f) && (hue > (_1G80[x] + _10GY80[x]) * 0.5f)) { + correction = _1G80[y] - _1G80[x] ; + lbe = _1G80[y]; + correctL = true; + } else if ((hue <= (_1G80[x] + _10GY80[x]) * 0.5f) && (hue > (_10GY80[x] + _75GY80[x]) * 0.5f)) { + correction = _10GY80[y] - _10GY80[x] ; + lbe = _10GY80[y]; + correctL = true; + } else if ((hue <= (_10GY80[x] + _75GY80[x]) * 0.5f) && (hue > (_75GY80[x] + _5GY80[x]) * 0.5f)) { + correction = _75GY80[y] - _75GY80[x] ; + lbe = _75GY80[y]; + correctL = true; + } else if ((hue <= (_5GY80[x] + _75GY80[x]) * 0.5f) && (hue > (_5GY80[x] - 0.035f))) { + correction = _5GY80[y] - _5GY80[x] ; + lbe = _5GY80[y]; + correctL = true; + } + } + } + } else if (zone == 4) { //Red purple correction : only for L < 30 + if (lum > 5.f) { + if (lum < 15.f && x < 45) { + y = std::min(y, 44); + if ((hue <= (_5R10[x] + 0.035f)) && (hue > (_5R10[x] - 0.043f))) { + correction = _5R10[y] - _5R10[x] ; + lbe = _5R10[y]; + correctL = true; + } else if ((hue <= (_25R10[x] + 0.043f)) && (hue > (_25R10[x] + _10RP10[x]) * 0.5f)) { + correction = _25R10[y] - _25R10[x] ; + lbe = _25R10[y]; + correctL = true; + } else if ((hue <= (_25R10[x] + _10RP10[x]) * 0.5f) && (hue > (_10RP10[x] - 0.035f))) { + correction = _10RP10[y] - _10RP10[x] ; + lbe = _10RP10[y]; + correctL = true; + } + } else if (lum < 25.f && x < 70) { + y = std::min(y, 70); + if ((hue <= (_5R20[x] + 0.035f)) && (hue > (_5R20[x] + _25R20[x]) * 0.5f)) { + correction = _5R20[y] - _5R20[x] ; + lbe = _5R20[y]; + correctL = true; + } else if ((hue <= (_5R20[x] + _25R20[x]) * 0.5f) && (hue > (_10RP20[x] + _25R20[x]) * 0.5f)) { + correction = _25R20[y] - _25R20[x] ; + lbe = _25R20[y]; + correctL = true; + } else if ( (hue <= (_10RP20[x] + _25R20[x]) * 0.5f) && (hue > (_10RP20[x] - 0.035f))) { + correction = _10RP20[y] - _10RP20[x] ; + lbe = _10RP20[y]; + correctL = true; + } + } else if (lum < 35.f && x < 85) { + y = rtengine::min(y, 85); + if ((hue <= (_5R30[x] + 0.035f)) && (hue > (_5R30[x] + _25R30[x]) * 0.5f)) { + correction = _5R30[y] - _5R30[x] ; + lbe = _5R30[y]; + correctL = true; + } else if ((hue <= (_5R30[x] + _25R30[x]) * 0.5f) && (hue > (_10RP30[x] + _25R30[x]) * 0.5f)) { + correction = _25R30[y] - _25R30[x] ; + lbe = _25R30[y]; + correctL = true; + } else if ((hue <= (_10RP30[x] + _25R30[x]) * 0.5f) && (hue > (_10RP30[x] - 0.035f))) { + correction = _10RP30[y] - _10RP30[x] ; + lbe = _10RP30[y]; + correctL = true; + } + } + } + } + //end red purple +} +} diff --git a/rtengine/opthelper.h b/rtengine/opthelper.h index b65ede227..f431c0ec9 100644 --- a/rtengine/opthelper.h +++ b/rtengine/opthelper.h @@ -18,27 +18,24 @@ // along with this program. If not, see . // //////////////////////////////////////////////////////////////// +#pragma once -#ifndef OPTHELPER_H - #define OPTHELPER_H +#define pow_F(a,b) (xexpf(b*xlogf(a))) - #define pow_F(a,b) (xexpf(b*xlogf(a))) - - #ifdef __SSE2__ - #include "sleefsseavx.c" - #endif - - #ifdef __GNUC__ - #define RESTRICT __restrict__ - #define LIKELY(x) __builtin_expect (!!(x), 1) - #define UNLIKELY(x) __builtin_expect (!!(x), 0) - #define ALIGNED64 __attribute__ ((aligned (64))) - #define ALIGNED16 __attribute__ ((aligned (16))) - #else - #define RESTRICT - #define LIKELY(x) (x) - #define UNLIKELY(x) (x) - #define ALIGNED64 - #define ALIGNED16 - #endif +#ifdef __SSE2__ + #include "sleefsseavx.h" +#endif + +#ifdef __GNUC__ + #define RESTRICT __restrict__ + #define LIKELY(x) __builtin_expect (!!(x), 1) + #define UNLIKELY(x) __builtin_expect (!!(x), 0) + #define ALIGNED64 __attribute__ ((aligned (64))) + #define ALIGNED16 __attribute__ ((aligned (16))) +#else + #define RESTRICT + #define LIKELY(x) (x) + #define UNLIKELY(x) (x) + #define ALIGNED64 + #define ALIGNED16 #endif diff --git a/rtengine/previewimage.h b/rtengine/previewimage.h index e6c3ea070..2143509a3 100644 --- a/rtengine/previewimage.h +++ b/rtengine/previewimage.h @@ -18,10 +18,16 @@ */ #pragma once -#include #include +namespace Glib +{ + +class ustring; + +} + namespace rtengine { diff --git a/rtengine/processingjob.h b/rtengine/processingjob.h index 6cdc6bd7c..9c3846958 100644 --- a/rtengine/processingjob.h +++ b/rtengine/processingjob.h @@ -24,7 +24,7 @@ namespace rtengine { -class ProcessingJobImpl : public ProcessingJob +class ProcessingJobImpl final : public ProcessingJob { public: diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index dda3f721d..0f2027726 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -4322,7 +4322,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) if (keyFile.has_key("Shadows & Highlights", "LocalContrast") && ppVersion < 329) { int lc = keyFile.get_integer("Shadows & Highlights", "LocalContrast"); - localContrast.amount = float(lc) / 30.; + localContrast.amount = float(lc) / 30.f; if (pedited) { pedited->localContrast.amount = true; @@ -4644,8 +4644,9 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) Glib::ustring temp; assignFromKeyfile(keyFile, "Wavelet", "LevMethod", pedited, temp, pedited->wavelet.Lmethod); - if (!temp.empty()) { + try { wavelet.Lmethod = std::stoi(temp); + } catch (...) { } } else { assignFromKeyfile(keyFile, "Wavelet", "LevMethod", pedited, wavelet.Lmethod, pedited->wavelet.Lmethod); diff --git a/rtengine/rawimage.cc b/rtengine/rawimage.cc index 4421e4af4..34d5d961c 100644 --- a/rtengine/rawimage.cc +++ b/rtengine/rawimage.cc @@ -171,7 +171,7 @@ void RawImage::get_colorsCoeff( float *pre_mul_, float *scale_mul_, float *cblac } for (int c = 0; c < 4; c++) { - dsumthr[c] += sum[c]; + dsumthr[c] += static_cast(sum[c]); } skip_block2: @@ -195,7 +195,7 @@ skip_block2: } for(int c = 0; c < 4; c++) { - dsum[c] -= cblack_[c] * dsum[c + 4]; + dsum[c] -= static_cast(cblack_[c]) * dsum[c + 4]; } } else if(isXtrans()) { @@ -241,7 +241,7 @@ skip_block2: } for (int c = 0; c < 8; c++) { - dsumthr[c] += sum[c]; + dsumthr[c] += static_cast(sum[c]); } skip_block3: @@ -365,18 +365,14 @@ skip_block: } for (dmin = DBL_MAX, dmax = c = 0; c < 4; c++) { - if (dmin > pre_mul_[c]) { - dmin = pre_mul_[c]; - } - - if (dmax < pre_mul_[c]) { - dmax = pre_mul_[c]; - } + dmin = rtengine::min(dmin, pre_mul_[c]); + dmax = rtengine::max(dmax, pre_mul_[c]); } for (c = 0; c < 4; c++) { int sat = this->get_white(c) - cblack_[c]; - scale_mul_[c] = (pre_mul_[c] /= dmax) * 65535.0 / sat; + pre_mul_[c] /= static_cast(dmax); + scale_mul_[c] = pre_mul_[c] * 65535.f / sat; } if (settings->verbose) { @@ -387,25 +383,30 @@ skip_block: asn[c] = 0; } - if (asn[c] > dmax) { + if (asn[c] > static_cast(dmax)) { dmax = asn[c]; } } for (c = 0; c < 4; c++) { - asn[c] /= dmax; + asn[c] /= static_cast(dmax); } printf("cam_mul:[%f %f %f %f], AsShotNeutral:[%f %f %f %f]\n", - cam_mul[0], cam_mul[1], cam_mul[2], cam_mul[3], asn[0], asn[1], asn[2], asn[3]); + static_cast(cam_mul[0]), static_cast(cam_mul[1]), + static_cast(cam_mul[2]), static_cast(cam_mul[3]), + static_cast(asn[0]), static_cast(asn[1]), static_cast(asn[2]), static_cast(asn[3])); printf("pre_mul:[%f %f %f %f], scale_mul:[%f %f %f %f], cblack:[%f %f %f %f]\n", - pre_mul_[0], pre_mul_[1], pre_mul_[2], pre_mul_[3], - scale_mul_[0], scale_mul_[1], scale_mul_[2], scale_mul_[3], - cblack_[0], cblack_[1], cblack_[2], cblack_[3]); + static_cast(pre_mul_[0]), static_cast(pre_mul_[1]), + static_cast(pre_mul_[2]), static_cast(pre_mul_[3]), + static_cast(scale_mul_[0]), static_cast(scale_mul_[1]), + static_cast(scale_mul_[2]), static_cast(scale_mul_[3]), + static_cast(cblack_[0]), static_cast(cblack_[1]), + static_cast(cblack_[2]), static_cast(cblack_[3])); printf("rgb_cam:[ [ %f %f %f], [%f %f %f], [%f %f %f] ]%s\n", - rgb_cam[0][0], rgb_cam[1][0], rgb_cam[2][0], - rgb_cam[0][1], rgb_cam[1][1], rgb_cam[2][1], - rgb_cam[0][2], rgb_cam[1][2], rgb_cam[2][2], + static_cast(rgb_cam[0][0]), static_cast(rgb_cam[1][0]), static_cast(rgb_cam[2][0]), + static_cast(rgb_cam[0][1]), static_cast(rgb_cam[1][1]), static_cast(rgb_cam[2][1]), + static_cast(rgb_cam[0][2]), static_cast(rgb_cam[1][2]), static_cast(rgb_cam[2][2]), (!this->isBayer()) ? " (not bayer)" : ""); } diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 18fc18f58..fcc85f2c6 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -17,6 +17,7 @@ * along with RawTherapee. If not, see . */ #include +#include #include #include "camconst.h" @@ -25,6 +26,7 @@ #include "dcp.h" #include "dfmanager.h" #include "ffmanager.h" +#include "iccmatrices.h" #include "iccstore.h" #include "imagefloat.h" #include "improcfun.h" @@ -49,10 +51,6 @@ #endif #include "opthelper.h" -#define clipretinex( val, minv, maxv ) (( val = (val < minv ? minv : val ) ) > maxv ? maxv : val ) - -#undef CLIPD -#define CLIPD(a) ((a)>0.0f?((a)<1.0f?(a):1.0f):0.0f) namespace { @@ -101,7 +99,7 @@ void transLineFuji (const float* const red, const float* const green, const floa { // Fuji SuperCCD rotation + coarse rotation - int start = ABS(fw - i); + int start = std::abs(fw - i); int w = fw * 2 + 1; int h = (imheight - fw) * 2 + 1; int end = min(h + fw - i, w - fw + i); @@ -425,12 +423,6 @@ void transLineD1x (const float* const red, const float* const green, const float namespace rtengine { -#undef ABS -#undef DIST - -#define ABS(a) ((a)<0?-(a):(a)) -#define DIST(a,b) (ABS(a-b)) - RawImageSource::RawImageSource () : ImageSource() , W(0), H(0) @@ -620,7 +612,7 @@ float calculate_scale_mul(float scale_mul[4], const float pre_mul_[4], const flo { if (isMono || colors == 1) { for (int c = 0; c < 4; c++) { - scale_mul[c] = 65535.0 / (c_white[c] - c_black[c]); + scale_mul[c] = 65535.f / (c_white[c] - c_black[c]); } } else { float pre_mul[4]; @@ -636,7 +628,7 @@ float calculate_scale_mul(float scale_mul[4], const float pre_mul_[4], const flo float maxpremul = max(pre_mul[0], pre_mul[1], pre_mul[2], pre_mul[3]); for (int c = 0; c < 4; c++) { - scale_mul[c] = (pre_mul[c] / maxpremul) * 65535.0 / (c_white[c] - c_black[c]); + scale_mul[c] = (pre_mul[c] / maxpremul) * 65535.f / (c_white[c] - c_black[c]); } } @@ -675,7 +667,7 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima || (ri->getSensorType() == ST_BAYER && raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::MONO)); for (int i = 0; i < 4; ++i) { - c_white[i] = (ri->get_white(i) - cblacksom[i]) / raw.expos + cblacksom[i]; + c_white[i] = (ri->get_white(i) - cblacksom[i]) / static_cast(raw.expos) + cblacksom[i]; } float gain = calculate_scale_mul(new_scale_mul, new_pre_mul, c_white, cblacksom, isMono, ri->get_colors()); @@ -684,21 +676,21 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima bm = new_scale_mul[2] / scale_mul[2] * gain; //fprintf(stderr, "camera gain: %f, current wb gain: %f, diff in stops %f\n", camInitialGain, gain, log2(camInitialGain) - log2(gain)); } else { - // old scaling: used a fixed reference gain based on camera (as-shot) white balance - - // how much we need to scale each channel to get our new white balance - rm = refwb_red / rm; - gm = refwb_green / gm; - bm = refwb_blue / bm; - // normalize so larger multiplier becomes 1.0 - float minval = min(rm, gm, bm); - rm /= minval; - gm /= minval; - bm /= minval; - // multiply with reference gain, ie as-shot WB - rm *= camInitialGain; - gm *= camInitialGain; - bm *= camInitialGain; +// // old scaling: used a fixed reference gain based on camera (as-shot) white balance +// +// // how much we need to scale each channel to get our new white balance +// rm = refwb_red / rm; +// gm = refwb_green / gm; +// bm = refwb_blue / bm; +// // normalize so larger multiplier becomes 1.0 +// float minval = min(rm, gm, bm); +// rm /= minval; +// gm /= minval; +// bm /= minval; +// // multiply with reference gain, ie as-shot WB +// rm *= camInitialGain; +// gm *= camInitialGain; +// bm *= camInitialGain; } defGain = 0.0; @@ -877,13 +869,13 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima for (int i = 1; i < image->getHeight() - 1; i++) { for (int j = 2 - (a + i + 1) % 2; j < image->getWidth() - 1; j += 2) { // edge-adaptive interpolation - double dh = (ABS(image->r(i, j + 1) - image->r(i, j - 1)) + ABS(image->g(i, j + 1) - image->g(i, j - 1)) + ABS(image->b(i, j + 1) - image->b(i, j - 1))) / 1.0; - double dv = (ABS(image->r(i + 1, j) - image->r(i - 1, j)) + ABS(image->g(i + 1, j) - image->g(i - 1, j)) + ABS(image->b(i + 1, j) - image->b(i - 1, j))) / 1.0; - double eh = 1.0 / (1.0 + dh); - double ev = 1.0 / (1.0 + dv); - image->r(i, j) = (eh * (image->r(i, j + 1) + image->r(i, j - 1)) + ev * (image->r(i + 1, j) + image->r(i - 1, j))) / (2.0 * (eh + ev)); - image->g(i, j) = (eh * (image->g(i, j + 1) + image->g(i, j - 1)) + ev * (image->g(i + 1, j) + image->g(i - 1, j))) / (2.0 * (eh + ev)); - image->b(i, j) = (eh * (image->b(i, j + 1) + image->b(i, j - 1)) + ev * (image->b(i + 1, j) + image->b(i - 1, j))) / (2.0 * (eh + ev)); + float dh = (std::fabs(image->r(i, j + 1) - image->r(i, j - 1)) + std::fabs(image->g(i, j + 1) - image->g(i, j - 1)) + std::fabs(image->b(i, j + 1) - image->b(i, j - 1))); + float dv = (std::fabs(image->r(i + 1, j) - image->r(i - 1, j)) + std::fabs(image->g(i + 1, j) - image->g(i - 1, j)) + std::fabs(image->b(i + 1, j) - image->b(i - 1, j))); + float eh = 1.f / (1.f + dh); + float ev = 1.f / (1.f + dv); + image->r(i, j) = (eh * (image->r(i, j + 1) + image->r(i, j - 1)) + ev * (image->r(i + 1, j) + image->r(i - 1, j))) / (2.f * (eh + ev)); + image->g(i, j) = (eh * (image->g(i, j + 1) + image->g(i, j - 1)) + ev * (image->g(i + 1, j) + image->g(i - 1, j))) / (2.f * (eh + ev)); + image->b(i, j) = (eh * (image->b(i, j + 1) + image->b(i, j - 1)) + ev * (image->b(i + 1, j) + image->b(i - 1, j))) / (2.f * (eh + ev)); } // first pixel @@ -1547,7 +1539,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le } } - if(prepareDenoise && dirpyrdenoiseExpComp == INFINITY) { + if(prepareDenoise && dirpyrdenoiseExpComp == RT_INFINITY) { LUTu aehist; int aehistcompr; double clip = 0; @@ -2916,7 +2908,7 @@ lab2ProphotoRgbD50(float L, float A, float B, float& r, float& g, float& b) float X; float Y; float Z; -#define CLIP01(a) ((a)>0?((a)<1?(a):1):0) + { // convert from Lab to XYZ float x, y, z, fx, fy, fz; @@ -2951,9 +2943,6 @@ lab2ProphotoRgbD50(float L, float A, float B, float& r, float& g, float& b) r = prophoto_xyz[0][0] * X + prophoto_xyz[0][1] * Y + prophoto_xyz[0][2] * Z; g = prophoto_xyz[1][0] * X + prophoto_xyz[1][1] * Y + prophoto_xyz[1][2] * Z; b = prophoto_xyz[2][0] * X + prophoto_xyz[2][1] * Y + prophoto_xyz[2][2] * Z; - // r = CLIP01(r); - // g = CLIP01(g); - // b = CLIP01(b); } // Converts raw image including ICC input profile to working space - floating point version @@ -3881,7 +3870,7 @@ void RawImageSource::getRowStartEnd (int x, int &start, int &end) { if (fuji) { int fw = ri->get_FujiWidth(); - start = ABS(fw - x) + border; + start = std::abs(fw - x) + border; end = min(H + W - fw - x, fw + x) - border; } else { start = border; @@ -3922,7 +3911,7 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm) if (fuji) { for (int i = 32; i < H - 32; i++) { int fw = ri->get_FujiWidth(); - int start = ABS(fw - i) + 32; + int start = std::abs(fw - i) + 32; int end = min(H + W - fw - i, fw + i) - 32; for (int j = start; j < end; j++) { diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index bd460c61b..6be02f6d6 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -37,7 +37,7 @@ class DiagonalCurve; class RetinextransmissionCurve; class RetinexgaintransmissionCurve; -class RawImageSource : public ImageSource +class RawImageSource final : public ImageSource { private: static DiagonalCurve *phaseOneIccCurve; diff --git a/rtengine/rescale.h b/rtengine/rescale.h index 70974aa48..2138cd8e8 100644 --- a/rtengine/rescale.h +++ b/rtengine/rescale.h @@ -20,9 +20,12 @@ #pragma once -#include "array2D.h" #include "rt_math.h" +template +class array2D; + + namespace rtengine { diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index 0473622c4..ca663c5bc 100644 --- a/rtengine/rtengine.h +++ b/rtengine/rtengine.h @@ -31,7 +31,6 @@ #include "imageformat.h" #include "procevents.h" #include "rawmetadatalocation.h" -#include "rt_math.h" #include "settings.h" #include "../rtgui/threadutils.h" diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 9da601e2a..4507f2b40 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -31,6 +31,7 @@ #include "colortemp.h" #include "curves.h" #include "dcp.h" +#include "iccmatrices.h" #include "iccstore.h" #include "image8.h" #include "improcfun.h" @@ -511,8 +512,6 @@ Thumbnail* Thumbnail::loadQuickFromRaw (const Glib::ustring& fname, RawMetaDataL ((filter >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3)==0 || !filter) #define FISGREEN(filter,row,col) \ ((filter >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3)==1 || !filter) -#define FISBLUE(filter,row,col) \ - ((filter >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3)==2 || !filter) RawMetaDataLocation Thumbnail::loadMetaDataFromRaw (const Glib::ustring& fname) { @@ -2254,44 +2253,6 @@ bool Thumbnail::writeEmbProfile (const Glib::ustring& fname) return false; } -bool Thumbnail::readAEHistogram (const Glib::ustring& fname) -{ - - FILE* f = g_fopen(fname.c_str(), "rb"); - - if (!f) { - aeHistogram.reset(); - } else { - aeHistogram(65536 >> aeHistCompression); - const size_t histoBytes = (65536 >> aeHistCompression) * sizeof(aeHistogram[0]); - const size_t bytesRead = fread(&aeHistogram[0], 1, histoBytes, f); - fclose (f); - if (bytesRead != histoBytes) { - aeHistogram.reset(); - return false; - } - return true; - } - - return false; -} - -bool Thumbnail::writeAEHistogram (const Glib::ustring& fname) -{ - - if (aeHistogram) { - FILE* f = g_fopen (fname.c_str (), "wb"); - - if (f) { - fwrite (&aeHistogram[0], 1, (65536 >> aeHistCompression)*sizeof (aeHistogram[0]), f); - fclose (f); - return true; - } - } - - return false; -} - unsigned char* Thumbnail::getImage8Data() { if (thumbImg && thumbImg->getType() == rtengine::sImage8) { diff --git a/rtengine/rtthumbnail.h b/rtengine/rtthumbnail.h index dcc9596f6..ccca1c582 100644 --- a/rtengine/rtthumbnail.h +++ b/rtengine/rtthumbnail.h @@ -18,8 +18,6 @@ */ #pragma once -#include - #include #include "image16.h" @@ -30,6 +28,13 @@ #include "../rtgui/threadutils.h" +namespace Glib +{ + +class ustring; + +} + namespace rtengine { @@ -108,10 +113,6 @@ public: bool readEmbProfile (const Glib::ustring& fname); bool writeEmbProfile (const Glib::ustring& fname); - bool readAEHistogram (const Glib::ustring& fname); - bool writeAEHistogram (const Glib::ustring& fname); - - bool isAeValid() { return aeValid; }; unsigned char* getImage8Data(); // accessor to the 8bit image if it is one, which should be the case for the "Inspector" mode. // Hombre: ... let's hope that proper template can make this cleaner diff --git a/rtengine/shmap.cc b/rtengine/shmap.cc index abdcc42a4..306e30bdd 100644 --- a/rtengine/shmap.cc +++ b/rtengine/shmap.cc @@ -27,6 +27,37 @@ #undef THREAD_PRIORITY_NORMAL #include "opthelper.h" +namespace { + +void fillLuminance(rtengine::Imagefloat* img, float** luminance, const float lumi[3], int W, int H) // fill with luminance +{ + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = 0; i < H; i++) + for (int j = 0; j < W; j++) { + luminance[i][j] = lumi[0] * std::max(img->r(i, j), 0.f) + lumi[1] * std::max(img->g(i, j), 0.f) + lumi[2] * std::max(img->b(i, j), 0.f); + } + +} + +void fillLuminanceL(float** L, float** luminance, int W, int H) // fill with luminance +{ + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = 0; i < H; i++) + for (int j = 0; j < W; j++) { + luminance[i][j] = std::max(L[i][j], 0.f) ;//we can put here some enhancements Gamma, compression data,... + } + +} + +} namespace rtengine { @@ -51,39 +82,13 @@ SHMap::~SHMap () delete [] map; } -void SHMap::fillLuminance( Imagefloat * img, float **luminance, double lumi[3] ) // fill with luminance -{ - -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int i = 0; i < H; i++) - for (int j = 0; j < W; j++) { - luminance[i][j] = lumi[0] * std::max(img->r(i, j), 0.f) + lumi[1] * std::max(img->g(i, j), 0.f) + lumi[2] * std::max(img->b(i, j), 0.f); - } - -} - -void SHMap::fillLuminanceL( float ** L, float **luminance) // fill with luminance -{ - -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int i = 0; i < H; i++) - for (int j = 0; j < W; j++) { - luminance[i][j] = std::max(L[i][j], 0.f) ;//we can put here some enhancements Gamma, compression data,... - } - -} - void SHMap::update (Imagefloat* img, double radius, double lumi[3], bool hq, int skip) { + const float lumif[3] = { static_cast(lumi[0]), static_cast(lumi[1]), static_cast(lumi[2]) }; + if (!hq) { - fillLuminance( img, map, lumi); + fillLuminance(img, map, lumif, W, H); const bool useBoxBlur = radius > 40.0; // boxblur is less prone to artifacts for large radi @@ -91,7 +96,7 @@ void SHMap::update (Imagefloat* img, double radius, double lumi[3], bool hq, int #pragma omp parallel if (!useBoxBlur) #endif { - gaussianBlur (map, map, W, H, radius, useBoxBlur); + gaussianBlur(map, map, W, H, radius, useBoxBlur); } } @@ -99,7 +104,7 @@ void SHMap::update (Imagefloat* img, double radius, double lumi[3], bool hq, int //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //experimental dirpyr shmap - float thresh = (100.f * radius); //1000; + float thresh = 100.0 * radius; //1000; // set up range function // calculate size of Lookup table. That's possible because from a value k for all i>=k rangefn[i] will be exp(-10) @@ -142,7 +147,7 @@ void SHMap::update (Imagefloat* img, double radius, double lumi[3], bool hq, int dirpyrlo[1] = buffer; } - fillLuminance( img, dirpyrlo[0], lumi); + fillLuminance(img, dirpyrlo[0], lumif, W, H); scale = 1; int level = 0; @@ -181,28 +186,18 @@ void SHMap::update (Imagefloat* img, double radius, double lumi[3], bool hq, int for (int j = 0; j < W; j++) { _val = map[i][j]; - if (_val < _min_f) { - _min_f = _val; - } + _min_f = std::min(_min_f, _val); + _max_f = std::max(_max_f, _val); - if (_val > _max_f) { - _max_f = _val; - } - - _avg += _val; + _avg += static_cast(_val); } #ifdef _OPENMP #pragma omp critical #endif { - if(_min_f < min_f ) { - min_f = _min_f; - } - - if(_max_f > max_f ) { - max_f = _max_f; - } + min_f = std::min(min_f, _min_f); + max_f = std::max(max_f, _max_f); } } _avg /= ((H) * (W)); @@ -214,7 +209,7 @@ void SHMap::updateL (float** L, double radius, bool hq, int skip) { if (!hq) { - fillLuminanceL( L, map); + fillLuminanceL(L, map, W, H); #ifdef _OPENMP #pragma omp parallel #endif @@ -228,7 +223,7 @@ void SHMap::updateL (float** L, double radius, bool hq, int skip) { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //experimental dirpyr shmap - float thresh = (100.f * radius); //1000; + float thresh = 100.0 * radius; //1000; int levrad; // = 16; levrad = 2; //for retinex - otherwise levrad = 16 // set up range function @@ -274,7 +269,7 @@ void SHMap::updateL (float** L, double radius, bool hq, int skip) dirpyrlo[1] = buffer; } - fillLuminanceL( L, dirpyrlo[0]); + fillLuminanceL(L, dirpyrlo[0], W, H); scale = 1; int level = 0; @@ -313,28 +308,18 @@ void SHMap::updateL (float** L, double radius, bool hq, int skip) for (int j = 0; j < W; j++) { _val = map[i][j]; - if (_val < _min_f) { - _min_f = _val; - } + _min_f = std::min(_min_f, _val); + _max_f = std::max(_max_f, _val); - if (_val > _max_f) { - _max_f = _val; - } - - _avg += _val; + _avg += static_cast(_val); } #ifdef _OPENMP #pragma omp critical #endif { - if(_min_f < min_f ) { - min_f = _min_f; - } - - if(_max_f > max_f ) { - max_f = _max_f; - } + min_f = std::min(min_f, _min_f); + max_f = std::max(max_f, _max_f); } } _avg /= ((H) * (W)); diff --git a/rtengine/shmap.h b/rtengine/shmap.h index 68e352b23..b1b1e5eff 100644 --- a/rtengine/shmap.h +++ b/rtengine/shmap.h @@ -48,8 +48,6 @@ public: private: int W, H; - void fillLuminance( Imagefloat * img, float **luminance, double lumi[3] ); - void fillLuminanceL( float ** L, float **luminance ); void dirpyr_shmap(float ** data_fine, float ** data_coarse, int width, int height, const LUTf& rangefn, int level, int scale); }; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 3505bcd50..28188b0f6 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1005,7 +1005,7 @@ private: ipf.rgbProc(baseImg, labView, nullptr, curve1, curve2, curve, params.toneCurve.saturation, rCurve, gCurve, bCurve, satLimit, satLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, customToneCurvebw1, customToneCurvebw2, rrm, ggm, bbm, autor, autog, autob, expcomp, hlcompr, hlcomprthresh, dcpProf, as, histToneCurve, options.chunkSizeRGB, options.measure); if (settings->verbose) { - printf("Output image / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", autor, autog, autob); + printf ("Output image / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", static_cast(autor), static_cast(autog), static_cast(autob)); } // if clut was used and size of clut cache == 1 we free the memory used by the clutstore (default clut cache size = 1 for 32 bit OS) @@ -1318,10 +1318,10 @@ private: adap = 2000.; }//if no exif data or wrong else { - float E_V = fcomp + log2((fnum * fnum) / fspeed / (fiso / 100.f)); + double E_V = fcomp + log2 ((fnum * fnum) / fspeed / (fiso / 100.f)); E_V += params.toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV - E_V += log2(params.raw.expos); // exposure raw white point ; log2 ==> linear to EV - adap = powf(2.f, E_V - 3.f); //cd / m2 + E_V += log2(params.raw.expos); // exposure raw white point ; log2 ==> linear to EV + adap = std::pow(2.0, E_V - 3.0); //cd / m2 } LUTf CAMBrightCurveJ; diff --git a/rtengine/sleefsseavx.c b/rtengine/sleefsseavx.c deleted file mode 100644 index 0af516f9b..000000000 --- a/rtengine/sleefsseavx.c +++ /dev/null @@ -1,1483 +0,0 @@ -//////////////////////////////////////////////////////////////// -// -// this code was taken from http://shibatch.sourceforge.net/ -// Many thanks to the author of original version: Naoki Shibata -// -// This version contains modifications made by Ingo Weyrich -// -//////////////////////////////////////////////////////////////// - - -#ifndef SLEEFSSEAVX -#define SLEEFSSEAVX - -#include -#include "rt_math.h" -#ifdef __SSE2__ -#include "helpersse2.h" - -#ifdef ENABLE_AVX -#include "helperavx.h" -#endif - -#ifdef __GNUC__ -#define INLINE __inline -#else -#define INLINE inline -#endif - -#define PI4_A .7853981554508209228515625 -#define PI4_B .794662735614792836713604629039764404296875e-8 -#define PI4_C .306161699786838294306516483068750264552437361480769e-16 -#define M_4_PI 1.273239544735162542821171882678754627704620361328125 - -#define L2U .69314718055966295651160180568695068359375 -#define L2L .28235290563031577122588448175013436025525412068e-12 -#define R_LN2 1.442695040888963407359924681001892137426645954152985934135449406931 - -#define PI4_Af 0.78515625f -#define PI4_Bf 0.00024127960205078125f -#define PI4_Cf 6.3329935073852539062e-07f -#define PI4_Df 4.9604681473525147339e-10f - -#define L2Uf 0.693145751953125f -#define L2Lf 1.428606765330187045e-06f -#define R_LN2f 1.442695040888963407359924681001892137426645954152985934135449406931f - -#define INFINITYf ((float)rtengine::RT_INFINITY) -#define NANf ((float)rtengine::RT_NAN) - -static INLINE vdouble vadd3(vdouble v0, vdouble v1, vdouble v2) { - return vadd(vadd(v0, v1), v2); -} - -static INLINE vdouble vadd4(vdouble v0, vdouble v1, vdouble v2, vdouble v3) { - return vadd3(vadd(v0, v1), v2, v3); -} - -static INLINE vdouble vadd5(vdouble v0, vdouble v1, vdouble v2, vdouble v3, vdouble v4) { - return vadd4(vadd(v0, v1), v2, v3, v4); -} - -static INLINE vdouble vadd6(vdouble v0, vdouble v1, vdouble v2, vdouble v3, vdouble v4, vdouble v5) { - return vadd5(vadd(v0, v1), v2, v3, v4, v5); -} - -static INLINE vdouble vadd7(vdouble v0, vdouble v1, vdouble v2, vdouble v3, vdouble v4, vdouble v5, vdouble v6) { - return vadd6(vadd(v0, v1), v2, v3, v4, v5, v6); -} - -static INLINE vdouble vsub3(vdouble v0, vdouble v1, vdouble v2) { - return vsub(vsub(v0, v1), v2); -} - -static INLINE vdouble vsub4(vdouble v0, vdouble v1, vdouble v2, vdouble v3) { - return vsub3(vsub(v0, v1), v2, v3); -} - -static INLINE vdouble vsub5(vdouble v0, vdouble v1, vdouble v2, vdouble v3, vdouble v4) { - return vsub4(vsub(v0, v1), v2, v3, v4); -} - -// - -static INLINE vdouble2 normalize_d(vdouble2 t) { - vdouble2 s; - - s.x = vadd(t.x, t.y); - s.y = vadd(vsub(t.x, s.x), t.y); - - return s; -} - -static INLINE vdouble2 scale_d(vdouble2 d, vdouble s) { - vdouble2 r = {vmul(d.x, s), vmul(d.y, s)}; - return r; -} - -static INLINE vdouble2 add_ss(vdouble x, vdouble y) { - vdouble2 r; - - r.x = vadd(x, y); - r.y = vadd(vsub(x, r.x), y); - - return r; -} - -static INLINE vdouble2 add2_ss(vdouble x, vdouble y) { - vdouble2 r; - - r.x = vadd(x, y); - vdouble v = vsub(r.x, x); - r.y = vadd(vsub(x, vsub(r.x, v)), vsub(y, v)); - - return r; -} - -static INLINE vdouble2 add_ds(vdouble2 x, vdouble y) { - vdouble2 r; - - r.x = vadd(x.x, y); - r.y = vadd3(vsub(x.x, r.x), y, x.y); - - return r; -} - -static INLINE vdouble2 add2_ds(vdouble2 x, vdouble y) { - vdouble2 r; - - r.x = vadd(x.x, y); - vdouble v = vsub(r.x, x.x); - r.y = vadd(vsub(x.x, vsub(r.x, v)), vsub(y, v)); - r.y = vadd(r.y, x.y); - - return r; -} - -static INLINE vdouble2 add_sd(vdouble x, vdouble2 y) { - vdouble2 r; - - r.x = vadd(x, y.x); - r.y = vadd3(vsub(x, r.x), y.x, y.y); - - return r; -} - -static INLINE vdouble2 add_dd(vdouble2 x, vdouble2 y) { - // |x| >= |y| - - vdouble2 r; - - r.x = vadd(x.x, y.x); - r.y = vadd4(vsub(x.x, r.x), y.x, x.y, y.y); - - return r; -} - -static INLINE vdouble2 add2_dd(vdouble2 x, vdouble2 y) { - vdouble2 r; - - r.x = vadd(x.x, y.x); - vdouble v = vsub(r.x, x.x); - r.y = vadd(vsub(x.x, vsub(r.x, v)), vsub(y.x, v)); - r.y = vadd(r.y, vadd(x.y, y.y)); - - return r; -} - -static INLINE vdouble2 div_dd(vdouble2 n, vdouble2 d) { - vdouble t = vrec(d.x); - vdouble dh = vupper(d.x), dl = vsub(d.x, dh); - vdouble th = vupper(t ), tl = vsub(t , th); - vdouble nhh = vupper(n.x), nhl = vsub(n.x, nhh); - - vdouble2 q; - - q.x = vmul(n.x, t); - - vdouble u = vadd5(vsub(vmul(nhh, th), q.x), vmul(nhh, tl), vmul(nhl, th), vmul(nhl, tl), - vmul(q.x, vsub5(vcast_vd_d(1), vmul(dh, th), vmul(dh, tl), vmul(dl, th), vmul(dl, tl)))); - - q.y = vadd(vmul(t, vsub(n.y, vmul(q.x, d.y))), u); - - return q; -} - -static INLINE vdouble2 mul_ss(vdouble x, vdouble y) { - vdouble xh = vupper(x), xl = vsub(x, xh); - vdouble yh = vupper(y), yl = vsub(y, yh); - vdouble2 r; - - r.x = vmul(x, y); - r.y = vadd5(vmul(xh, yh), vneg(r.x), vmul(xl, yh), vmul(xh, yl), vmul(xl, yl)); - - return r; -} - -static INLINE vdouble2 mul_ds(vdouble2 x, vdouble y) { - vdouble xh = vupper(x.x), xl = vsub(x.x, xh); - vdouble yh = vupper(y ), yl = vsub(y , yh); - vdouble2 r; - - r.x = vmul(x.x, y); - r.y = vadd6(vmul(xh, yh), vneg(r.x), vmul(xl, yh), vmul(xh, yl), vmul(xl, yl), vmul(x.y, y)); - - return r; -} - -static INLINE vdouble2 mul_dd(vdouble2 x, vdouble2 y) { - vdouble xh = vupper(x.x), xl = vsub(x.x, xh); - vdouble yh = vupper(y.x), yl = vsub(y.x, yh); - vdouble2 r; - - r.x = vmul(x.x, y.x); - r.y = vadd7(vmul(xh, yh), vneg(r.x), vmul(xl, yh), vmul(xh, yl), vmul(xl, yl), vmul(x.x, y.y), vmul(x.y, y.x)); - - return r; -} - -static INLINE vdouble2 squ_d(vdouble2 x) { - vdouble xh = vupper(x.x), xl = vsub(x.x, xh); - vdouble2 r; - - r.x = vmul(x.x, x.x); - r.y = vadd5(vmul(xh, xh), vneg(r.x), vmul(vadd(xh, xh), xl), vmul(xl, xl), vmul(x.x, vadd(x.y, x.y))); - - return r; -} - -static INLINE vdouble2 rec_s(vdouble d) { - vdouble t = vrec(d); - vdouble dh = vupper(d), dl = vsub(d, dh); - vdouble th = vupper(t), tl = vsub(t, th); - vdouble2 q; - - q.x = t; - q.y = vmul(t, vsub5(vcast_vd_d(1), vmul(dh, th), vmul(dh, tl), vmul(dl, th), vmul(dl, tl))); - - return q; -} - -static INLINE vdouble2 sqrt_d(vdouble2 d) { - vdouble t = vsqrt(vadd(d.x, d.y)); - return scale_d(mul_dd(add2_dd(d, mul_ss(t, t)), rec_s(t)), vcast_vd_d(0.5)); -} - -// - -static INLINE vdouble xldexp(vdouble x, vint q) { return vldexp(x, q); } - -static INLINE vint xilogb(vdouble d) { - vdouble e = vcast_vd_vi(vsubi(vilogbp1(vabs(d)), vcast_vi_i(1))); - e = vsel(vmask_eq(d, vcast_vd_d(0)), vcast_vd_d(-2147483648.0), e); - e = vsel(vmask_eq(vabs(d), vcast_vd_d(rtengine::RT_INFINITY)), vcast_vd_d(2147483647), e); - return vrint_vi_vd(e); -} - -static INLINE vdouble xsin(vdouble d) { - vint q; - vdouble u, s; - - q = vrint_vi_vd(vmul(d, vcast_vd_d(rtengine::RT_1_PI))); - - u = vcast_vd_vi(q); - d = vadd(d, vmul(u, vcast_vd_d(-PI4_A*4))); - d = vadd(d, vmul(u, vcast_vd_d(-PI4_B*4))); - d = vadd(d, vmul(u, vcast_vd_d(-PI4_C*4))); - - s = vmul(d, d); - - d = vsel(vmaski_eq(vandi(q, vcast_vi_i(1)), vcast_vi_i(1)), vneg(d), d); - - u = vcast_vd_d(-7.97255955009037868891952e-18); - u = vmla(u, s, vcast_vd_d(2.81009972710863200091251e-15)); - u = vmla(u, s, vcast_vd_d(-7.64712219118158833288484e-13)); - u = vmla(u, s, vcast_vd_d(1.60590430605664501629054e-10)); - u = vmla(u, s, vcast_vd_d(-2.50521083763502045810755e-08)); - u = vmla(u, s, vcast_vd_d(2.75573192239198747630416e-06)); - u = vmla(u, s, vcast_vd_d(-0.000198412698412696162806809)); - u = vmla(u, s, vcast_vd_d(0.00833333333333332974823815)); - u = vmla(u, s, vcast_vd_d(-0.166666666666666657414808)); - - u = vmla(s, vmul(u, d), d); - - return u; -} - -static INLINE vdouble xcos(vdouble d) { - vint q; - vdouble u, s; - - q = vrint_vi_vd(vsub(vmul(d, vcast_vd_d(rtengine::RT_1_PI)), vcast_vd_d(0.5))); - q = vaddi(vaddi(q, q), vcast_vi_i(1)); - - u = vcast_vd_vi(q); - d = vadd(d, vmul(u, vcast_vd_d(-PI4_A*2))); - d = vadd(d, vmul(u, vcast_vd_d(-PI4_B*2))); - d = vadd(d, vmul(u, vcast_vd_d(-PI4_C*2))); - - s = vmul(d, d); - - d = vsel(vmaski_eq(vandi(q, vcast_vi_i(2)), vcast_vi_i(0)), vneg(d), d); - - u = vcast_vd_d(-7.97255955009037868891952e-18); - u = vmla(u, s, vcast_vd_d(2.81009972710863200091251e-15)); - u = vmla(u, s, vcast_vd_d(-7.64712219118158833288484e-13)); - u = vmla(u, s, vcast_vd_d(1.60590430605664501629054e-10)); - u = vmla(u, s, vcast_vd_d(-2.50521083763502045810755e-08)); - u = vmla(u, s, vcast_vd_d(2.75573192239198747630416e-06)); - u = vmla(u, s, vcast_vd_d(-0.000198412698412696162806809)); - u = vmla(u, s, vcast_vd_d(0.00833333333333332974823815)); - u = vmla(u, s, vcast_vd_d(-0.166666666666666657414808)); - - u = vmla(s, vmul(u, d), d); - - return u; -} - -static INLINE vdouble2 xsincos(vdouble d) { - vint q; - vmask m; - vdouble u, s, t, rx, ry; - vdouble2 r; - - q = vrint_vi_vd(vmul(d, vcast_vd_d(rtengine::RT_2_PI))); - - s = d; - - u = vcast_vd_vi(q); - s = vmla(u, vcast_vd_d(-PI4_A*2), s); - s = vmla(u, vcast_vd_d(-PI4_B*2), s); - s = vmla(u, vcast_vd_d(-PI4_C*2), s); - - t = s; - - s = vmul(s, s); - - u = vcast_vd_d(1.58938307283228937328511e-10); - u = vmla(u, s, vcast_vd_d(-2.50506943502539773349318e-08)); - u = vmla(u, s, vcast_vd_d(2.75573131776846360512547e-06)); - u = vmla(u, s, vcast_vd_d(-0.000198412698278911770864914)); - u = vmla(u, s, vcast_vd_d(0.0083333333333191845961746)); - u = vmla(u, s, vcast_vd_d(-0.166666666666666130709393)); - u = vmul(vmul(u, s), t); - - rx = vadd(t, u); - - u = vcast_vd_d(-1.13615350239097429531523e-11); - u = vmla(u, s, vcast_vd_d(2.08757471207040055479366e-09)); - u = vmla(u, s, vcast_vd_d(-2.75573144028847567498567e-07)); - u = vmla(u, s, vcast_vd_d(2.48015872890001867311915e-05)); - u = vmla(u, s, vcast_vd_d(-0.00138888888888714019282329)); - u = vmla(u, s, vcast_vd_d(0.0416666666666665519592062)); - u = vmla(u, s, vcast_vd_d(-0.5)); - - ry = vadd(vcast_vd_d(1), vmul(s, u)); - - m = vmaski_eq(vandi(q, vcast_vi_i(1)), vcast_vi_i(0)); - r.x = vsel(m, rx, ry); - r.y = vsel(m, ry, rx); - - m = vmaski_eq(vandi(q, vcast_vi_i(2)), vcast_vi_i(2)); - r.x = vreinterpret_vd_vm(vxorm(vandm(m, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(r.x))); - - m = vmaski_eq(vandi(vaddi(q, vcast_vi_i(1)), vcast_vi_i(2)), vcast_vi_i(2)); - r.y = vreinterpret_vd_vm(vxorm(vandm(m, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(r.y))); - - m = vmask_isinf(d); - r.x = vsel(m, vcast_vd_d(rtengine::RT_NAN), r.x); - r.y = vsel(m, vcast_vd_d(rtengine::RT_NAN), r.y); - - return r; -} - -static INLINE vdouble xtan(vdouble d) { - vint q; - vdouble u, s, x; - vmask m; - - q = vrint_vi_vd(vmul(d, vcast_vd_d(rtengine::RT_2_PI))); - - u = vcast_vd_vi(q); - x = vadd(d, vmul(u, vcast_vd_d(-PI4_A*2))); - x = vadd(x, vmul(u, vcast_vd_d(-PI4_B*2))); - x = vadd(x, vmul(u, vcast_vd_d(-PI4_C*2))); - - s = vmul(x, x); - - m = vmaski_eq(vandi(q, vcast_vi_i(1)), vcast_vi_i(1)); - x = vsel(m, vneg(x), x); - - u = vcast_vd_d(1.01419718511083373224408e-05); - u = vmla(u, s, vcast_vd_d(-2.59519791585924697698614e-05)); - u = vmla(u, s, vcast_vd_d(5.23388081915899855325186e-05)); - u = vmla(u, s, vcast_vd_d(-3.05033014433946488225616e-05)); - u = vmla(u, s, vcast_vd_d(7.14707504084242744267497e-05)); - u = vmla(u, s, vcast_vd_d(8.09674518280159187045078e-05)); - u = vmla(u, s, vcast_vd_d(0.000244884931879331847054404)); - u = vmla(u, s, vcast_vd_d(0.000588505168743587154904506)); - u = vmla(u, s, vcast_vd_d(0.00145612788922812427978848)); - u = vmla(u, s, vcast_vd_d(0.00359208743836906619142924)); - u = vmla(u, s, vcast_vd_d(0.00886323944362401618113356)); - u = vmla(u, s, vcast_vd_d(0.0218694882853846389592078)); - u = vmla(u, s, vcast_vd_d(0.0539682539781298417636002)); - u = vmla(u, s, vcast_vd_d(0.133333333333125941821962)); - u = vmla(u, s, vcast_vd_d(0.333333333333334980164153)); - - u = vmla(s, vmul(u, x), x); - - u = vsel(m, vrec(u), u); - - u = vsel(vmask_isinf(d), vcast_vd_d(rtengine::RT_NAN), u); - - return u; -} - -static INLINE vdouble atan2k(vdouble y, vdouble x) { - vdouble s, t, u; - vint q; - vmask p; - - q = vseli_lt(x, vcast_vd_d(0), vcast_vi_i(-2), vcast_vi_i(0)); - x = vabs(x); - - q = vseli_lt(x, y, vaddi(q, vcast_vi_i(1)), q); - p = vmask_lt(x, y); - s = vsel (p, vneg(x), y); - t = vmax (x, y); - - s = vdiv(s, t); - t = vmul(s, s); - - u = vcast_vd_d(-1.88796008463073496563746e-05); - u = vmla(u, t, vcast_vd_d(0.000209850076645816976906797)); - u = vmla(u, t, vcast_vd_d(-0.00110611831486672482563471)); - u = vmla(u, t, vcast_vd_d(0.00370026744188713119232403)); - u = vmla(u, t, vcast_vd_d(-0.00889896195887655491740809)); - u = vmla(u, t, vcast_vd_d(0.016599329773529201970117)); - u = vmla(u, t, vcast_vd_d(-0.0254517624932312641616861)); - u = vmla(u, t, vcast_vd_d(0.0337852580001353069993897)); - u = vmla(u, t, vcast_vd_d(-0.0407629191276836500001934)); - u = vmla(u, t, vcast_vd_d(0.0466667150077840625632675)); - u = vmla(u, t, vcast_vd_d(-0.0523674852303482457616113)); - u = vmla(u, t, vcast_vd_d(0.0587666392926673580854313)); - u = vmla(u, t, vcast_vd_d(-0.0666573579361080525984562)); - u = vmla(u, t, vcast_vd_d(0.0769219538311769618355029)); - u = vmla(u, t, vcast_vd_d(-0.090908995008245008229153)); - u = vmla(u, t, vcast_vd_d(0.111111105648261418443745)); - u = vmla(u, t, vcast_vd_d(-0.14285714266771329383765)); - u = vmla(u, t, vcast_vd_d(0.199999999996591265594148)); - u = vmla(u, t, vcast_vd_d(-0.333333333333311110369124)); - - t = vadd(s, vmul(s, vmul(t, u))); - t = vadd(t, vmul(vcast_vd_vi(q), vcast_vd_d(rtengine::RT_PI/2))); - - return t; -} - -static INLINE vdouble xatan2(vdouble y, vdouble x) { - vdouble r = atan2k(vabs(y), x); - - r = vmulsign(r, x); - r = vsel(vorm(vmask_isinf(x), vmask_eq(x, vcast_vd_d(0))), vsub(vcast_vd_d(rtengine::RT_PI/2), visinf2(x, vmulsign(vcast_vd_d(rtengine::RT_PI/2), x))), r); - r = vsel(vmask_isinf(y), vsub(vcast_vd_d(rtengine::RT_PI/2), visinf2(x, vmulsign(vcast_vd_d(rtengine::RT_PI/4), x))), r); - r = vsel(vmask_eq(y, vcast_vd_d(0)), vsel(vmask_eq(vsign(x), vcast_vd_d(-1.0)), vcast_vd_d(rtengine::RT_PI), vcast_vd_d(0)), r); - - return vsel(vorm(vmask_isnan(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_NAN), vmulsign(r, y)); -} - -static INLINE vdouble xasin(vdouble d) { - vdouble x, y; - x = vadd(vcast_vd_d(1), d); - y = vsub(vcast_vd_d(1), d); - x = vmul(x, y); - x = vsqrt(x); - x = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), atan2k(vabs(d), x)); - return vmulsign(x, d); -} - -static INLINE vdouble xacos(vdouble d) { - vdouble x, y; - x = vadd(vcast_vd_d(1), d); - y = vsub(vcast_vd_d(1), d); - x = vmul(x, y); - x = vsqrt(x); - x = vmulsign(atan2k(x, vabs(d)), d); - y = (vdouble)vandm(vmask_lt(d, vcast_vd_d(0)), (vmask)vcast_vd_d(rtengine::RT_PI)); - x = vadd(x, y); - return x; -} - -static INLINE vdouble xatan(vdouble s) { - vdouble t, u; - vint q; - - q = vseli_lt(s, vcast_vd_d(0), vcast_vi_i(2), vcast_vi_i(0)); - s = vabs(s); - - q = vseli_lt(vcast_vd_d(1), s, vaddi(q, vcast_vi_i(1)), q); - s = vsel(vmask_lt(vcast_vd_d(1), s), vdiv(vcast_vd_d(1), s), s); - - t = vmul(s, s); - - u = vcast_vd_d(-1.88796008463073496563746e-05); - u = vmla(u, t, vcast_vd_d(0.000209850076645816976906797)); - u = vmla(u, t, vcast_vd_d(-0.00110611831486672482563471)); - u = vmla(u, t, vcast_vd_d(0.00370026744188713119232403)); - u = vmla(u, t, vcast_vd_d(-0.00889896195887655491740809)); - u = vmla(u, t, vcast_vd_d(0.016599329773529201970117)); - u = vmla(u, t, vcast_vd_d(-0.0254517624932312641616861)); - u = vmla(u, t, vcast_vd_d(0.0337852580001353069993897)); - u = vmla(u, t, vcast_vd_d(-0.0407629191276836500001934)); - u = vmla(u, t, vcast_vd_d(0.0466667150077840625632675)); - u = vmla(u, t, vcast_vd_d(-0.0523674852303482457616113)); - u = vmla(u, t, vcast_vd_d(0.0587666392926673580854313)); - u = vmla(u, t, vcast_vd_d(-0.0666573579361080525984562)); - u = vmla(u, t, vcast_vd_d(0.0769219538311769618355029)); - u = vmla(u, t, vcast_vd_d(-0.090908995008245008229153)); - u = vmla(u, t, vcast_vd_d(0.111111105648261418443745)); - u = vmla(u, t, vcast_vd_d(-0.14285714266771329383765)); - u = vmla(u, t, vcast_vd_d(0.199999999996591265594148)); - u = vmla(u, t, vcast_vd_d(-0.333333333333311110369124)); - - t = vadd(s, vmul(s, vmul(t, u))); - - t = vsel(vmaski_eq(vandi(q, vcast_vi_i(1)), vcast_vi_i(1)), vsub(vcast_vd_d(rtengine::RT_PI/2), t), t); - t = vsel(vmaski_eq(vandi(q, vcast_vi_i(2)), vcast_vi_i(2)), vneg(t), t); - - return t; -} - -static INLINE vdouble xlog(vdouble d) { - vdouble x, x2; - vdouble t, m; - vint e; - - e = vilogbp1(vmul(d, vcast_vd_d(0.7071))); - m = vldexp(d, vsubi(vcast_vi_i(0), e)); - - x = vdiv(vadd(vcast_vd_d(-1), m), vadd(vcast_vd_d(1), m)); - x2 = vmul(x, x); - - t = vcast_vd_d(0.148197055177935105296783); - t = vmla(t, x2, vcast_vd_d(0.153108178020442575739679)); - t = vmla(t, x2, vcast_vd_d(0.181837339521549679055568)); - t = vmla(t, x2, vcast_vd_d(0.22222194152736701733275)); - t = vmla(t, x2, vcast_vd_d(0.285714288030134544449368)); - t = vmla(t, x2, vcast_vd_d(0.399999999989941956712869)); - t = vmla(t, x2, vcast_vd_d(0.666666666666685503450651)); - t = vmla(t, x2, vcast_vd_d(2)); - - x = vadd(vmul(x, t), vmul(vcast_vd_d(0.693147180559945286226764), vcast_vd_vi(e))); - - x = vsel(vmask_ispinf(d), vcast_vd_d(rtengine::RT_INFINITY), x); - x = vsel(vmask_gt(vcast_vd_d(0), d), vcast_vd_d(rtengine::RT_NAN), x); - x = vsel(vmask_eq(d, vcast_vd_d(0)), vcast_vd_d(-rtengine::RT_INFINITY), x); - - return x; -} - -static INLINE vdouble xexp(vdouble d) { - vint q = vrint_vi_vd(vmul(d, vcast_vd_d(R_LN2))); - vdouble s, u; - - s = vadd(d, vmul(vcast_vd_vi(q), vcast_vd_d(-L2U))); - s = vadd(s, vmul(vcast_vd_vi(q), vcast_vd_d(-L2L))); - - u = vcast_vd_d(2.08860621107283687536341e-09); - u = vmla(u, s, vcast_vd_d(2.51112930892876518610661e-08)); - u = vmla(u, s, vcast_vd_d(2.75573911234900471893338e-07)); - u = vmla(u, s, vcast_vd_d(2.75572362911928827629423e-06)); - u = vmla(u, s, vcast_vd_d(2.4801587159235472998791e-05)); - u = vmla(u, s, vcast_vd_d(0.000198412698960509205564975)); - u = vmla(u, s, vcast_vd_d(0.00138888888889774492207962)); - u = vmla(u, s, vcast_vd_d(0.00833333333331652721664984)); - u = vmla(u, s, vcast_vd_d(0.0416666666666665047591422)); - u = vmla(u, s, vcast_vd_d(0.166666666666666851703837)); - u = vmla(u, s, vcast_vd_d(0.5)); - - u = vadd(vcast_vd_d(1), vadd(s, vmul(vmul(s, s), u))); - - u = vldexp(u, q); - - u = vsel(vmask_isminf(d), vcast_vd_d(0), u); - - return u; -} - -static INLINE vdouble2 logk(vdouble d) { - vdouble2 x, x2; - vdouble t, m; - vint e; - - e = vilogbp1(vmul(d, vcast_vd_d(0.7071))); - m = vldexp(d, vsubi(vcast_vi_i(0), e)); - - x = div_dd(add2_ss(vcast_vd_d(-1), m), add2_ss(vcast_vd_d(1), m)); - x2 = squ_d(x); - x2 = normalize_d(x2); - - t = vcast_vd_d(0.134601987501262130076155); - t = vmla(t, x2.x, vcast_vd_d(0.132248509032032670243288)); - t = vmla(t, x2.x, vcast_vd_d(0.153883458318096079652524)); - t = vmla(t, x2.x, vcast_vd_d(0.181817427573705403298686)); - t = vmla(t, x2.x, vcast_vd_d(0.222222231326187414840781)); - t = vmla(t, x2.x, vcast_vd_d(0.285714285651261412873718)); - t = vmla(t, x2.x, vcast_vd_d(0.400000000000222439910458)); - t = vmla(t, x2.x, vcast_vd_d(0.666666666666666371239645)); - - return add2_dd(mul_ds(dd(vcast_vd_d(0.693147180559945286226764), vcast_vd_d(2.319046813846299558417771e-17)), - vcast_vd_vi(e)), - add2_dd(scale_d(x, vcast_vd_d(2)), mul_ds(mul_dd(x2, x), t))); -} - -static INLINE vdouble expk(vdouble2 d) { - vdouble u = vmul(vadd(d.x, d.y), vcast_vd_d(R_LN2)); - vint q = vrint_vi_vd(u); - vdouble2 s, t; - - s = add2_ds(d, vmul(vcast_vd_vi(q), vcast_vd_d(-L2U))); - s = add2_ds(s, vmul(vcast_vd_vi(q), vcast_vd_d(-L2L))); - - q = vrint_vi_vd(vmin(vmax(vcast_vd_d(-2047.49), u), vcast_vd_d(2047.49))); - - s = normalize_d(s); - - u = vcast_vd_d(2.51069683420950419527139e-08); - u = vmla(u, s.x, vcast_vd_d(2.76286166770270649116855e-07)); - u = vmla(u, s.x, vcast_vd_d(2.75572496725023574143864e-06)); - u = vmla(u, s.x, vcast_vd_d(2.48014973989819794114153e-05)); - u = vmla(u, s.x, vcast_vd_d(0.000198412698809069797676111)); - u = vmla(u, s.x, vcast_vd_d(0.0013888888939977128960529)); - u = vmla(u, s.x, vcast_vd_d(0.00833333333332371417601081)); - u = vmla(u, s.x, vcast_vd_d(0.0416666666665409524128449)); - u = vmla(u, s.x, vcast_vd_d(0.166666666666666740681535)); - u = vmla(u, s.x, vcast_vd_d(0.500000000000000999200722)); - - t = add_dd(s, mul_ds(squ_d(s), u)); - - t = add_sd(vcast_vd_d(1), t); - u = vadd(t.x, t.y); - u = vldexp(u, q); - - return u; -} - -static INLINE vdouble xpow(vdouble x, vdouble y) { -#if 1 - vmask yisint = vmask_eq(vcast_vd_vi(vrint_vi_vd(y)), y); - vmask yisodd = vandm(vmaski_eq(vandi(vrint_vi_vd(y), vcast_vi_i(1)), vcast_vi_i(1)), yisint); - - vdouble result = expk(mul_ds(logk(vabs(x)), y)); - - //result = vsel(vmask_isnan(result), vcast_vd_d(rtengine::RT_INFINITY), result); - - result = vmul(result, - vsel(vmask_gt(x, vcast_vd_d(0)), - vcast_vd_d(1), - vsel(yisint, - vsel(yisodd, - vcast_vd_d(-1), - vcast_vd_d(1)), - vcast_vd_d(rtengine::RT_NAN)))); - - vdouble efx = vreinterpret_vd_vm(vxorm(vreinterpret_vm_vd(vsub(vabs(x), vcast_vd_d(1))), vsignbit(y))); - - result = vsel(vmask_isinf(y), - vsel(vmask_lt(efx, vcast_vd_d(0)), - vcast_vd_d(0), - vsel(vmask_eq(efx, vcast_vd_d(0)), - vcast_vd_d(1.0), - vcast_vd_d(rtengine::RT_INFINITY))), - result); - - result = vsel(vorm(vmask_isinf(x), vmask_eq(x, vcast_vd_d(0))), - vmul(vsel(yisodd, vsign(x), vcast_vd_d(1)), - vsel(vmask_lt(vsel(vmask_eq(x, vcast_vd_d(0)), vneg(y), y), vcast_vd_d(0)), - vcast_vd_d(0), - vcast_vd_d(rtengine::RT_INFINITY))), - result); - - result = vsel(vorm(vmask_isnan(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_NAN), result); - - result = vsel(vorm(vmask_eq(y, vcast_vd_d(0)), vmask_eq(x, vcast_vd_d(1))), vcast_vd_d(1), result); - - return result; -#else - return expk(mul_ds(logk(x), y)); -#endif -} - -static INLINE vdouble2 expk2(vdouble2 d) { - vdouble u = vmul(vadd(d.x, d.y), vcast_vd_d(R_LN2)); - vint q = vrint_vi_vd(u); - vdouble2 s, t; - - s = add2_ds(d, vmul(vcast_vd_vi(q), vcast_vd_d(-L2U))); - s = add2_ds(s, vmul(vcast_vd_vi(q), vcast_vd_d(-L2L))); - - q = vrint_vi_vd(vmin(vmax(vcast_vd_d(-2047.49), u), vcast_vd_d(2047.49))); - - s = normalize_d(s); - - u = vcast_vd_d(2.51069683420950419527139e-08); - u = vmla(u, s.x, vcast_vd_d(2.76286166770270649116855e-07)); - u = vmla(u, s.x, vcast_vd_d(2.75572496725023574143864e-06)); - u = vmla(u, s.x, vcast_vd_d(2.48014973989819794114153e-05)); - u = vmla(u, s.x, vcast_vd_d(0.000198412698809069797676111)); - u = vmla(u, s.x, vcast_vd_d(0.0013888888939977128960529)); - u = vmla(u, s.x, vcast_vd_d(0.00833333333332371417601081)); - u = vmla(u, s.x, vcast_vd_d(0.0416666666665409524128449)); - u = vmla(u, s.x, vcast_vd_d(0.166666666666666740681535)); - u = vmla(u, s.x, vcast_vd_d(0.500000000000000999200722)); - - t = add_dd(s, mul_ds(squ_d(s), u)); - - t = add_sd(vcast_vd_d(1), t); - - return dd(vldexp(t.x, q), vldexp(t.y, q)); -} - -static INLINE vdouble xsinh(vdouble x) { - vdouble y = vabs(x); - vdouble2 d = expk2(dd(y, vcast_vd_d(0))); - d = add2_dd(d, div_dd(dd(vcast_vd_d(-1), vcast_vd_d(0)), d)); - y = vmul(vadd(d.x, d.y), vcast_vd_d(0.5)); - - y = vsel(vorm(vmask_isinf(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_INFINITY), y); - y = vmulsign(y, x); - y = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), y); - - return y; -} - -static INLINE vdouble xcosh(vdouble x) { - vdouble2 d = expk2(dd(x, vcast_vd_d(0))); - d = add2_dd(d, div_dd(dd(vcast_vd_d(1), vcast_vd_d(0)), d)); - vdouble y = vmul(vadd(d.x, d.y), vcast_vd_d(0.5)); - - y = vsel(vorm(vmask_isinf(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_INFINITY), y); - y = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), y); - - return y; -} - -static INLINE vdouble xtanh(vdouble x) { - vdouble y = vabs(x); - vdouble2 d = expk2(dd(y, vcast_vd_d(0))); - vdouble2 e = div_dd(dd(vcast_vd_d(1), vcast_vd_d(0)), d); - d = div_dd(add2_dd(d, scale_d(e, vcast_vd_d(-1))), add2_dd(d, e)); - y = d.x + d.y; - - y = vsel(vorm(vmask_isinf(x), vmask_isnan(y)), vcast_vd_d(1.0), y); - y = vmulsign(y, x); - y = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), y); - - return y; -} - -static INLINE vdouble2 logk2(vdouble2 d) { - vdouble2 x, x2, m; - vdouble t; - vint e; - - d = normalize_d(d); - e = vilogbp1(vmul(d.x, vcast_vd_d(0.7071))); - m = scale_d(d, vldexp(vcast_vd_d(1), vsubi(vcast_vi_i(0), e))); - - x = div_dd(add2_ds(m, vcast_vd_d(-1)), add2_ds(m, vcast_vd_d(1))); - x2 = squ_d(x); - x2 = normalize_d(x2); - - t = vcast_vd_d(0.134601987501262130076155); - t = vmla(t, x2.x, vcast_vd_d(0.132248509032032670243288)); - t = vmla(t, x2.x, vcast_vd_d(0.153883458318096079652524)); - t = vmla(t, x2.x, vcast_vd_d(0.181817427573705403298686)); - t = vmla(t, x2.x, vcast_vd_d(0.222222231326187414840781)); - t = vmla(t, x2.x, vcast_vd_d(0.285714285651261412873718)); - t = vmla(t, x2.x, vcast_vd_d(0.400000000000222439910458)); - t = vmla(t, x2.x, vcast_vd_d(0.666666666666666371239645)); - - return add2_dd(mul_ds(dd(vcast_vd_d(0.693147180559945286226764), vcast_vd_d(2.319046813846299558417771e-17)), - vcast_vd_vi(e)), - add2_dd(scale_d(x, vcast_vd_d(2)), mul_ds(mul_dd(x2, x), t))); -} - -static INLINE vdouble xasinh(vdouble x) { - vdouble y = vabs(x); - vdouble2 d = logk2(add2_ds(sqrt_d(add2_ds(mul_ss(y, y), vcast_vd_d(1))), y)); - y = vadd(d.x, d.y); - - y = vsel(vorm(vmask_isinf(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_INFINITY), y); - y = vmulsign(y, x); - y = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), y); - - return y; -} - -static INLINE vdouble xacosh(vdouble x) { - vdouble2 d = logk2(add2_ds(sqrt_d(add2_ds(mul_ss(x, x), vcast_vd_d(-1))), x)); - vdouble y = vadd(d.x, d.y); - - y = vsel(vorm(vmask_isinf(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_INFINITY), y); - y = vsel(vmask_eq(x, vcast_vd_d(1.0)), vcast_vd_d(0.0), y); - y = vsel(vmask_lt(x, vcast_vd_d(1.0)), vcast_vd_d(rtengine::RT_NAN), y); - y = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), y); - - return y; -} - -static INLINE vdouble xatanh(vdouble x) { - vdouble y = vabs(x); - vdouble2 d = logk2(div_dd(add2_ss(vcast_vd_d(1), y), add2_ss(vcast_vd_d(1), -y))); - y = vsel(vmask_gt(y, vcast_vd_d(1.0)), vcast_vd_d(rtengine::RT_NAN), vsel(vmask_eq(y, vcast_vd_d(1.0)), vcast_vd_d(rtengine::RT_INFINITY), vmul(vadd(d.x, d.y), vcast_vd_d(0.5)))); - - y = vsel(vorm(vmask_isinf(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_NAN), y); - y = vmulsign(y, x); - y = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), y); - - return y; -} - -static INLINE vdouble xcbrt(vdouble d) { - vdouble x, y, q = vcast_vd_d(1.0); - vint e, qu, re; - vdouble t; - - e = vilogbp1(vabs(d)); - d = vldexp(d, vsubi(vcast_vi_i(0), e)); - - t = vadd(vcast_vd_vi(e), vcast_vd_d(6144)); - qu = vtruncate_vi_vd(vdiv(t, vcast_vd_d(3))); - re = vtruncate_vi_vd(vsub(t, vmul(vcast_vd_vi(qu), vcast_vd_d(3)))); - - q = vsel(vmaski_eq(re, vcast_vi_i(1)), vcast_vd_d(1.2599210498948731647672106), q); - q = vsel(vmaski_eq(re, vcast_vi_i(2)), vcast_vd_d(1.5874010519681994747517056), q); - q = vldexp(q, vsubi(qu, vcast_vi_i(2048))); - - q = vmulsign(q, d); - - d = vabs(d); - - x = vcast_vd_d(-0.640245898480692909870982); - x = vmla(x, d, vcast_vd_d(2.96155103020039511818595)); - x = vmla(x, d, vcast_vd_d(-5.73353060922947843636166)); - x = vmla(x, d, vcast_vd_d(6.03990368989458747961407)); - x = vmla(x, d, vcast_vd_d(-3.85841935510444988821632)); - x = vmla(x, d, vcast_vd_d(2.2307275302496609725722)); - - y = vmul(x, x); y = vmul(y, y); x = vsub(x, vmul(vmla(d, y, vneg(x)), vcast_vd_d(1.0 / 3.0))); - y = vmul(vmul(d, x), x); - y = vmul(vsub(y, vmul(vmul(vcast_vd_d(2.0 / 3.0), y), vmla(y, x, vcast_vd_d(-1.0)))), q); - - return y; -} - -static INLINE vdouble xexp2(vdouble a) { - vdouble u = expk(mul_ds(dd(vcast_vd_d(0.69314718055994528623), vcast_vd_d(2.3190468138462995584e-17)), a)); - u = vsel(vmask_ispinf(a), vcast_vd_d(rtengine::RT_INFINITY), u); - u = vsel(vmask_isminf(a), vcast_vd_d(0), u); - return u; -} - -static INLINE vdouble xexp10(vdouble a) { - vdouble u = expk(mul_ds(dd(vcast_vd_d(2.3025850929940459011), vcast_vd_d(-2.1707562233822493508e-16)), a)); - u = vsel(vmask_ispinf(a), vcast_vd_d(rtengine::RT_INFINITY), u); - u = vsel(vmask_isminf(a), vcast_vd_d(0), u); - return u; -} - -static INLINE vdouble xexpm1(vdouble a) { - vdouble2 d = add2_ds(expk2(dd(a, vcast_vd_d(0))), vcast_vd_d(-1.0)); - vdouble x = d.x + d.y; - x = vsel(vmask_ispinf(a), vcast_vd_d(rtengine::RT_INFINITY), x); - x = vsel(vmask_isminf(a), vcast_vd_d(-1), x); - return x; -} - -static INLINE vdouble xlog10(vdouble a) { - vdouble2 d = mul_dd(logk(a), dd(vcast_vd_d(0.43429448190325176116), vcast_vd_d(6.6494347733425473126e-17))); - vdouble x = d.x + d.y; - - x = vsel(vmask_ispinf(a), vcast_vd_d(rtengine::RT_INFINITY), x); - x = vsel(vmask_gt(vcast_vd_d(0), a), vcast_vd_d(rtengine::RT_NAN), x); - x = vsel(vmask_eq(a, vcast_vd_d(0)), vcast_vd_d(-rtengine::RT_INFINITY), x); - - return x; -} - -static INLINE vdouble xlog1p(vdouble a) { - vdouble2 d = logk2(add2_ss(a, vcast_vd_d(1))); - vdouble x = d.x + d.y; - - x = vsel(vmask_ispinf(a), vcast_vd_d(rtengine::RT_INFINITY), x); - x = vsel(vmask_gt(vcast_vd_d(-1), a), vcast_vd_d(rtengine::RT_NAN), x); - x = vsel(vmask_eq(a, vcast_vd_d(-1)), vcast_vd_d(-rtengine::RT_INFINITY), x); - - return x; -} - -// - -typedef struct { - vfloat x, y; -} vfloat2; - -static INLINE vfloat vabsf(vfloat f) { return (vfloat)vandnotm((vmask)vcast_vf_f(-0.0f), (vmask)f); } -static INLINE vfloat vnegf(vfloat f) { return (vfloat)vxorm((vmask)f, (vmask)vcast_vf_f(-0.0f)); } - -#ifdef __SSE4_1__ -// only one instruction when using SSE4.1 -static INLINE vfloat vself(vmask mask, vfloat x, vfloat y) { - return _mm_blendv_ps(y,x,(vfloat)mask); -} - -static INLINE vint vselc(vmask mask, vint x, vint y) { - return _mm_blendv_epi8(y,x,mask); -} - -#else -// three instructions when using SSE2 -static INLINE vfloat vself(vmask mask, vfloat x, vfloat y) { - return (vfloat)vorm(vandm(mask, (vmask)x), vandnotm(mask, (vmask)y)); -} - -static INLINE vint vselc(vmask mask, vint x, vint y) { - return vorm(vandm(mask, (vmask)x), vandnotm(mask, (vmask)y)); -} -#endif - -static INLINE vfloat vselfzero(vmask mask, vfloat x) { - // returns value of x if corresponding mask bits are 1, else returns 0 - // faster than vself(mask, x, ZEROV) - return _mm_and_ps((vfloat)mask, x); -} -static INLINE vfloat vselfnotzero(vmask mask, vfloat x) { - // returns value of x if corresponding mask bits are 0, else returns 0 - // faster than vself(mask, ZEROV, x) - return _mm_andnot_ps((vfloat)mask, x); -} - -static INLINE vint vselizero(vmask mask, vint x) { - // returns value of x if corresponding mask bits are 1, else returns 0 - // faster than vselc(mask, x, ZEROV) - return _mm_and_si128(mask, x); -} -static INLINE vint vselinotzero(vmask mask, vint x) { - // returns value of x if corresponding mask bits are 0, else returns 0 - // faster than vselc(mask, ZEROV, x) - return _mm_andnot_si128(mask, x); -} - -static INLINE vint2 vseli2_lt(vfloat f0, vfloat f1, vint2 x, vint2 y) { - vint2 m2 = vcast_vi2_vm(vmaskf_lt(f0, f1)); - return vori2(vandi2(m2, x), vandnoti2(m2, y)); -} - -static INLINE vmask vsignbitf(vfloat f) { - return vandm((vmask)f, (vmask)vcast_vf_f(-0.0f)); -} - -static INLINE vfloat vmulsignf(vfloat x, vfloat y) { - return (vfloat)vxorm((vmask)x, vsignbitf(y)); -} - -static INLINE vfloat vsignf(vfloat f) { - return (vfloat)vorm((vmask)vcast_vf_f(1.0f), vandm((vmask)vcast_vf_f(-0.0f), (vmask)f)); -} - -static INLINE vmask vmaskf_isinf(vfloat d) { return vmaskf_eq(vabsf(d), vcast_vf_f(INFINITYf)); } -static INLINE vmask vmaskf_ispinf(vfloat d) { return vmaskf_eq(d, vcast_vf_f(INFINITYf)); } -static INLINE vmask vmaskf_isminf(vfloat d) { return vmaskf_eq(d, vcast_vf_f(-INFINITYf)); } -static INLINE vmask vmaskf_isnan(vfloat d) { return vmaskf_neq(d, d); } -// the following is equivalent to vorm(vmaskf_isnan(a), vmaskf_isnan(b)), but faster -static INLINE vmask vmaskf_isnan(vfloat a, vfloat b) { return (vmask)_mm_cmpunord_ps(a, b); } -static INLINE vfloat visinf2f(vfloat d, vfloat m) { return (vfloat)vandm(vmaskf_isinf(d), vorm(vsignbitf(d), (vmask)m)); } -static INLINE vfloat visinff(vfloat d) { return visinf2f(d, vcast_vf_f(1.0f)); } - -static INLINE vint2 vilogbp1f(vfloat d) { - vmask m = vmaskf_lt(d, vcast_vf_f(5.421010862427522E-20f)); - d = vself(m, vmulf(vcast_vf_f(1.8446744073709552E19f), d), d); - vint2 q = vandi2(vsrli2(vcast_vi2_vm(vreinterpret_vm_vf(d)), 23), vcast_vi2_i(0xff)); - q = vsubi2(q, vseli2(m, vcast_vi2_i(64 + 0x7e), vcast_vi2_i(0x7e))); - return q; -} - -static INLINE vfloat vldexpf(vfloat x, vint2 q) { - vfloat u; - vint2 m = vsrai2(q, 31); - m = vslli2(vsubi2(vsrai2(vaddi2(m, q), 6), m), 4); - q = vsubi2(q, vslli2(m, 2)); - u = vreinterpret_vf_vm(vcast_vm_vi2(vslli2(vaddi2(m, vcast_vi2_i(0x7f)), 23))); - x = vmulf(vmulf(vmulf(vmulf(x, u), u), u), u); - u = vreinterpret_vf_vm(vcast_vm_vi2(vslli2(vaddi2(q, vcast_vi2_i(0x7f)), 23))); - return vmulf(x, u); -} - -static INLINE vfloat xsinf(vfloat d) { - vint2 q; - vfloat u, s; - - q = vrint_vi2_vf(vmulf(d, vcast_vf_f((float)rtengine::RT_1_PI))); - - u = vcast_vf_vi2(q); - d = vmlaf(u, vcast_vf_f(-PI4_Af*4), d); - d = vmlaf(u, vcast_vf_f(-PI4_Bf*4), d); - d = vmlaf(u, vcast_vf_f(-PI4_Cf*4), d); - d = vmlaf(u, vcast_vf_f(-PI4_Df*4), d); - - s = vmulf(d, d); - - d = vself(vmaski2_eq(vandi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vnegf(d), d); - - u = vcast_vf_f(2.6083159809786593541503e-06f); - u = vmlaf(u, s, vcast_vf_f(-0.0001981069071916863322258f)); - u = vmlaf(u, s, vcast_vf_f(0.00833307858556509017944336f)); - u = vmlaf(u, s, vcast_vf_f(-0.166666597127914428710938f)); - - u = vmlaf(s, vmulf(u, d), d); - - return u; -} - -static INLINE vfloat xcosf(vfloat d) { - vint2 q; - vfloat u, s; - - q = vrint_vi2_vf(vsubf(vmulf(d, vcast_vf_f((float)rtengine::RT_1_PI)), vcast_vf_f(0.5f))); - q = vaddi2(vaddi2(q, q), vcast_vi2_i(1)); - - u = vcast_vf_vi2(q); - d = vmlaf(u, vcast_vf_f(-PI4_Af*2), d); - d = vmlaf(u, vcast_vf_f(-PI4_Bf*2), d); - d = vmlaf(u, vcast_vf_f(-PI4_Cf*2), d); - d = vmlaf(u, vcast_vf_f(-PI4_Df*2), d); - - s = vmulf(d, d); - - d = vself(vmaski2_eq(vandi2(q, vcast_vi2_i(2)), vcast_vi2_i(2)), d, vnegf(d)); - - u = vcast_vf_f(2.6083159809786593541503e-06f); - u = vmlaf(u, s, vcast_vf_f(-0.0001981069071916863322258f)); - u = vmlaf(u, s, vcast_vf_f(0.00833307858556509017944336f)); - u = vmlaf(u, s, vcast_vf_f(-0.166666597127914428710938f)); - - u = vmlaf(s, vmulf(u, d), d); - - return u; -} - -static INLINE vfloat2 xsincosf(vfloat d) { - vint2 q; - vmask m; - vfloat u, s, t, rx, ry; - vfloat2 r; - - q = vrint_vi2_vf(vmulf(d, vcast_vf_f((float)rtengine::RT_2_PI))); - - s = d; - - u = vcast_vf_vi2(q); - s = vmlaf(u, vcast_vf_f(-PI4_Af*2), s); - s = vmlaf(u, vcast_vf_f(-PI4_Bf*2), s); - s = vmlaf(u, vcast_vf_f(-PI4_Cf*2), s); - s = vmlaf(u, vcast_vf_f(-PI4_Df*2), s); - - t = s; - - s = vmulf(s, s); - - u = vcast_vf_f(-0.000195169282960705459117889f); - u = vmlaf(u, s, vcast_vf_f(0.00833215750753879547119141f)); - u = vmlaf(u, s, vcast_vf_f(-0.166666537523269653320312f)); - u = vmulf(vmulf(u, s), t); - - rx = vaddf(t, u); - - u = vcast_vf_f(-2.71811842367242206819355e-07f); - u = vmlaf(u, s, vcast_vf_f(2.47990446951007470488548e-05f)); - u = vmlaf(u, s, vcast_vf_f(-0.00138888787478208541870117f)); - u = vmlaf(u, s, vcast_vf_f(0.0416666641831398010253906f)); - u = vmlaf(u, s, vcast_vf_f(-0.5)); - - ry = vaddf(vcast_vf_f(1), vmulf(s, u)); - - m = vmaski2_eq(vandi2(q, vcast_vi2_i(1)), vcast_vi2_i(0)); - r.x = vself(m, rx, ry); - r.y = vself(m, ry, rx); - - m = vmaski2_eq(vandi2(q, vcast_vi2_i(2)), vcast_vi2_i(2)); - r.x = vreinterpret_vf_vm(vxorm(vandm(m, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(r.x))); - - m = vmaski2_eq(vandi2(vaddi2(q, vcast_vi2_i(1)), vcast_vi2_i(2)), vcast_vi2_i(2)); - r.y = vreinterpret_vf_vm(vxorm(vandm(m, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(r.y))); - - m = vmaskf_isinf(d); - r.x = vself(m, vcast_vf_f(rtengine::RT_NAN), r.x); - r.y = vself(m, vcast_vf_f(rtengine::RT_NAN), r.y); - - return r; -} - -static INLINE vfloat xtanf(vfloat d) { - vint2 q; - vmask m; - vfloat u, s, x; - - q = vrint_vi2_vf(vmulf(d, vcast_vf_f((float)(2 * rtengine::RT_1_PI)))); - - x = d; - - u = vcast_vf_vi2(q); - x = vmlaf(u, vcast_vf_f(-PI4_Af*2), x); - x = vmlaf(u, vcast_vf_f(-PI4_Bf*2), x); - x = vmlaf(u, vcast_vf_f(-PI4_Cf*2), x); - x = vmlaf(u, vcast_vf_f(-PI4_Df*2), x); - - s = vmulf(x, x); - - m = vmaski2_eq(vandi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)); - x = vself(m, vnegf(x), x); - - u = vcast_vf_f(0.00927245803177356719970703f); - u = vmlaf(u, s, vcast_vf_f(0.00331984995864331722259521f)); - u = vmlaf(u, s, vcast_vf_f(0.0242998078465461730957031f)); - u = vmlaf(u, s, vcast_vf_f(0.0534495301544666290283203f)); - u = vmlaf(u, s, vcast_vf_f(0.133383005857467651367188f)); - u = vmlaf(u, s, vcast_vf_f(0.333331853151321411132812f)); - - u = vmlaf(s, vmulf(u, x), x); - - u = vself(m, vrecf(u), u); - - u = vself(vmaskf_isinf(d), vcast_vf_f(NANf), u); - - return u; -} - -static INLINE vfloat xatanf(vfloat s) { - vfloat t, u; - vint2 q; - - q = vseli2_lt(s, vcast_vf_f(0.0f), vcast_vi2_i(2), vcast_vi2_i(0)); - s = vabsf(s); - - q = vseli2_lt(vcast_vf_f(1.0f), s, vaddi2(q, vcast_vi2_i(1)), q); - s = vself(vmaskf_lt(vcast_vf_f(1.0f), s), vdivf(vcast_vf_f(1.0f), s), s); - - t = vmulf(s, s); - - u = vcast_vf_f(0.00282363896258175373077393f); - u = vmlaf(u, t, vcast_vf_f(-0.0159569028764963150024414f)); - u = vmlaf(u, t, vcast_vf_f(0.0425049886107444763183594f)); - u = vmlaf(u, t, vcast_vf_f(-0.0748900920152664184570312f)); - u = vmlaf(u, t, vcast_vf_f(0.106347933411598205566406f)); - u = vmlaf(u, t, vcast_vf_f(-0.142027363181114196777344f)); - u = vmlaf(u, t, vcast_vf_f(0.199926957488059997558594f)); - u = vmlaf(u, t, vcast_vf_f(-0.333331018686294555664062f)); - - t = vaddf(s, vmulf(s, vmulf(t, u))); - - t = vself(vmaski2_eq(vandi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vsubf(vcast_vf_f((float)(rtengine::RT_PI/2)), t), t); - t = vself(vmaski2_eq(vandi2(q, vcast_vi2_i(2)), vcast_vi2_i(2)), vnegf(t), t); - - return t; -} - -static INLINE vfloat atan2kf(vfloat y, vfloat x) { - vfloat s, t, u; - vint2 q; - vmask p; - - q = vseli2_lt(x, vcast_vf_f(0.0f), vcast_vi2_i(-2), vcast_vi2_i(0)); - x = vabsf(x); - - q = vseli2_lt(x, y, vaddi2(q, vcast_vi2_i(1)), q); - p = vmaskf_lt(x, y); - s = vself(p, vnegf(x), y); - t = vmaxf(x, y); - - s = vdivf(s, t); - t = vmulf(s, s); - - u = vcast_vf_f(0.00282363896258175373077393f); - u = vmlaf(u, t, vcast_vf_f(-0.0159569028764963150024414f)); - u = vmlaf(u, t, vcast_vf_f(0.0425049886107444763183594f)); - u = vmlaf(u, t, vcast_vf_f(-0.0748900920152664184570312f)); - u = vmlaf(u, t, vcast_vf_f(0.106347933411598205566406f)); - u = vmlaf(u, t, vcast_vf_f(-0.142027363181114196777344f)); - u = vmlaf(u, t, vcast_vf_f(0.199926957488059997558594f)); - u = vmlaf(u, t, vcast_vf_f(-0.333331018686294555664062f)); - - t = vaddf(s, vmulf(s, vmulf(t, u))); - t = vaddf(t, vmulf(vcast_vf_vi2(q), vcast_vf_f((float)(rtengine::RT_PI/2)))); - - return t; -} - -static INLINE vfloat xatan2f(vfloat y, vfloat x) { - vfloat r = atan2kf(vabsf(y), x); - - r = vmulsignf(r, x); - r = vself(vorm(vmaskf_isinf(x), vmaskf_eq(x, vcast_vf_f(0.0f))), vsubf(vcast_vf_f((float)(rtengine::RT_PI/2)), visinf2f(x, vmulsignf(vcast_vf_f((float)(rtengine::RT_PI/2)), x))), r); - r = vself(vmaskf_isinf(y), vsubf(vcast_vf_f((float)(rtengine::RT_PI/2)), visinf2f(x, vmulsignf(vcast_vf_f((float)(rtengine::RT_PI/4)), x))), r); - r = vself(vmaskf_eq(y, vcast_vf_f(0.0f)), vselfzero(vmaskf_eq(vsignf(x), vcast_vf_f(-1.0f)), vcast_vf_f((float)rtengine::RT_PI)), r); - - return vself(vmaskf_isnan(x, y), vcast_vf_f(NANf), vmulsignf(r, y)); -} - -static INLINE vfloat xasinf(vfloat d) { - vfloat x, y; - x = vaddf(vcast_vf_f(1.0f), d); - y = vsubf(vcast_vf_f(1.0f), d); - x = vmulf(x, y); - x = vsqrtf(x); - x = vself(vmaskf_isnan(x), vcast_vf_f(NANf), atan2kf(vabsf(d), x)); - return vmulsignf(x, d); -} - -static INLINE vfloat xacosf(vfloat d) { - vfloat x, y; - x = vaddf(vcast_vf_f(1.0f), d); - y = vsubf(vcast_vf_f(1.0f), d); - x = vmulf(x, y); - x = vsqrtf(x); - x = vmulsignf(atan2kf(x, vabsf(d)), d); - y = (vfloat)vandm(vmaskf_lt(d, vcast_vf_f(0.0f)), (vmask)vcast_vf_f((float)rtengine::RT_PI)); - x = vaddf(x, y); - return x; -} - -static INLINE vfloat xlogf(vfloat d) { - vfloat x, x2, t, m; - vint2 e; - - e = vilogbp1f(vmulf(d, vcast_vf_f(0.7071f))); - m = vldexpf(d, vsubi2(vcast_vi2_i(0), e)); - - x = vdivf(vaddf(vcast_vf_f(-1.0f), m), vaddf(vcast_vf_f(1.0f), m)); - x2 = vmulf(x, x); - - t = vcast_vf_f(0.2371599674224853515625f); - t = vmlaf(t, x2, vcast_vf_f(0.285279005765914916992188f)); - t = vmlaf(t, x2, vcast_vf_f(0.400005519390106201171875f)); - t = vmlaf(t, x2, vcast_vf_f(0.666666567325592041015625f)); - t = vmlaf(t, x2, vcast_vf_f(2.0f)); - - x = vaddf(vmulf(x, t), vmulf(vcast_vf_f(0.693147180559945286226764f), vcast_vf_vi2(e))); - - x = vself(vmaskf_ispinf(d), vcast_vf_f(INFINITYf), x); - x = vself(vmaskf_gt(vcast_vf_f(0), d), vcast_vf_f(NANf), x); - x = vself(vmaskf_eq(d, vcast_vf_f(0)), vcast_vf_f(-INFINITYf), x); - - return x; -} - -static INLINE vfloat xlogf1(vfloat d) { // does xlogf(vmaxf(d, 1.f)) but faster - vfloat x, x2, t, m; - vint2 e; - - e = vilogbp1f(vmulf(d, vcast_vf_f(0.7071f))); - m = vldexpf(d, vsubi2(vcast_vi2_i(0), e)); - - x = vdivf(vaddf(vcast_vf_f(-1.0f), m), vaddf(vcast_vf_f(1.0f), m)); - x2 = vmulf(x, x); - - t = vcast_vf_f(0.2371599674224853515625f); - t = vmlaf(t, x2, vcast_vf_f(0.285279005765914916992188f)); - t = vmlaf(t, x2, vcast_vf_f(0.400005519390106201171875f)); - t = vmlaf(t, x2, vcast_vf_f(0.666666567325592041015625f)); - t = vmlaf(t, x2, vcast_vf_f(2.0f)); - - x = vaddf(vmulf(x, t), vmulf(vcast_vf_f(0.693147180559945286226764f), vcast_vf_vi2(e))); - - x = vself(vmaskf_ispinf(d), vcast_vf_f(INFINITYf), x); - x = vselfnotzero(vmaskf_le(d, vcast_vf_f(1.f)), x); - - return x; -} - -static INLINE vfloat xlogf0(vfloat d) { - vfloat x, x2, t, m; - vint2 e; - - e = vilogbp1f(vmulf(d, vcast_vf_f(0.7071f))); - m = vldexpf(d, vsubi2(vcast_vi2_i(0), e)); - - x = vdivf(vaddf(vcast_vf_f(-1.0f), m), vaddf(vcast_vf_f(1.0f), m)); - x2 = vmulf(x, x); - - t = vcast_vf_f(0.2371599674224853515625f); - t = vmlaf(t, x2, vcast_vf_f(0.285279005765914916992188f)); - t = vmlaf(t, x2, vcast_vf_f(0.400005519390106201171875f)); - t = vmlaf(t, x2, vcast_vf_f(0.666666567325592041015625f)); - t = vmlaf(t, x2, vcast_vf_f(2.0f)); - - x = vaddf(vmulf(x, t), vmulf(vcast_vf_f(0.693147180559945286226764f), vcast_vf_vi2(e))); - - x = vself(vmaskf_ispinf(d), vcast_vf_f(0), x); - x = vself(vmaskf_gt(vcast_vf_f(0), d), vcast_vf_f(0), x); - x = vself(vmaskf_eq(d, vcast_vf_f(0)), vcast_vf_f(0), x); - - return x; -} - -static INLINE vfloat xlogfNoCheck(vfloat d) { // this version does not check input values. Use it only when you know the input values are > 0 e.g. when filling a lookup table - vfloat x, x2, t, m; - vint2 e; - - e = vilogbp1f(vmulf(d, vcast_vf_f(0.7071f))); - m = vldexpf(d, vsubi2(vcast_vi2_i(0), e)); - - x = vdivf(vaddf(vcast_vf_f(-1.0f), m), vaddf(vcast_vf_f(1.0f), m)); - x2 = vmulf(x, x); - - t = vcast_vf_f(0.2371599674224853515625f); - t = vmlaf(t, x2, vcast_vf_f(0.285279005765914916992188f)); - t = vmlaf(t, x2, vcast_vf_f(0.400005519390106201171875f)); - t = vmlaf(t, x2, vcast_vf_f(0.666666567325592041015625f)); - t = vmlaf(t, x2, vcast_vf_f(2.0f)); - - return vaddf(vmulf(x, t), vmulf(vcast_vf_f(0.693147180559945286226764f), vcast_vf_vi2(e))); - -} - -static INLINE vfloat xexpf(vfloat d) { - vint2 q = vrint_vi2_vf(vmulf(d, vcast_vf_f(R_LN2f))); - vfloat s, u; - - s = vmlaf(vcast_vf_vi2(q), vcast_vf_f(-L2Uf),d); - s = vmlaf(vcast_vf_vi2(q), vcast_vf_f(-L2Lf),s); - - u = vcast_vf_f(0.00136324646882712841033936f); - u = vmlaf(u, s, vcast_vf_f(0.00836596917361021041870117f)); - u = vmlaf(u, s, vcast_vf_f(0.0416710823774337768554688f)); - u = vmlaf(u, s, vcast_vf_f(0.166665524244308471679688f)); - u = vmlaf(u, s, vcast_vf_f(0.499999850988388061523438f)); - - u = vaddf(vcast_vf_f(1.0f), vmlaf(vmulf(s, s), u, s)); - - u = vldexpf(u, q); - - // -104.0 - return vselfnotzero(vmaskf_gt(vcast_vf_f(-104.f), d), u); -} - -static INLINE vfloat xexpfNoCheck(vfloat d) { // this version does not check input values. Use it only when you know the input values are > -104.f e.g. when filling a lookup table - vint2 q = vrint_vi2_vf(vmulf(d, vcast_vf_f(R_LN2f))); - vfloat s, u; - - s = vmlaf(vcast_vf_vi2(q), vcast_vf_f(-L2Uf),d); - s = vmlaf(vcast_vf_vi2(q), vcast_vf_f(-L2Lf),s); - - u = vcast_vf_f(0.00136324646882712841033936f); - u = vmlaf(u, s, vcast_vf_f(0.00836596917361021041870117f)); - u = vmlaf(u, s, vcast_vf_f(0.0416710823774337768554688f)); - u = vmlaf(u, s, vcast_vf_f(0.166665524244308471679688f)); - u = vmlaf(u, s, vcast_vf_f(0.499999850988388061523438f)); - - u = vaddf(vcast_vf_f(1.0f), vmlaf(vmulf(s, s), u, s)); - - return vldexpf(u, q); -} - -static INLINE vfloat xcbrtf(vfloat d) { - vfloat x, y, q = vcast_vf_f(1.0), t; - vint2 e, qu, re; - - e = vilogbp1f(vabsf(d)); - d = vldexpf(d, vsubi2(vcast_vi2_i(0), e)); - - t = vaddf(vcast_vf_vi2(e), vcast_vf_f(6144)); - qu = vtruncate_vi2_vf(vdivf(t, vcast_vf_f(3))); - re = vtruncate_vi2_vf(vsubf(t, vmulf(vcast_vf_vi2(qu), vcast_vf_f(3)))); - - q = vself(vmaski2_eq(re, vcast_vi2_i(1)), vcast_vf_f(1.2599210498948731647672106f), q); - q = vself(vmaski2_eq(re, vcast_vi2_i(2)), vcast_vf_f(1.5874010519681994747517056f), q); - q = vldexpf(q, vsubi2(qu, vcast_vi2_i(2048))); - - q = vmulsignf(q, d); - d = vabsf(d); - - x = vcast_vf_f(-0.601564466953277587890625f); - x = vmlaf(x, d, vcast_vf_f(2.8208892345428466796875f)); - x = vmlaf(x, d, vcast_vf_f(-5.532182216644287109375f)); - x = vmlaf(x, d, vcast_vf_f(5.898262500762939453125f)); - x = vmlaf(x, d, vcast_vf_f(-3.8095417022705078125f)); - x = vmlaf(x, d, vcast_vf_f(2.2241256237030029296875f)); - - y = vmulf(vmulf(d, x), x); - y = vmulf(vsubf(y, vmulf(vmulf(vcast_vf_f(2.0f / 3.0f), y), vmlaf(y, x, vcast_vf_f(-1.0f)))), q); - - return y; -} - -static INLINE vfloat vclampf(vfloat value, vfloat low, vfloat high) { - // clamps value in [low;high], returns low if value is NaN - return vmaxf(vminf(high, value), low); -} - -static INLINE vfloat SQRV(vfloat a){ - return a * a; -} - -static inline void vswap( vmask condition, vfloat &a, vfloat &b) { - // conditional swap the elements of two vfloats - vfloat temp = vself(condition, a, b); // the values which fit to condition - a = vself(condition, b, a); // the values which fit to inverted condition - b = temp; -} - -static inline float vhadd( vfloat a ) { - // returns a[0] + a[1] + a[2] + a[3] - a += _mm_movehl_ps(a, a); - return _mm_cvtss_f32(_mm_add_ss(a, _mm_shuffle_ps(a, a, 1))); -} - -static inline float vhmin(vfloat a) { - // returns min(a[0], a[1], a[2], a[3]) - a = vminf(a, _mm_movehl_ps(a, a)); - return _mm_cvtss_f32(vminf(a, _mm_shuffle_ps(a, a, 1))); -} - -static inline float vhmax(vfloat a) { - // returns max(a[0], a[1], a[2], a[3]) - a = vmaxf(a, _mm_movehl_ps(a, a)); - return _mm_cvtss_f32(vmaxf(a, _mm_shuffle_ps(a, a, 1))); -} - -static INLINE vfloat vmul2f(vfloat a){ - // fastest way to multiply by 2 - return a + a; -} - -static INLINE vfloat vintpf(vfloat a, vfloat b, vfloat c) { - // calculate a * b + (1 - a) * c (interpolate two values) - // following is valid: - // vintpf(a, b+x, c+x) = vintpf(a, b, c) + x - // vintpf(a, b*x, c*x) = vintpf(a, b, c) * x - return a * (b-c) + c; -} - -static INLINE vfloat vdup(vfloat a){ - // returns { a[0],a[0],a[1],a[1] } - return _mm_unpacklo_ps( a, a ); -} - -static INLINE vfloat vaddc2vfu(float &a) -{ - // loads a[0]..a[7] and returns { a[0]+a[1], a[2]+a[3], a[4]+a[5], a[6]+a[7] } - vfloat a1 = _mm_loadu_ps( &a ); - vfloat a2 = _mm_loadu_ps( (&a) + 4 ); - return _mm_shuffle_ps(a1,a2,_MM_SHUFFLE( 2,0,2,0 )) + _mm_shuffle_ps(a1,a2,_MM_SHUFFLE( 3,1,3,1 )); -} - -static INLINE vfloat vadivapb (vfloat a, vfloat b) { - return a / (a+b); -} - -static INLINE void vconvertrgbrgbrgbrgb2rrrrggggbbbb (const float * src, vfloat &rv, vfloat &gv, vfloat &bv) { // cool function name, isn't it ? :P - // converts a sequence of 4 float RGB triplets to 3 red, green and blue quadruples - rv = _mm_setr_ps(src[0],src[3],src[6],src[9]); - gv = _mm_setr_ps(src[1],src[4],src[7],src[10]); - bv = _mm_setr_ps(src[2],src[5],src[8],src[11]); -} - -#if defined( __SSE4_1__ ) && defined( __x86_64__ ) -static INLINE vfloat vceilf(vfloat x) { - return _mm_round_ps(x, _MM_FROUND_TO_POS_INF |_MM_FROUND_NO_EXC); -} - -#else - -static INLINE vfloat vceilf(vfloat x) { - __m128i zerov = _mm_setzero_si128(); - zerov = _mm_cmpeq_epi32(zerov, zerov); - const vfloat onev = (vfloat)_mm_slli_epi32(_mm_srli_epi32(zerov, 25), 23); //create vector 1.0f - const vfloat xi = _mm_cvtepi32_ps(_mm_cvttps_epi32(x)); - return xi + _mm_and_ps(_mm_cmplt_ps(xi, x), onev); -} -#endif - -#endif // __SSE2__ -#endif // SLEEFSSEAVX diff --git a/rtengine/sleefsseavx.h b/rtengine/sleefsseavx.h index 8fe20c54b..c10f4a0c2 100644 --- a/rtengine/sleefsseavx.h +++ b/rtengine/sleefsseavx.h @@ -1,124 +1,897 @@ -#include -#include +//////////////////////////////////////////////////////////////// +// +// this code was taken from http://shibatch.sourceforge.net/ +// Many thanks to the author of original version: Naoki Shibata +// +// This version contains modifications made by Ingo Weyrich +// +//////////////////////////////////////////////////////////////// +#pragma once +#include "rt_math.h" #ifdef __SSE2__ -#define VECTLENDP 2 -#define VECTLENSP 4 - -typedef __m128d vdouble; -typedef __m128i vint; - -typedef __m128 vfloat; -typedef __m128i vint2; -typedef __m128i vmask; - -static vdouble vloadu(double *p) -{ - return _mm_loadu_pd(p); -} -static void vstoreu(double *p, vdouble v) -{ - _mm_storeu_pd(p, v); -} - -static vfloat vloaduf(float *p) -{ - return _mm_loadu_ps(p); -} -static void vstoreuf(float *p, vfloat v) -{ - _mm_storeu_ps(p, v); -} - -static vint2 vloadui2(int32_t *p) -{ - return (vint2)_mm_loadu_si128((__m128i *)p); -} -static void vstoreui2(int32_t *p, vint2 v) -{ - _mm_storeu_si128((__m128i *)p, (__m128i)v); -} -#endif +#include "helpersse2.h" #ifdef ENABLE_AVX -#define VECTLENDP 4 -#define VECTLENSP 8 +#include "helperavx.h" +#endif -typedef __m256d vdouble; -typedef __m128i vint; +#ifdef __GNUC__ +#define INLINE __inline +#else +#define INLINE inline +#endif +#define PI4_A .7853981554508209228515625 +#define PI4_B .794662735614792836713604629039764404296875e-8 +#define PI4_C .306161699786838294306516483068750264552437361480769e-16 +#define M_4_PI 1.273239544735162542821171882678754627704620361328125 -typedef __m256 vfloat; -typedef struct { - vint x, y; -} vint2; +#define L2U .69314718055966295651160180568695068359375 +#define L2L .28235290563031577122588448175013436025525412068e-12 +#define R_LN2 1.442695040888963407359924681001892137426645954152985934135449406931 -static vdouble vloadu(double *p) -{ - return _mm256_loadu_pd(p); -} -static void vstoreu(double *p, vdouble v) -{ - return _mm256_storeu_pd(p, v); +#define PI4_Af 0.78515625f +#define PI4_Bf 0.00024127960205078125f +#define PI4_Cf 6.3329935073852539062e-07f +#define PI4_Df 4.9604681473525147339e-10f + +#define L2Uf 0.693145751953125f +#define L2Lf 1.428606765330187045e-06f +#define R_LN2f 1.442695040888963407359924681001892137426645954152985934135449406931f + +#define INFINITYf ((float)rtengine::RT_INFINITY) +#define NANf ((float)rtengine::RT_NAN) + +static INLINE vdouble vadd3(vdouble v0, vdouble v1, vdouble v2) { + return vadd(vadd(v0, v1), v2); } -static vfloat vloaduf(float *p) -{ - return _mm256_loadu_ps(p); -} -static void vstoreuf(float *p, vfloat v) -{ - return _mm256_storeu_ps(p, v); +static INLINE vdouble vadd4(vdouble v0, vdouble v1, vdouble v2, vdouble v3) { + return vadd3(vadd(v0, v1), v2, v3); } -static vint2 vloadui2(int32_t *p) -{ - vint2 r; - r.x = _mm_loadu_si128((__m128i *) p ); - r.y = _mm_loadu_si128((__m128i *)(p + 4)); +static INLINE vdouble vadd5(vdouble v0, vdouble v1, vdouble v2, vdouble v3, vdouble v4) { + return vadd4(vadd(v0, v1), v2, v3, v4); +} + +static INLINE vdouble vadd6(vdouble v0, vdouble v1, vdouble v2, vdouble v3, vdouble v4, vdouble v5) { + return vadd5(vadd(v0, v1), v2, v3, v4, v5); +} + +static INLINE vdouble vadd7(vdouble v0, vdouble v1, vdouble v2, vdouble v3, vdouble v4, vdouble v5, vdouble v6) { + return vadd6(vadd(v0, v1), v2, v3, v4, v5, v6); +} + +static INLINE vdouble vsub3(vdouble v0, vdouble v1, vdouble v2) { + return vsub(vsub(v0, v1), v2); +} + +static INLINE vdouble vsub4(vdouble v0, vdouble v1, vdouble v2, vdouble v3) { + return vsub3(vsub(v0, v1), v2, v3); +} + +static INLINE vdouble vsub5(vdouble v0, vdouble v1, vdouble v2, vdouble v3, vdouble v4) { + return vsub4(vsub(v0, v1), v2, v3, v4); +} + +// + +static INLINE vdouble2 normalize_d(vdouble2 t) { + vdouble2 s; + + s.x = vadd(t.x, t.y); + s.y = vadd(vsub(t.x, s.x), t.y); + + return s; +} + +static INLINE vdouble2 scale_d(vdouble2 d, vdouble s) { + vdouble2 r = {vmul(d.x, s), vmul(d.y, s)}; return r; } -static void vstoreui2(int32_t *p, vint2 v) -{ - _mm_storeu_si128((__m128i *) p , v.x); - _mm_storeu_si128((__m128i *)(p + 4), v.y); +static INLINE vdouble2 add_ss(vdouble x, vdouble y) { + vdouble2 r; + + r.x = vadd(x, y); + r.y = vadd(vsub(x, r.x), y); + + return r; } -#endif -typedef struct { +static INLINE vdouble2 add2_ss(vdouble x, vdouble y) { + vdouble2 r; + + r.x = vadd(x, y); + vdouble v = vsub(r.x, x); + r.y = vadd(vsub(x, vsub(r.x, v)), vsub(y, v)); + + return r; +} + +static INLINE vdouble2 add_ds(vdouble2 x, vdouble y) { + vdouble2 r; + + r.x = vadd(x.x, y); + r.y = vadd3(vsub(x.x, r.x), y, x.y); + + return r; +} + +static INLINE vdouble2 add2_ds(vdouble2 x, vdouble y) { + vdouble2 r; + + r.x = vadd(x.x, y); + vdouble v = vsub(r.x, x.x); + r.y = vadd(vsub(x.x, vsub(r.x, v)), vsub(y, v)); + r.y = vadd(r.y, x.y); + + return r; +} + +static INLINE vdouble2 add_sd(vdouble x, vdouble2 y) { + vdouble2 r; + + r.x = vadd(x, y.x); + r.y = vadd3(vsub(x, r.x), y.x, y.y); + + return r; +} + +static INLINE vdouble2 add_dd(vdouble2 x, vdouble2 y) { + // |x| >= |y| + + vdouble2 r; + + r.x = vadd(x.x, y.x); + r.y = vadd4(vsub(x.x, r.x), y.x, x.y, y.y); + + return r; +} + +static INLINE vdouble2 add2_dd(vdouble2 x, vdouble2 y) { + vdouble2 r; + + r.x = vadd(x.x, y.x); + vdouble v = vsub(r.x, x.x); + r.y = vadd(vsub(x.x, vsub(r.x, v)), vsub(y.x, v)); + r.y = vadd(r.y, vadd(x.y, y.y)); + + return r; +} + +static INLINE vdouble2 div_dd(vdouble2 n, vdouble2 d) { + vdouble t = vrec(d.x); + vdouble dh = vupper(d.x), dl = vsub(d.x, dh); + vdouble th = vupper(t ), tl = vsub(t , th); + vdouble nhh = vupper(n.x), nhl = vsub(n.x, nhh); + + vdouble2 q; + + q.x = vmul(n.x, t); + + vdouble u = vadd5(vsub(vmul(nhh, th), q.x), vmul(nhh, tl), vmul(nhl, th), vmul(nhl, tl), + vmul(q.x, vsub5(vcast_vd_d(1), vmul(dh, th), vmul(dh, tl), vmul(dl, th), vmul(dl, tl)))); + + q.y = vadd(vmul(t, vsub(n.y, vmul(q.x, d.y))), u); + + return q; +} + +static INLINE vdouble2 mul_ss(vdouble x, vdouble y) { + vdouble xh = vupper(x), xl = vsub(x, xh); + vdouble yh = vupper(y), yl = vsub(y, yh); + vdouble2 r; + + r.x = vmul(x, y); + r.y = vadd5(vmul(xh, yh), vneg(r.x), vmul(xl, yh), vmul(xh, yl), vmul(xl, yl)); + + return r; +} + +static INLINE vdouble2 mul_ds(vdouble2 x, vdouble y) { + vdouble xh = vupper(x.x), xl = vsub(x.x, xh); + vdouble yh = vupper(y ), yl = vsub(y , yh); + vdouble2 r; + + r.x = vmul(x.x, y); + r.y = vadd6(vmul(xh, yh), vneg(r.x), vmul(xl, yh), vmul(xh, yl), vmul(xl, yl), vmul(x.y, y)); + + return r; +} + +static INLINE vdouble2 mul_dd(vdouble2 x, vdouble2 y) { + vdouble xh = vupper(x.x), xl = vsub(x.x, xh); + vdouble yh = vupper(y.x), yl = vsub(y.x, yh); + vdouble2 r; + + r.x = vmul(x.x, y.x); + r.y = vadd7(vmul(xh, yh), vneg(r.x), vmul(xl, yh), vmul(xh, yl), vmul(xl, yl), vmul(x.x, y.y), vmul(x.y, y.x)); + + return r; +} + +static INLINE vdouble2 squ_d(vdouble2 x) { + vdouble xh = vupper(x.x), xl = vsub(x.x, xh); + vdouble2 r; + + r.x = vmul(x.x, x.x); + r.y = vadd5(vmul(xh, xh), vneg(r.x), vmul(vadd(xh, xh), xl), vmul(xl, xl), vmul(x.x, vadd(x.y, x.y))); + + return r; +} + +static INLINE vdouble2 rec_s(vdouble d) { + vdouble t = vrec(d); + vdouble dh = vupper(d), dl = vsub(d, dh); + vdouble th = vupper(t), tl = vsub(t, th); + vdouble2 q; + + q.x = t; + q.y = vmul(t, vsub5(vcast_vd_d(1), vmul(dh, th), vmul(dh, tl), vmul(dl, th), vmul(dl, tl))); + + return q; +} + +static INLINE vdouble2 sqrt_d(vdouble2 d) { + vdouble t = vsqrt(vadd(d.x, d.y)); + return scale_d(mul_dd(add2_dd(d, mul_ss(t, t)), rec_s(t)), vcast_vd_d(0.5)); +} + +// + +static INLINE vdouble xldexp(vdouble x, vint q) { return vldexp(x, q); } + +static INLINE vint xilogb(vdouble d) { + vdouble e = vcast_vd_vi(vsubi(vilogbp1(vabs(d)), vcast_vi_i(1))); + e = vsel(vmask_eq(d, vcast_vd_d(0)), vcast_vd_d(-2147483648.0), e); + e = vsel(vmask_eq(vabs(d), vcast_vd_d(rtengine::RT_INFINITY)), vcast_vd_d(2147483647), e); + return vrint_vi_vd(e); +} + +static INLINE vdouble xsin(vdouble d) { + vint q; + vdouble u, s; + + q = vrint_vi_vd(vmul(d, vcast_vd_d(rtengine::RT_1_PI))); + + u = vcast_vd_vi(q); + d = vadd(d, vmul(u, vcast_vd_d(-PI4_A*4))); + d = vadd(d, vmul(u, vcast_vd_d(-PI4_B*4))); + d = vadd(d, vmul(u, vcast_vd_d(-PI4_C*4))); + + s = vmul(d, d); + + d = vsel(vmaski_eq(vandi(q, vcast_vi_i(1)), vcast_vi_i(1)), vneg(d), d); + + u = vcast_vd_d(-7.97255955009037868891952e-18); + u = vmla(u, s, vcast_vd_d(2.81009972710863200091251e-15)); + u = vmla(u, s, vcast_vd_d(-7.64712219118158833288484e-13)); + u = vmla(u, s, vcast_vd_d(1.60590430605664501629054e-10)); + u = vmla(u, s, vcast_vd_d(-2.50521083763502045810755e-08)); + u = vmla(u, s, vcast_vd_d(2.75573192239198747630416e-06)); + u = vmla(u, s, vcast_vd_d(-0.000198412698412696162806809)); + u = vmla(u, s, vcast_vd_d(0.00833333333333332974823815)); + u = vmla(u, s, vcast_vd_d(-0.166666666666666657414808)); + + u = vmla(s, vmul(u, d), d); + + return u; +} + +static INLINE vdouble xcos(vdouble d) { + vint q; + vdouble u, s; + + q = vrint_vi_vd(vsub(vmul(d, vcast_vd_d(rtengine::RT_1_PI)), vcast_vd_d(0.5))); + q = vaddi(vaddi(q, q), vcast_vi_i(1)); + + u = vcast_vd_vi(q); + d = vadd(d, vmul(u, vcast_vd_d(-PI4_A*2))); + d = vadd(d, vmul(u, vcast_vd_d(-PI4_B*2))); + d = vadd(d, vmul(u, vcast_vd_d(-PI4_C*2))); + + s = vmul(d, d); + + d = vsel(vmaski_eq(vandi(q, vcast_vi_i(2)), vcast_vi_i(0)), vneg(d), d); + + u = vcast_vd_d(-7.97255955009037868891952e-18); + u = vmla(u, s, vcast_vd_d(2.81009972710863200091251e-15)); + u = vmla(u, s, vcast_vd_d(-7.64712219118158833288484e-13)); + u = vmla(u, s, vcast_vd_d(1.60590430605664501629054e-10)); + u = vmla(u, s, vcast_vd_d(-2.50521083763502045810755e-08)); + u = vmla(u, s, vcast_vd_d(2.75573192239198747630416e-06)); + u = vmla(u, s, vcast_vd_d(-0.000198412698412696162806809)); + u = vmla(u, s, vcast_vd_d(0.00833333333333332974823815)); + u = vmla(u, s, vcast_vd_d(-0.166666666666666657414808)); + + u = vmla(s, vmul(u, d), d); + + return u; +} + +static INLINE vdouble2 xsincos(vdouble d) { + vint q; + vmask m; + vdouble u, s, t, rx, ry; + vdouble2 r; + + q = vrint_vi_vd(vmul(d, vcast_vd_d(rtengine::RT_2_PI))); + + s = d; + + u = vcast_vd_vi(q); + s = vmla(u, vcast_vd_d(-PI4_A*2), s); + s = vmla(u, vcast_vd_d(-PI4_B*2), s); + s = vmla(u, vcast_vd_d(-PI4_C*2), s); + + t = s; + + s = vmul(s, s); + + u = vcast_vd_d(1.58938307283228937328511e-10); + u = vmla(u, s, vcast_vd_d(-2.50506943502539773349318e-08)); + u = vmla(u, s, vcast_vd_d(2.75573131776846360512547e-06)); + u = vmla(u, s, vcast_vd_d(-0.000198412698278911770864914)); + u = vmla(u, s, vcast_vd_d(0.0083333333333191845961746)); + u = vmla(u, s, vcast_vd_d(-0.166666666666666130709393)); + u = vmul(vmul(u, s), t); + + rx = vadd(t, u); + + u = vcast_vd_d(-1.13615350239097429531523e-11); + u = vmla(u, s, vcast_vd_d(2.08757471207040055479366e-09)); + u = vmla(u, s, vcast_vd_d(-2.75573144028847567498567e-07)); + u = vmla(u, s, vcast_vd_d(2.48015872890001867311915e-05)); + u = vmla(u, s, vcast_vd_d(-0.00138888888888714019282329)); + u = vmla(u, s, vcast_vd_d(0.0416666666666665519592062)); + u = vmla(u, s, vcast_vd_d(-0.5)); + + ry = vadd(vcast_vd_d(1), vmul(s, u)); + + m = vmaski_eq(vandi(q, vcast_vi_i(1)), vcast_vi_i(0)); + r.x = vsel(m, rx, ry); + r.y = vsel(m, ry, rx); + + m = vmaski_eq(vandi(q, vcast_vi_i(2)), vcast_vi_i(2)); + r.x = vreinterpret_vd_vm(vxorm(vandm(m, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(r.x))); + + m = vmaski_eq(vandi(vaddi(q, vcast_vi_i(1)), vcast_vi_i(2)), vcast_vi_i(2)); + r.y = vreinterpret_vd_vm(vxorm(vandm(m, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(r.y))); + + m = vmask_isinf(d); + r.x = vsel(m, vcast_vd_d(rtengine::RT_NAN), r.x); + r.y = vsel(m, vcast_vd_d(rtengine::RT_NAN), r.y); + + return r; +} + +static INLINE vdouble xtan(vdouble d) { + vint q; + vdouble u, s, x; + vmask m; + + q = vrint_vi_vd(vmul(d, vcast_vd_d(rtengine::RT_2_PI))); + + u = vcast_vd_vi(q); + x = vadd(d, vmul(u, vcast_vd_d(-PI4_A*2))); + x = vadd(x, vmul(u, vcast_vd_d(-PI4_B*2))); + x = vadd(x, vmul(u, vcast_vd_d(-PI4_C*2))); + + s = vmul(x, x); + + m = vmaski_eq(vandi(q, vcast_vi_i(1)), vcast_vi_i(1)); + x = vsel(m, vneg(x), x); + + u = vcast_vd_d(1.01419718511083373224408e-05); + u = vmla(u, s, vcast_vd_d(-2.59519791585924697698614e-05)); + u = vmla(u, s, vcast_vd_d(5.23388081915899855325186e-05)); + u = vmla(u, s, vcast_vd_d(-3.05033014433946488225616e-05)); + u = vmla(u, s, vcast_vd_d(7.14707504084242744267497e-05)); + u = vmla(u, s, vcast_vd_d(8.09674518280159187045078e-05)); + u = vmla(u, s, vcast_vd_d(0.000244884931879331847054404)); + u = vmla(u, s, vcast_vd_d(0.000588505168743587154904506)); + u = vmla(u, s, vcast_vd_d(0.00145612788922812427978848)); + u = vmla(u, s, vcast_vd_d(0.00359208743836906619142924)); + u = vmla(u, s, vcast_vd_d(0.00886323944362401618113356)); + u = vmla(u, s, vcast_vd_d(0.0218694882853846389592078)); + u = vmla(u, s, vcast_vd_d(0.0539682539781298417636002)); + u = vmla(u, s, vcast_vd_d(0.133333333333125941821962)); + u = vmla(u, s, vcast_vd_d(0.333333333333334980164153)); + + u = vmla(s, vmul(u, x), x); + + u = vsel(m, vrec(u), u); + + u = vsel(vmask_isinf(d), vcast_vd_d(rtengine::RT_NAN), u); + + return u; +} + +static INLINE vdouble atan2k(vdouble y, vdouble x) { + vdouble s, t, u; + vint q; + vmask p; + + q = vseli_lt(x, vcast_vd_d(0), vcast_vi_i(-2), vcast_vi_i(0)); + x = vabs(x); + + q = vseli_lt(x, y, vaddi(q, vcast_vi_i(1)), q); + p = vmask_lt(x, y); + s = vsel (p, vneg(x), y); + t = vmax (x, y); + + s = vdiv(s, t); + t = vmul(s, s); + + u = vcast_vd_d(-1.88796008463073496563746e-05); + u = vmla(u, t, vcast_vd_d(0.000209850076645816976906797)); + u = vmla(u, t, vcast_vd_d(-0.00110611831486672482563471)); + u = vmla(u, t, vcast_vd_d(0.00370026744188713119232403)); + u = vmla(u, t, vcast_vd_d(-0.00889896195887655491740809)); + u = vmla(u, t, vcast_vd_d(0.016599329773529201970117)); + u = vmla(u, t, vcast_vd_d(-0.0254517624932312641616861)); + u = vmla(u, t, vcast_vd_d(0.0337852580001353069993897)); + u = vmla(u, t, vcast_vd_d(-0.0407629191276836500001934)); + u = vmla(u, t, vcast_vd_d(0.0466667150077840625632675)); + u = vmla(u, t, vcast_vd_d(-0.0523674852303482457616113)); + u = vmla(u, t, vcast_vd_d(0.0587666392926673580854313)); + u = vmla(u, t, vcast_vd_d(-0.0666573579361080525984562)); + u = vmla(u, t, vcast_vd_d(0.0769219538311769618355029)); + u = vmla(u, t, vcast_vd_d(-0.090908995008245008229153)); + u = vmla(u, t, vcast_vd_d(0.111111105648261418443745)); + u = vmla(u, t, vcast_vd_d(-0.14285714266771329383765)); + u = vmla(u, t, vcast_vd_d(0.199999999996591265594148)); + u = vmla(u, t, vcast_vd_d(-0.333333333333311110369124)); + + t = vadd(s, vmul(s, vmul(t, u))); + t = vadd(t, vmul(vcast_vd_vi(q), vcast_vd_d(rtengine::RT_PI/2))); + + return t; +} + +static INLINE vdouble xatan2(vdouble y, vdouble x) { + vdouble r = atan2k(vabs(y), x); + + r = vmulsign(r, x); + r = vsel(vorm(vmask_isinf(x), vmask_eq(x, vcast_vd_d(0))), vsub(vcast_vd_d(rtengine::RT_PI/2), visinf2(x, vmulsign(vcast_vd_d(rtengine::RT_PI/2), x))), r); + r = vsel(vmask_isinf(y), vsub(vcast_vd_d(rtengine::RT_PI/2), visinf2(x, vmulsign(vcast_vd_d(rtengine::RT_PI/4), x))), r); + r = vsel(vmask_eq(y, vcast_vd_d(0)), vsel(vmask_eq(vsign(x), vcast_vd_d(-1.0)), vcast_vd_d(rtengine::RT_PI), vcast_vd_d(0)), r); + + return vsel(vorm(vmask_isnan(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_NAN), vmulsign(r, y)); +} + +static INLINE vdouble xasin(vdouble d) { vdouble x, y; -} vdouble2; + x = vadd(vcast_vd_d(1), d); + y = vsub(vcast_vd_d(1), d); + x = vmul(x, y); + x = vsqrt(x); + x = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), atan2k(vabs(d), x)); + return vmulsign(x, d); +} -vdouble xldexp(vdouble x, vint q); -vint xilogb(vdouble d); +static INLINE vdouble xacos(vdouble d) { + vdouble x, y; + x = vadd(vcast_vd_d(1), d); + y = vsub(vcast_vd_d(1), d); + x = vmul(x, y); + x = vsqrt(x); + x = vmulsign(atan2k(x, vabs(d)), d); + y = (vdouble)vandm(vmask_lt(d, vcast_vd_d(0)), (vmask)vcast_vd_d(rtengine::RT_PI)); + x = vadd(x, y); + return x; +} -vdouble xsin(vdouble d); -vdouble xcos(vdouble d); -vdouble2 xsincos(vdouble d); -vdouble xtan(vdouble d); -vdouble xasin(vdouble s); -vdouble xacos(vdouble s); -vdouble xatan(vdouble s); -vdouble xatan2(vdouble y, vdouble x); -vdouble xlog(vdouble d); -vdouble xexp(vdouble d); -vdouble xpow(vdouble x, vdouble y); +static INLINE vdouble xatan(vdouble s) { + vdouble t, u; + vint q; -vdouble xsinh(vdouble d); -vdouble xcosh(vdouble d); -vdouble xtanh(vdouble d); -vdouble xasinh(vdouble s); -vdouble xacosh(vdouble s); -vdouble xatanh(vdouble s); + q = vseli_lt(s, vcast_vd_d(0), vcast_vi_i(2), vcast_vi_i(0)); + s = vabs(s); -vdouble xcbrt(vdouble d); + q = vseli_lt(vcast_vd_d(1), s, vaddi(q, vcast_vi_i(1)), q); + s = vsel(vmask_lt(vcast_vd_d(1), s), vdiv(vcast_vd_d(1), s), s); -vdouble xexp2(vdouble a); -vdouble xexp10(vdouble a); -vdouble xexpm1(vdouble a); -vdouble xlog10(vdouble a); -vdouble xlog1p(vdouble a); + t = vmul(s, s); + + u = vcast_vd_d(-1.88796008463073496563746e-05); + u = vmla(u, t, vcast_vd_d(0.000209850076645816976906797)); + u = vmla(u, t, vcast_vd_d(-0.00110611831486672482563471)); + u = vmla(u, t, vcast_vd_d(0.00370026744188713119232403)); + u = vmla(u, t, vcast_vd_d(-0.00889896195887655491740809)); + u = vmla(u, t, vcast_vd_d(0.016599329773529201970117)); + u = vmla(u, t, vcast_vd_d(-0.0254517624932312641616861)); + u = vmla(u, t, vcast_vd_d(0.0337852580001353069993897)); + u = vmla(u, t, vcast_vd_d(-0.0407629191276836500001934)); + u = vmla(u, t, vcast_vd_d(0.0466667150077840625632675)); + u = vmla(u, t, vcast_vd_d(-0.0523674852303482457616113)); + u = vmla(u, t, vcast_vd_d(0.0587666392926673580854313)); + u = vmla(u, t, vcast_vd_d(-0.0666573579361080525984562)); + u = vmla(u, t, vcast_vd_d(0.0769219538311769618355029)); + u = vmla(u, t, vcast_vd_d(-0.090908995008245008229153)); + u = vmla(u, t, vcast_vd_d(0.111111105648261418443745)); + u = vmla(u, t, vcast_vd_d(-0.14285714266771329383765)); + u = vmla(u, t, vcast_vd_d(0.199999999996591265594148)); + u = vmla(u, t, vcast_vd_d(-0.333333333333311110369124)); + + t = vadd(s, vmul(s, vmul(t, u))); + + t = vsel(vmaski_eq(vandi(q, vcast_vi_i(1)), vcast_vi_i(1)), vsub(vcast_vd_d(rtengine::RT_PI/2), t), t); + t = vsel(vmaski_eq(vandi(q, vcast_vi_i(2)), vcast_vi_i(2)), vneg(t), t); + + return t; +} + +static INLINE vdouble xlog(vdouble d) { + vdouble x, x2; + vdouble t, m; + vint e; + + e = vilogbp1(vmul(d, vcast_vd_d(0.7071))); + m = vldexp(d, vsubi(vcast_vi_i(0), e)); + + x = vdiv(vadd(vcast_vd_d(-1), m), vadd(vcast_vd_d(1), m)); + x2 = vmul(x, x); + + t = vcast_vd_d(0.148197055177935105296783); + t = vmla(t, x2, vcast_vd_d(0.153108178020442575739679)); + t = vmla(t, x2, vcast_vd_d(0.181837339521549679055568)); + t = vmla(t, x2, vcast_vd_d(0.22222194152736701733275)); + t = vmla(t, x2, vcast_vd_d(0.285714288030134544449368)); + t = vmla(t, x2, vcast_vd_d(0.399999999989941956712869)); + t = vmla(t, x2, vcast_vd_d(0.666666666666685503450651)); + t = vmla(t, x2, vcast_vd_d(2)); + + x = vadd(vmul(x, t), vmul(vcast_vd_d(0.693147180559945286226764), vcast_vd_vi(e))); + + x = vsel(vmask_ispinf(d), vcast_vd_d(rtengine::RT_INFINITY), x); + x = vsel(vmask_gt(vcast_vd_d(0), d), vcast_vd_d(rtengine::RT_NAN), x); + x = vsel(vmask_eq(d, vcast_vd_d(0)), vcast_vd_d(-rtengine::RT_INFINITY), x); + + return x; +} + +static INLINE vdouble xexp(vdouble d) { + vint q = vrint_vi_vd(vmul(d, vcast_vd_d(R_LN2))); + vdouble s, u; + + s = vadd(d, vmul(vcast_vd_vi(q), vcast_vd_d(-L2U))); + s = vadd(s, vmul(vcast_vd_vi(q), vcast_vd_d(-L2L))); + + u = vcast_vd_d(2.08860621107283687536341e-09); + u = vmla(u, s, vcast_vd_d(2.51112930892876518610661e-08)); + u = vmla(u, s, vcast_vd_d(2.75573911234900471893338e-07)); + u = vmla(u, s, vcast_vd_d(2.75572362911928827629423e-06)); + u = vmla(u, s, vcast_vd_d(2.4801587159235472998791e-05)); + u = vmla(u, s, vcast_vd_d(0.000198412698960509205564975)); + u = vmla(u, s, vcast_vd_d(0.00138888888889774492207962)); + u = vmla(u, s, vcast_vd_d(0.00833333333331652721664984)); + u = vmla(u, s, vcast_vd_d(0.0416666666666665047591422)); + u = vmla(u, s, vcast_vd_d(0.166666666666666851703837)); + u = vmla(u, s, vcast_vd_d(0.5)); + + u = vadd(vcast_vd_d(1), vadd(s, vmul(vmul(s, s), u))); + + u = vldexp(u, q); + + u = vsel(vmask_isminf(d), vcast_vd_d(0), u); + + return u; +} + +static INLINE vdouble2 logk(vdouble d) { + vdouble2 x, x2; + vdouble t, m; + vint e; + + e = vilogbp1(vmul(d, vcast_vd_d(0.7071))); + m = vldexp(d, vsubi(vcast_vi_i(0), e)); + + x = div_dd(add2_ss(vcast_vd_d(-1), m), add2_ss(vcast_vd_d(1), m)); + x2 = squ_d(x); + x2 = normalize_d(x2); + + t = vcast_vd_d(0.134601987501262130076155); + t = vmla(t, x2.x, vcast_vd_d(0.132248509032032670243288)); + t = vmla(t, x2.x, vcast_vd_d(0.153883458318096079652524)); + t = vmla(t, x2.x, vcast_vd_d(0.181817427573705403298686)); + t = vmla(t, x2.x, vcast_vd_d(0.222222231326187414840781)); + t = vmla(t, x2.x, vcast_vd_d(0.285714285651261412873718)); + t = vmla(t, x2.x, vcast_vd_d(0.400000000000222439910458)); + t = vmla(t, x2.x, vcast_vd_d(0.666666666666666371239645)); + + return add2_dd(mul_ds(dd(vcast_vd_d(0.693147180559945286226764), vcast_vd_d(2.319046813846299558417771e-17)), + vcast_vd_vi(e)), + add2_dd(scale_d(x, vcast_vd_d(2)), mul_ds(mul_dd(x2, x), t))); +} + +static INLINE vdouble expk(vdouble2 d) { + vdouble u = vmul(vadd(d.x, d.y), vcast_vd_d(R_LN2)); + vint q = vrint_vi_vd(u); + vdouble2 s, t; + + s = add2_ds(d, vmul(vcast_vd_vi(q), vcast_vd_d(-L2U))); + s = add2_ds(s, vmul(vcast_vd_vi(q), vcast_vd_d(-L2L))); + + q = vrint_vi_vd(vmin(vmax(vcast_vd_d(-2047.49), u), vcast_vd_d(2047.49))); + + s = normalize_d(s); + + u = vcast_vd_d(2.51069683420950419527139e-08); + u = vmla(u, s.x, vcast_vd_d(2.76286166770270649116855e-07)); + u = vmla(u, s.x, vcast_vd_d(2.75572496725023574143864e-06)); + u = vmla(u, s.x, vcast_vd_d(2.48014973989819794114153e-05)); + u = vmla(u, s.x, vcast_vd_d(0.000198412698809069797676111)); + u = vmla(u, s.x, vcast_vd_d(0.0013888888939977128960529)); + u = vmla(u, s.x, vcast_vd_d(0.00833333333332371417601081)); + u = vmla(u, s.x, vcast_vd_d(0.0416666666665409524128449)); + u = vmla(u, s.x, vcast_vd_d(0.166666666666666740681535)); + u = vmla(u, s.x, vcast_vd_d(0.500000000000000999200722)); + + t = add_dd(s, mul_ds(squ_d(s), u)); + + t = add_sd(vcast_vd_d(1), t); + u = vadd(t.x, t.y); + u = vldexp(u, q); + + return u; +} + +static INLINE vdouble xpow(vdouble x, vdouble y) { +#if 1 + vmask yisint = vmask_eq(vcast_vd_vi(vrint_vi_vd(y)), y); + vmask yisodd = vandm(vmaski_eq(vandi(vrint_vi_vd(y), vcast_vi_i(1)), vcast_vi_i(1)), yisint); + + vdouble result = expk(mul_ds(logk(vabs(x)), y)); + + //result = vsel(vmask_isnan(result), vcast_vd_d(rtengine::RT_INFINITY), result); + + result = vmul(result, + vsel(vmask_gt(x, vcast_vd_d(0)), + vcast_vd_d(1), + vsel(yisint, + vsel(yisodd, + vcast_vd_d(-1), + vcast_vd_d(1)), + vcast_vd_d(rtengine::RT_NAN)))); + + vdouble efx = vreinterpret_vd_vm(vxorm(vreinterpret_vm_vd(vsub(vabs(x), vcast_vd_d(1))), vsignbit(y))); + + result = vsel(vmask_isinf(y), + vsel(vmask_lt(efx, vcast_vd_d(0)), + vcast_vd_d(0), + vsel(vmask_eq(efx, vcast_vd_d(0)), + vcast_vd_d(1.0), + vcast_vd_d(rtengine::RT_INFINITY))), + result); + + result = vsel(vorm(vmask_isinf(x), vmask_eq(x, vcast_vd_d(0))), + vmul(vsel(yisodd, vsign(x), vcast_vd_d(1)), + vsel(vmask_lt(vsel(vmask_eq(x, vcast_vd_d(0)), vneg(y), y), vcast_vd_d(0)), + vcast_vd_d(0), + vcast_vd_d(rtengine::RT_INFINITY))), + result); + + result = vsel(vorm(vmask_isnan(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_NAN), result); + + result = vsel(vorm(vmask_eq(y, vcast_vd_d(0)), vmask_eq(x, vcast_vd_d(1))), vcast_vd_d(1), result); + + return result; +#else + return expk(mul_ds(logk(x), y)); +#endif +} + +static INLINE vdouble2 expk2(vdouble2 d) { + vdouble u = vmul(vadd(d.x, d.y), vcast_vd_d(R_LN2)); + vint q = vrint_vi_vd(u); + vdouble2 s, t; + + s = add2_ds(d, vmul(vcast_vd_vi(q), vcast_vd_d(-L2U))); + s = add2_ds(s, vmul(vcast_vd_vi(q), vcast_vd_d(-L2L))); + + q = vrint_vi_vd(vmin(vmax(vcast_vd_d(-2047.49), u), vcast_vd_d(2047.49))); + + s = normalize_d(s); + + u = vcast_vd_d(2.51069683420950419527139e-08); + u = vmla(u, s.x, vcast_vd_d(2.76286166770270649116855e-07)); + u = vmla(u, s.x, vcast_vd_d(2.75572496725023574143864e-06)); + u = vmla(u, s.x, vcast_vd_d(2.48014973989819794114153e-05)); + u = vmla(u, s.x, vcast_vd_d(0.000198412698809069797676111)); + u = vmla(u, s.x, vcast_vd_d(0.0013888888939977128960529)); + u = vmla(u, s.x, vcast_vd_d(0.00833333333332371417601081)); + u = vmla(u, s.x, vcast_vd_d(0.0416666666665409524128449)); + u = vmla(u, s.x, vcast_vd_d(0.166666666666666740681535)); + u = vmla(u, s.x, vcast_vd_d(0.500000000000000999200722)); + + t = add_dd(s, mul_ds(squ_d(s), u)); + + t = add_sd(vcast_vd_d(1), t); + + return dd(vldexp(t.x, q), vldexp(t.y, q)); +} + +static INLINE vdouble xsinh(vdouble x) { + vdouble y = vabs(x); + vdouble2 d = expk2(dd(y, vcast_vd_d(0))); + d = add2_dd(d, div_dd(dd(vcast_vd_d(-1), vcast_vd_d(0)), d)); + y = vmul(vadd(d.x, d.y), vcast_vd_d(0.5)); + + y = vsel(vorm(vmask_isinf(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_INFINITY), y); + y = vmulsign(y, x); + y = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), y); + + return y; +} + +static INLINE vdouble xcosh(vdouble x) { + vdouble2 d = expk2(dd(x, vcast_vd_d(0))); + d = add2_dd(d, div_dd(dd(vcast_vd_d(1), vcast_vd_d(0)), d)); + vdouble y = vmul(vadd(d.x, d.y), vcast_vd_d(0.5)); + + y = vsel(vorm(vmask_isinf(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_INFINITY), y); + y = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), y); + + return y; +} + +static INLINE vdouble xtanh(vdouble x) { + vdouble y = vabs(x); + vdouble2 d = expk2(dd(y, vcast_vd_d(0))); + vdouble2 e = div_dd(dd(vcast_vd_d(1), vcast_vd_d(0)), d); + d = div_dd(add2_dd(d, scale_d(e, vcast_vd_d(-1))), add2_dd(d, e)); + y = d.x + d.y; + + y = vsel(vorm(vmask_isinf(x), vmask_isnan(y)), vcast_vd_d(1.0), y); + y = vmulsign(y, x); + y = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), y); + + return y; +} + +static INLINE vdouble2 logk2(vdouble2 d) { + vdouble2 x, x2, m; + vdouble t; + vint e; + + d = normalize_d(d); + e = vilogbp1(vmul(d.x, vcast_vd_d(0.7071))); + m = scale_d(d, vldexp(vcast_vd_d(1), vsubi(vcast_vi_i(0), e))); + + x = div_dd(add2_ds(m, vcast_vd_d(-1)), add2_ds(m, vcast_vd_d(1))); + x2 = squ_d(x); + x2 = normalize_d(x2); + + t = vcast_vd_d(0.134601987501262130076155); + t = vmla(t, x2.x, vcast_vd_d(0.132248509032032670243288)); + t = vmla(t, x2.x, vcast_vd_d(0.153883458318096079652524)); + t = vmla(t, x2.x, vcast_vd_d(0.181817427573705403298686)); + t = vmla(t, x2.x, vcast_vd_d(0.222222231326187414840781)); + t = vmla(t, x2.x, vcast_vd_d(0.285714285651261412873718)); + t = vmla(t, x2.x, vcast_vd_d(0.400000000000222439910458)); + t = vmla(t, x2.x, vcast_vd_d(0.666666666666666371239645)); + + return add2_dd(mul_ds(dd(vcast_vd_d(0.693147180559945286226764), vcast_vd_d(2.319046813846299558417771e-17)), + vcast_vd_vi(e)), + add2_dd(scale_d(x, vcast_vd_d(2)), mul_ds(mul_dd(x2, x), t))); +} + +static INLINE vdouble xasinh(vdouble x) { + vdouble y = vabs(x); + vdouble2 d = logk2(add2_ds(sqrt_d(add2_ds(mul_ss(y, y), vcast_vd_d(1))), y)); + y = vadd(d.x, d.y); + + y = vsel(vorm(vmask_isinf(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_INFINITY), y); + y = vmulsign(y, x); + y = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), y); + + return y; +} + +static INLINE vdouble xacosh(vdouble x) { + vdouble2 d = logk2(add2_ds(sqrt_d(add2_ds(mul_ss(x, x), vcast_vd_d(-1))), x)); + vdouble y = vadd(d.x, d.y); + + y = vsel(vorm(vmask_isinf(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_INFINITY), y); + y = vsel(vmask_eq(x, vcast_vd_d(1.0)), vcast_vd_d(0.0), y); + y = vsel(vmask_lt(x, vcast_vd_d(1.0)), vcast_vd_d(rtengine::RT_NAN), y); + y = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), y); + + return y; +} + +static INLINE vdouble xatanh(vdouble x) { + vdouble y = vabs(x); + vdouble2 d = logk2(div_dd(add2_ss(vcast_vd_d(1), y), add2_ss(vcast_vd_d(1), -y))); + y = vsel(vmask_gt(y, vcast_vd_d(1.0)), vcast_vd_d(rtengine::RT_NAN), vsel(vmask_eq(y, vcast_vd_d(1.0)), vcast_vd_d(rtengine::RT_INFINITY), vmul(vadd(d.x, d.y), vcast_vd_d(0.5)))); + + y = vsel(vorm(vmask_isinf(x), vmask_isnan(y)), vcast_vd_d(rtengine::RT_NAN), y); + y = vmulsign(y, x); + y = vsel(vmask_isnan(x), vcast_vd_d(rtengine::RT_NAN), y); + + return y; +} + +static INLINE vdouble xcbrt(vdouble d) { + vdouble x, y, q = vcast_vd_d(1.0); + vint e, qu, re; + vdouble t; + + e = vilogbp1(vabs(d)); + d = vldexp(d, vsubi(vcast_vi_i(0), e)); + + t = vadd(vcast_vd_vi(e), vcast_vd_d(6144)); + qu = vtruncate_vi_vd(vdiv(t, vcast_vd_d(3))); + re = vtruncate_vi_vd(vsub(t, vmul(vcast_vd_vi(qu), vcast_vd_d(3)))); + + q = vsel(vmaski_eq(re, vcast_vi_i(1)), vcast_vd_d(1.2599210498948731647672106), q); + q = vsel(vmaski_eq(re, vcast_vi_i(2)), vcast_vd_d(1.5874010519681994747517056), q); + q = vldexp(q, vsubi(qu, vcast_vi_i(2048))); + + q = vmulsign(q, d); + + d = vabs(d); + + x = vcast_vd_d(-0.640245898480692909870982); + x = vmla(x, d, vcast_vd_d(2.96155103020039511818595)); + x = vmla(x, d, vcast_vd_d(-5.73353060922947843636166)); + x = vmla(x, d, vcast_vd_d(6.03990368989458747961407)); + x = vmla(x, d, vcast_vd_d(-3.85841935510444988821632)); + x = vmla(x, d, vcast_vd_d(2.2307275302496609725722)); + + y = vmul(x, x); y = vmul(y, y); x = vsub(x, vmul(vmla(d, y, vneg(x)), vcast_vd_d(1.0 / 3.0))); + y = vmul(vmul(d, x), x); + y = vmul(vsub(y, vmul(vmul(vcast_vd_d(2.0 / 3.0), y), vmla(y, x, vcast_vd_d(-1.0)))), q); + + return y; +} + +static INLINE vdouble xexp2(vdouble a) { + vdouble u = expk(mul_ds(dd(vcast_vd_d(0.69314718055994528623), vcast_vd_d(2.3190468138462995584e-17)), a)); + u = vsel(vmask_ispinf(a), vcast_vd_d(rtengine::RT_INFINITY), u); + u = vsel(vmask_isminf(a), vcast_vd_d(0), u); + return u; +} + +static INLINE vdouble xexp10(vdouble a) { + vdouble u = expk(mul_ds(dd(vcast_vd_d(2.3025850929940459011), vcast_vd_d(-2.1707562233822493508e-16)), a)); + u = vsel(vmask_ispinf(a), vcast_vd_d(rtengine::RT_INFINITY), u); + u = vsel(vmask_isminf(a), vcast_vd_d(0), u); + return u; +} + +static INLINE vdouble xexpm1(vdouble a) { + vdouble2 d = add2_ds(expk2(dd(a, vcast_vd_d(0))), vcast_vd_d(-1.0)); + vdouble x = d.x + d.y; + x = vsel(vmask_ispinf(a), vcast_vd_d(rtengine::RT_INFINITY), x); + x = vsel(vmask_isminf(a), vcast_vd_d(-1), x); + return x; +} + +static INLINE vdouble xlog10(vdouble a) { + vdouble2 d = mul_dd(logk(a), dd(vcast_vd_d(0.43429448190325176116), vcast_vd_d(6.6494347733425473126e-17))); + vdouble x = d.x + d.y; + + x = vsel(vmask_ispinf(a), vcast_vd_d(rtengine::RT_INFINITY), x); + x = vsel(vmask_gt(vcast_vd_d(0), a), vcast_vd_d(rtengine::RT_NAN), x); + x = vsel(vmask_eq(a, vcast_vd_d(0)), vcast_vd_d(-rtengine::RT_INFINITY), x); + + return x; +} + +static INLINE vdouble xlog1p(vdouble a) { + vdouble2 d = logk2(add2_ss(a, vcast_vd_d(1))); + vdouble x = d.x + d.y; + + x = vsel(vmask_ispinf(a), vcast_vd_d(rtengine::RT_INFINITY), x); + x = vsel(vmask_gt(vcast_vd_d(-1), a), vcast_vd_d(rtengine::RT_NAN), x); + x = vsel(vmask_eq(a, vcast_vd_d(-1)), vcast_vd_d(-rtengine::RT_INFINITY), x); + + return x; +} // @@ -126,15 +899,580 @@ typedef struct { vfloat x, y; } vfloat2; -vfloat xsinf(vfloat d); -vfloat xcosf(vfloat d); -vfloat2 xsincosf(vfloat d); -vfloat xtanf(vfloat d); -vfloat xasinf(vfloat s); -vfloat xacosf(vfloat s); -vfloat xatanf(vfloat s); -vfloat xatan2f(vfloat y, vfloat x); -vfloat xlogf(vfloat d); -vfloat xlogf0(vfloat d); -vfloat xexpf(vfloat d); -vfloat xcbrtf(vfloat s); +static INLINE vfloat vabsf(vfloat f) { return (vfloat)vandnotm((vmask)vcast_vf_f(-0.0f), (vmask)f); } +static INLINE vfloat vnegf(vfloat f) { return (vfloat)vxorm((vmask)f, (vmask)vcast_vf_f(-0.0f)); } + +#ifdef __SSE4_1__ +// only one instruction when using SSE4.1 +static INLINE vfloat vself(vmask mask, vfloat x, vfloat y) { + return _mm_blendv_ps(y,x,(vfloat)mask); +} + +static INLINE vint vselc(vmask mask, vint x, vint y) { + return _mm_blendv_epi8(y,x,mask); +} + +#else +// three instructions when using SSE2 +static INLINE vfloat vself(vmask mask, vfloat x, vfloat y) { + return (vfloat)vorm(vandm(mask, (vmask)x), vandnotm(mask, (vmask)y)); +} + +static INLINE vint vselc(vmask mask, vint x, vint y) { + return vorm(vandm(mask, (vmask)x), vandnotm(mask, (vmask)y)); +} +#endif + +static INLINE vfloat vselfzero(vmask mask, vfloat x) { + // returns value of x if corresponding mask bits are 1, else returns 0 + // faster than vself(mask, x, ZEROV) + return _mm_and_ps((vfloat)mask, x); +} +static INLINE vfloat vselfnotzero(vmask mask, vfloat x) { + // returns value of x if corresponding mask bits are 0, else returns 0 + // faster than vself(mask, ZEROV, x) + return _mm_andnot_ps((vfloat)mask, x); +} + +static INLINE vint vselizero(vmask mask, vint x) { + // returns value of x if corresponding mask bits are 1, else returns 0 + // faster than vselc(mask, x, ZEROV) + return _mm_and_si128(mask, x); +} +static INLINE vint vselinotzero(vmask mask, vint x) { + // returns value of x if corresponding mask bits are 0, else returns 0 + // faster than vselc(mask, ZEROV, x) + return _mm_andnot_si128(mask, x); +} + +static INLINE vint2 vseli2_lt(vfloat f0, vfloat f1, vint2 x, vint2 y) { + vint2 m2 = vcast_vi2_vm(vmaskf_lt(f0, f1)); + return vori2(vandi2(m2, x), vandnoti2(m2, y)); +} + +static INLINE vmask vsignbitf(vfloat f) { + return vandm((vmask)f, (vmask)vcast_vf_f(-0.0f)); +} + +static INLINE vfloat vmulsignf(vfloat x, vfloat y) { + return (vfloat)vxorm((vmask)x, vsignbitf(y)); +} + +static INLINE vfloat vsignf(vfloat f) { + return (vfloat)vorm((vmask)vcast_vf_f(1.0f), vandm((vmask)vcast_vf_f(-0.0f), (vmask)f)); +} + +static INLINE vmask vmaskf_isinf(vfloat d) { return vmaskf_eq(vabsf(d), vcast_vf_f(INFINITYf)); } +static INLINE vmask vmaskf_ispinf(vfloat d) { return vmaskf_eq(d, vcast_vf_f(INFINITYf)); } +static INLINE vmask vmaskf_isminf(vfloat d) { return vmaskf_eq(d, vcast_vf_f(-INFINITYf)); } +static INLINE vmask vmaskf_isnan(vfloat d) { return vmaskf_neq(d, d); } +// the following is equivalent to vorm(vmaskf_isnan(a), vmaskf_isnan(b)), but faster +static INLINE vmask vmaskf_isnan(vfloat a, vfloat b) { return (vmask)_mm_cmpunord_ps(a, b); } +static INLINE vfloat visinf2f(vfloat d, vfloat m) { return (vfloat)vandm(vmaskf_isinf(d), vorm(vsignbitf(d), (vmask)m)); } +static INLINE vfloat visinff(vfloat d) { return visinf2f(d, vcast_vf_f(1.0f)); } + +static INLINE vint2 vilogbp1f(vfloat d) { + vmask m = vmaskf_lt(d, vcast_vf_f(5.421010862427522E-20f)); + d = vself(m, vmulf(vcast_vf_f(1.8446744073709552E19f), d), d); + vint2 q = vandi2(vsrli2(vcast_vi2_vm(vreinterpret_vm_vf(d)), 23), vcast_vi2_i(0xff)); + q = vsubi2(q, vseli2(m, vcast_vi2_i(64 + 0x7e), vcast_vi2_i(0x7e))); + return q; +} + +static INLINE vfloat vldexpf(vfloat x, vint2 q) { + vfloat u; + vint2 m = vsrai2(q, 31); + m = vslli2(vsubi2(vsrai2(vaddi2(m, q), 6), m), 4); + q = vsubi2(q, vslli2(m, 2)); + u = vreinterpret_vf_vm(vcast_vm_vi2(vslli2(vaddi2(m, vcast_vi2_i(0x7f)), 23))); + x = vmulf(vmulf(vmulf(vmulf(x, u), u), u), u); + u = vreinterpret_vf_vm(vcast_vm_vi2(vslli2(vaddi2(q, vcast_vi2_i(0x7f)), 23))); + return vmulf(x, u); +} + +static INLINE vfloat xsinf(vfloat d) { + vint2 q; + vfloat u, s; + + q = vrint_vi2_vf(vmulf(d, vcast_vf_f((float)rtengine::RT_1_PI))); + + u = vcast_vf_vi2(q); + d = vmlaf(u, vcast_vf_f(-PI4_Af*4), d); + d = vmlaf(u, vcast_vf_f(-PI4_Bf*4), d); + d = vmlaf(u, vcast_vf_f(-PI4_Cf*4), d); + d = vmlaf(u, vcast_vf_f(-PI4_Df*4), d); + + s = vmulf(d, d); + + d = vself(vmaski2_eq(vandi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vnegf(d), d); + + u = vcast_vf_f(2.6083159809786593541503e-06f); + u = vmlaf(u, s, vcast_vf_f(-0.0001981069071916863322258f)); + u = vmlaf(u, s, vcast_vf_f(0.00833307858556509017944336f)); + u = vmlaf(u, s, vcast_vf_f(-0.166666597127914428710938f)); + + u = vmlaf(s, vmulf(u, d), d); + + return u; +} + +static INLINE vfloat xcosf(vfloat d) { + vint2 q; + vfloat u, s; + + q = vrint_vi2_vf(vsubf(vmulf(d, vcast_vf_f((float)rtengine::RT_1_PI)), vcast_vf_f(0.5f))); + q = vaddi2(vaddi2(q, q), vcast_vi2_i(1)); + + u = vcast_vf_vi2(q); + d = vmlaf(u, vcast_vf_f(-PI4_Af*2), d); + d = vmlaf(u, vcast_vf_f(-PI4_Bf*2), d); + d = vmlaf(u, vcast_vf_f(-PI4_Cf*2), d); + d = vmlaf(u, vcast_vf_f(-PI4_Df*2), d); + + s = vmulf(d, d); + + d = vself(vmaski2_eq(vandi2(q, vcast_vi2_i(2)), vcast_vi2_i(2)), d, vnegf(d)); + + u = vcast_vf_f(2.6083159809786593541503e-06f); + u = vmlaf(u, s, vcast_vf_f(-0.0001981069071916863322258f)); + u = vmlaf(u, s, vcast_vf_f(0.00833307858556509017944336f)); + u = vmlaf(u, s, vcast_vf_f(-0.166666597127914428710938f)); + + u = vmlaf(s, vmulf(u, d), d); + + return u; +} + +static INLINE vfloat2 xsincosf(vfloat d) { + vint2 q; + vmask m; + vfloat u, s, t, rx, ry; + vfloat2 r; + + q = vrint_vi2_vf(vmulf(d, vcast_vf_f((float)rtengine::RT_2_PI))); + + s = d; + + u = vcast_vf_vi2(q); + s = vmlaf(u, vcast_vf_f(-PI4_Af*2), s); + s = vmlaf(u, vcast_vf_f(-PI4_Bf*2), s); + s = vmlaf(u, vcast_vf_f(-PI4_Cf*2), s); + s = vmlaf(u, vcast_vf_f(-PI4_Df*2), s); + + t = s; + + s = vmulf(s, s); + + u = vcast_vf_f(-0.000195169282960705459117889f); + u = vmlaf(u, s, vcast_vf_f(0.00833215750753879547119141f)); + u = vmlaf(u, s, vcast_vf_f(-0.166666537523269653320312f)); + u = vmulf(vmulf(u, s), t); + + rx = vaddf(t, u); + + u = vcast_vf_f(-2.71811842367242206819355e-07f); + u = vmlaf(u, s, vcast_vf_f(2.47990446951007470488548e-05f)); + u = vmlaf(u, s, vcast_vf_f(-0.00138888787478208541870117f)); + u = vmlaf(u, s, vcast_vf_f(0.0416666641831398010253906f)); + u = vmlaf(u, s, vcast_vf_f(-0.5)); + + ry = vaddf(vcast_vf_f(1), vmulf(s, u)); + + m = vmaski2_eq(vandi2(q, vcast_vi2_i(1)), vcast_vi2_i(0)); + r.x = vself(m, rx, ry); + r.y = vself(m, ry, rx); + + m = vmaski2_eq(vandi2(q, vcast_vi2_i(2)), vcast_vi2_i(2)); + r.x = vreinterpret_vf_vm(vxorm(vandm(m, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(r.x))); + + m = vmaski2_eq(vandi2(vaddi2(q, vcast_vi2_i(1)), vcast_vi2_i(2)), vcast_vi2_i(2)); + r.y = vreinterpret_vf_vm(vxorm(vandm(m, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(r.y))); + + m = vmaskf_isinf(d); + r.x = vself(m, vcast_vf_f(rtengine::RT_NAN), r.x); + r.y = vself(m, vcast_vf_f(rtengine::RT_NAN), r.y); + + return r; +} + +static INLINE vfloat xtanf(vfloat d) { + vint2 q; + vmask m; + vfloat u, s, x; + + q = vrint_vi2_vf(vmulf(d, vcast_vf_f((float)(2 * rtengine::RT_1_PI)))); + + x = d; + + u = vcast_vf_vi2(q); + x = vmlaf(u, vcast_vf_f(-PI4_Af*2), x); + x = vmlaf(u, vcast_vf_f(-PI4_Bf*2), x); + x = vmlaf(u, vcast_vf_f(-PI4_Cf*2), x); + x = vmlaf(u, vcast_vf_f(-PI4_Df*2), x); + + s = vmulf(x, x); + + m = vmaski2_eq(vandi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)); + x = vself(m, vnegf(x), x); + + u = vcast_vf_f(0.00927245803177356719970703f); + u = vmlaf(u, s, vcast_vf_f(0.00331984995864331722259521f)); + u = vmlaf(u, s, vcast_vf_f(0.0242998078465461730957031f)); + u = vmlaf(u, s, vcast_vf_f(0.0534495301544666290283203f)); + u = vmlaf(u, s, vcast_vf_f(0.133383005857467651367188f)); + u = vmlaf(u, s, vcast_vf_f(0.333331853151321411132812f)); + + u = vmlaf(s, vmulf(u, x), x); + + u = vself(m, vrecf(u), u); + + u = vself(vmaskf_isinf(d), vcast_vf_f(NANf), u); + + return u; +} + +static INLINE vfloat xatanf(vfloat s) { + vfloat t, u; + vint2 q; + + q = vseli2_lt(s, vcast_vf_f(0.0f), vcast_vi2_i(2), vcast_vi2_i(0)); + s = vabsf(s); + + q = vseli2_lt(vcast_vf_f(1.0f), s, vaddi2(q, vcast_vi2_i(1)), q); + s = vself(vmaskf_lt(vcast_vf_f(1.0f), s), vdivf(vcast_vf_f(1.0f), s), s); + + t = vmulf(s, s); + + u = vcast_vf_f(0.00282363896258175373077393f); + u = vmlaf(u, t, vcast_vf_f(-0.0159569028764963150024414f)); + u = vmlaf(u, t, vcast_vf_f(0.0425049886107444763183594f)); + u = vmlaf(u, t, vcast_vf_f(-0.0748900920152664184570312f)); + u = vmlaf(u, t, vcast_vf_f(0.106347933411598205566406f)); + u = vmlaf(u, t, vcast_vf_f(-0.142027363181114196777344f)); + u = vmlaf(u, t, vcast_vf_f(0.199926957488059997558594f)); + u = vmlaf(u, t, vcast_vf_f(-0.333331018686294555664062f)); + + t = vaddf(s, vmulf(s, vmulf(t, u))); + + t = vself(vmaski2_eq(vandi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vsubf(vcast_vf_f((float)(rtengine::RT_PI/2)), t), t); + t = vself(vmaski2_eq(vandi2(q, vcast_vi2_i(2)), vcast_vi2_i(2)), vnegf(t), t); + + return t; +} + +static INLINE vfloat atan2kf(vfloat y, vfloat x) { + vfloat s, t, u; + vint2 q; + vmask p; + + q = vseli2_lt(x, vcast_vf_f(0.0f), vcast_vi2_i(-2), vcast_vi2_i(0)); + x = vabsf(x); + + q = vseli2_lt(x, y, vaddi2(q, vcast_vi2_i(1)), q); + p = vmaskf_lt(x, y); + s = vself(p, vnegf(x), y); + t = vmaxf(x, y); + + s = vdivf(s, t); + t = vmulf(s, s); + + u = vcast_vf_f(0.00282363896258175373077393f); + u = vmlaf(u, t, vcast_vf_f(-0.0159569028764963150024414f)); + u = vmlaf(u, t, vcast_vf_f(0.0425049886107444763183594f)); + u = vmlaf(u, t, vcast_vf_f(-0.0748900920152664184570312f)); + u = vmlaf(u, t, vcast_vf_f(0.106347933411598205566406f)); + u = vmlaf(u, t, vcast_vf_f(-0.142027363181114196777344f)); + u = vmlaf(u, t, vcast_vf_f(0.199926957488059997558594f)); + u = vmlaf(u, t, vcast_vf_f(-0.333331018686294555664062f)); + + t = vaddf(s, vmulf(s, vmulf(t, u))); + t = vaddf(t, vmulf(vcast_vf_vi2(q), vcast_vf_f((float)(rtengine::RT_PI/2)))); + + return t; +} + +static INLINE vfloat xatan2f(vfloat y, vfloat x) { + vfloat r = atan2kf(vabsf(y), x); + + r = vmulsignf(r, x); + r = vself(vorm(vmaskf_isinf(x), vmaskf_eq(x, vcast_vf_f(0.0f))), vsubf(vcast_vf_f((float)(rtengine::RT_PI/2)), visinf2f(x, vmulsignf(vcast_vf_f((float)(rtengine::RT_PI/2)), x))), r); + r = vself(vmaskf_isinf(y), vsubf(vcast_vf_f((float)(rtengine::RT_PI/2)), visinf2f(x, vmulsignf(vcast_vf_f((float)(rtengine::RT_PI/4)), x))), r); + r = vself(vmaskf_eq(y, vcast_vf_f(0.0f)), vselfzero(vmaskf_eq(vsignf(x), vcast_vf_f(-1.0f)), vcast_vf_f((float)rtengine::RT_PI)), r); + + return vself(vmaskf_isnan(x, y), vcast_vf_f(NANf), vmulsignf(r, y)); +} + +static INLINE vfloat xasinf(vfloat d) { + vfloat x, y; + x = vaddf(vcast_vf_f(1.0f), d); + y = vsubf(vcast_vf_f(1.0f), d); + x = vmulf(x, y); + x = vsqrtf(x); + x = vself(vmaskf_isnan(x), vcast_vf_f(NANf), atan2kf(vabsf(d), x)); + return vmulsignf(x, d); +} + +static INLINE vfloat xacosf(vfloat d) { + vfloat x, y; + x = vaddf(vcast_vf_f(1.0f), d); + y = vsubf(vcast_vf_f(1.0f), d); + x = vmulf(x, y); + x = vsqrtf(x); + x = vmulsignf(atan2kf(x, vabsf(d)), d); + y = (vfloat)vandm(vmaskf_lt(d, vcast_vf_f(0.0f)), (vmask)vcast_vf_f((float)rtengine::RT_PI)); + x = vaddf(x, y); + return x; +} + +static INLINE vfloat xlogf(vfloat d) { + vfloat x, x2, t, m; + vint2 e; + + e = vilogbp1f(vmulf(d, vcast_vf_f(0.7071f))); + m = vldexpf(d, vsubi2(vcast_vi2_i(0), e)); + + x = vdivf(vaddf(vcast_vf_f(-1.0f), m), vaddf(vcast_vf_f(1.0f), m)); + x2 = vmulf(x, x); + + t = vcast_vf_f(0.2371599674224853515625f); + t = vmlaf(t, x2, vcast_vf_f(0.285279005765914916992188f)); + t = vmlaf(t, x2, vcast_vf_f(0.400005519390106201171875f)); + t = vmlaf(t, x2, vcast_vf_f(0.666666567325592041015625f)); + t = vmlaf(t, x2, vcast_vf_f(2.0f)); + + x = vaddf(vmulf(x, t), vmulf(vcast_vf_f(0.693147180559945286226764f), vcast_vf_vi2(e))); + + x = vself(vmaskf_ispinf(d), vcast_vf_f(INFINITYf), x); + x = vself(vmaskf_gt(vcast_vf_f(0), d), vcast_vf_f(NANf), x); + x = vself(vmaskf_eq(d, vcast_vf_f(0)), vcast_vf_f(-INFINITYf), x); + + return x; +} + +static INLINE vfloat xlogf1(vfloat d) { // does xlogf(vmaxf(d, 1.f)) but faster + vfloat x, x2, t, m; + vint2 e; + + e = vilogbp1f(vmulf(d, vcast_vf_f(0.7071f))); + m = vldexpf(d, vsubi2(vcast_vi2_i(0), e)); + + x = vdivf(vaddf(vcast_vf_f(-1.0f), m), vaddf(vcast_vf_f(1.0f), m)); + x2 = vmulf(x, x); + + t = vcast_vf_f(0.2371599674224853515625f); + t = vmlaf(t, x2, vcast_vf_f(0.285279005765914916992188f)); + t = vmlaf(t, x2, vcast_vf_f(0.400005519390106201171875f)); + t = vmlaf(t, x2, vcast_vf_f(0.666666567325592041015625f)); + t = vmlaf(t, x2, vcast_vf_f(2.0f)); + + x = vaddf(vmulf(x, t), vmulf(vcast_vf_f(0.693147180559945286226764f), vcast_vf_vi2(e))); + + x = vself(vmaskf_ispinf(d), vcast_vf_f(INFINITYf), x); + x = vselfnotzero(vmaskf_le(d, vcast_vf_f(1.f)), x); + + return x; +} + +static INLINE vfloat xlogf0(vfloat d) { + vfloat x, x2, t, m; + vint2 e; + + e = vilogbp1f(vmulf(d, vcast_vf_f(0.7071f))); + m = vldexpf(d, vsubi2(vcast_vi2_i(0), e)); + + x = vdivf(vaddf(vcast_vf_f(-1.0f), m), vaddf(vcast_vf_f(1.0f), m)); + x2 = vmulf(x, x); + + t = vcast_vf_f(0.2371599674224853515625f); + t = vmlaf(t, x2, vcast_vf_f(0.285279005765914916992188f)); + t = vmlaf(t, x2, vcast_vf_f(0.400005519390106201171875f)); + t = vmlaf(t, x2, vcast_vf_f(0.666666567325592041015625f)); + t = vmlaf(t, x2, vcast_vf_f(2.0f)); + + x = vaddf(vmulf(x, t), vmulf(vcast_vf_f(0.693147180559945286226764f), vcast_vf_vi2(e))); + + x = vself(vmaskf_ispinf(d), vcast_vf_f(0), x); + x = vself(vmaskf_gt(vcast_vf_f(0), d), vcast_vf_f(0), x); + x = vself(vmaskf_eq(d, vcast_vf_f(0)), vcast_vf_f(0), x); + + return x; +} + +static INLINE vfloat xlogfNoCheck(vfloat d) { // this version does not check input values. Use it only when you know the input values are > 0 e.g. when filling a lookup table + vfloat x, x2, t, m; + vint2 e; + + e = vilogbp1f(vmulf(d, vcast_vf_f(0.7071f))); + m = vldexpf(d, vsubi2(vcast_vi2_i(0), e)); + + x = vdivf(vaddf(vcast_vf_f(-1.0f), m), vaddf(vcast_vf_f(1.0f), m)); + x2 = vmulf(x, x); + + t = vcast_vf_f(0.2371599674224853515625f); + t = vmlaf(t, x2, vcast_vf_f(0.285279005765914916992188f)); + t = vmlaf(t, x2, vcast_vf_f(0.400005519390106201171875f)); + t = vmlaf(t, x2, vcast_vf_f(0.666666567325592041015625f)); + t = vmlaf(t, x2, vcast_vf_f(2.0f)); + + return vaddf(vmulf(x, t), vmulf(vcast_vf_f(0.693147180559945286226764f), vcast_vf_vi2(e))); + +} + +static INLINE vfloat xexpf(vfloat d) { + vint2 q = vrint_vi2_vf(vmulf(d, vcast_vf_f(R_LN2f))); + vfloat s, u; + + s = vmlaf(vcast_vf_vi2(q), vcast_vf_f(-L2Uf),d); + s = vmlaf(vcast_vf_vi2(q), vcast_vf_f(-L2Lf),s); + + u = vcast_vf_f(0.00136324646882712841033936f); + u = vmlaf(u, s, vcast_vf_f(0.00836596917361021041870117f)); + u = vmlaf(u, s, vcast_vf_f(0.0416710823774337768554688f)); + u = vmlaf(u, s, vcast_vf_f(0.166665524244308471679688f)); + u = vmlaf(u, s, vcast_vf_f(0.499999850988388061523438f)); + + u = vaddf(vcast_vf_f(1.0f), vmlaf(vmulf(s, s), u, s)); + + u = vldexpf(u, q); + + // -104.0 + return vselfnotzero(vmaskf_gt(vcast_vf_f(-104.f), d), u); +} + +static INLINE vfloat xexpfNoCheck(vfloat d) { // this version does not check input values. Use it only when you know the input values are > -104.f e.g. when filling a lookup table + vint2 q = vrint_vi2_vf(vmulf(d, vcast_vf_f(R_LN2f))); + vfloat s, u; + + s = vmlaf(vcast_vf_vi2(q), vcast_vf_f(-L2Uf),d); + s = vmlaf(vcast_vf_vi2(q), vcast_vf_f(-L2Lf),s); + + u = vcast_vf_f(0.00136324646882712841033936f); + u = vmlaf(u, s, vcast_vf_f(0.00836596917361021041870117f)); + u = vmlaf(u, s, vcast_vf_f(0.0416710823774337768554688f)); + u = vmlaf(u, s, vcast_vf_f(0.166665524244308471679688f)); + u = vmlaf(u, s, vcast_vf_f(0.499999850988388061523438f)); + + u = vaddf(vcast_vf_f(1.0f), vmlaf(vmulf(s, s), u, s)); + + return vldexpf(u, q); +} + +static INLINE vfloat xcbrtf(vfloat d) { + vfloat x, y, q = vcast_vf_f(1.0), t; + vint2 e, qu, re; + + e = vilogbp1f(vabsf(d)); + d = vldexpf(d, vsubi2(vcast_vi2_i(0), e)); + + t = vaddf(vcast_vf_vi2(e), vcast_vf_f(6144)); + qu = vtruncate_vi2_vf(vdivf(t, vcast_vf_f(3))); + re = vtruncate_vi2_vf(vsubf(t, vmulf(vcast_vf_vi2(qu), vcast_vf_f(3)))); + + q = vself(vmaski2_eq(re, vcast_vi2_i(1)), vcast_vf_f(1.2599210498948731647672106f), q); + q = vself(vmaski2_eq(re, vcast_vi2_i(2)), vcast_vf_f(1.5874010519681994747517056f), q); + q = vldexpf(q, vsubi2(qu, vcast_vi2_i(2048))); + + q = vmulsignf(q, d); + d = vabsf(d); + + x = vcast_vf_f(-0.601564466953277587890625f); + x = vmlaf(x, d, vcast_vf_f(2.8208892345428466796875f)); + x = vmlaf(x, d, vcast_vf_f(-5.532182216644287109375f)); + x = vmlaf(x, d, vcast_vf_f(5.898262500762939453125f)); + x = vmlaf(x, d, vcast_vf_f(-3.8095417022705078125f)); + x = vmlaf(x, d, vcast_vf_f(2.2241256237030029296875f)); + + y = vmulf(vmulf(d, x), x); + y = vmulf(vsubf(y, vmulf(vmulf(vcast_vf_f(2.0f / 3.0f), y), vmlaf(y, x, vcast_vf_f(-1.0f)))), q); + + return y; +} + +static INLINE vfloat vclampf(vfloat value, vfloat low, vfloat high) { + // clamps value in [low;high], returns low if value is NaN + return vmaxf(vminf(high, value), low); +} + +static INLINE vfloat SQRV(vfloat a){ + return a * a; +} + +static inline void vswap( vmask condition, vfloat &a, vfloat &b) { + // conditional swap the elements of two vfloats + vfloat temp = vself(condition, a, b); // the values which fit to condition + a = vself(condition, b, a); // the values which fit to inverted condition + b = temp; +} + +static inline float vhadd( vfloat a ) { + // returns a[0] + a[1] + a[2] + a[3] + a += _mm_movehl_ps(a, a); + return _mm_cvtss_f32(_mm_add_ss(a, _mm_shuffle_ps(a, a, 1))); +} + +static inline float vhmin(vfloat a) { + // returns min(a[0], a[1], a[2], a[3]) + a = vminf(a, _mm_movehl_ps(a, a)); + return _mm_cvtss_f32(vminf(a, _mm_shuffle_ps(a, a, 1))); +} + +static inline float vhmax(vfloat a) { + // returns max(a[0], a[1], a[2], a[3]) + a = vmaxf(a, _mm_movehl_ps(a, a)); + return _mm_cvtss_f32(vmaxf(a, _mm_shuffle_ps(a, a, 1))); +} + +static INLINE vfloat vmul2f(vfloat a){ + // fastest way to multiply by 2 + return a + a; +} + +static INLINE vfloat vintpf(vfloat a, vfloat b, vfloat c) { + // calculate a * b + (1 - a) * c (interpolate two values) + // following is valid: + // vintpf(a, b+x, c+x) = vintpf(a, b, c) + x + // vintpf(a, b*x, c*x) = vintpf(a, b, c) * x + return a * (b-c) + c; +} + +static INLINE vfloat vdup(vfloat a){ + // returns { a[0],a[0],a[1],a[1] } + return _mm_unpacklo_ps( a, a ); +} + +static INLINE vfloat vaddc2vfu(float &a) +{ + // loads a[0]..a[7] and returns { a[0]+a[1], a[2]+a[3], a[4]+a[5], a[6]+a[7] } + vfloat a1 = _mm_loadu_ps( &a ); + vfloat a2 = _mm_loadu_ps( (&a) + 4 ); + return _mm_shuffle_ps(a1,a2,_MM_SHUFFLE( 2,0,2,0 )) + _mm_shuffle_ps(a1,a2,_MM_SHUFFLE( 3,1,3,1 )); +} + +static INLINE vfloat vadivapb (vfloat a, vfloat b) { + return a / (a+b); +} + +static INLINE void vconvertrgbrgbrgbrgb2rrrrggggbbbb (const float * src, vfloat &rv, vfloat &gv, vfloat &bv) { // cool function name, isn't it ? :P + // converts a sequence of 4 float RGB triplets to 3 red, green and blue quadruples + rv = _mm_setr_ps(src[0],src[3],src[6],src[9]); + gv = _mm_setr_ps(src[1],src[4],src[7],src[10]); + bv = _mm_setr_ps(src[2],src[5],src[8],src[11]); +} + +#if defined( __SSE4_1__ ) && defined( __x86_64__ ) +static INLINE vfloat vceilf(vfloat x) { + return _mm_round_ps(x, _MM_FROUND_TO_POS_INF |_MM_FROUND_NO_EXC); +} + +#else + +static INLINE vfloat vceilf(vfloat x) { + __m128i zerov = _mm_setzero_si128(); + zerov = _mm_cmpeq_epi32(zerov, zerov); + const vfloat onev = (vfloat)_mm_slli_epi32(_mm_srli_epi32(zerov, 25), 23); //create vector 1.0f + const vfloat xi = _mm_cvtepi32_ps(_mm_cvttps_epi32(x)); + return xi + _mm_and_ps(_mm_cmplt_ps(xi, x), onev); +} +#endif + +#endif // __SSE2__ diff --git a/rtengine/stdimagesource.cc b/rtengine/stdimagesource.cc index 1cb11e94d..271818303 100644 --- a/rtengine/stdimagesource.cc +++ b/rtengine/stdimagesource.cc @@ -53,7 +53,6 @@ template T** allocArray (int W, int H) return t; } -#define HR_SCALE 2 StdImageSource::StdImageSource () : ImageSource(), img(nullptr), plistener(nullptr), full(false), max{}, rgbSourceModified(false) { diff --git a/rtengine/tmo_fattal02.cc b/rtengine/tmo_fattal02.cc index feba5c95f..cee57c851 100644 --- a/rtengine/tmo_fattal02.cc +++ b/rtengine/tmo_fattal02.cc @@ -308,7 +308,7 @@ float calculateGradients (Array2Df* H, Array2Df* G, int k, bool multithread) // however, the impact is not visible so we ignore this here (*G) (x, y) = sqrt (gx * gx + gy * gy) / divider; - avgGrad += (*G) (x, y); + avgGrad += static_cast((*G) (x, y)); } } @@ -381,7 +381,7 @@ void calculateFiMatrix (Array2Df* FI, Array2Df* gradients[], #endif for ( int y = 0; y < height; y++ ) { for ( int x = 0; x < width; x++ ) { - float grad = ((*gradients[k]) (x, y) < 1e-4f) ? 1e-4 : (*gradients[k]) (x, y); + float grad = ((*gradients[k]) (x, y) < 1e-4f) ? 1e-4f : (*gradients[k]) (x, y); float a = alfa * avgGrad[k]; float value = pow ((grad + noise) / a, beta - 1.0f); @@ -603,8 +603,8 @@ void tmo_fattal02 (size_t width, // sets index+1 based on the boundary assumption H(N+1)=H(N-1) unsigned int xp1 = (x + 1 >= width ? width - 2 : x + 1); // forward differences in H, so need to use between-points approx of FI - (*Gx) (x, y) = ((*H) (xp1, y) - (*H) (x, y)) * 0.5 * ((*FI) (xp1, y) + (*FI) (x, y)); - (*Gy) (x, y) = ((*H) (x, yp1) - (*H) (x, y)) * 0.5 * ((*FI) (x, yp1) + (*FI) (x, y)); + (*Gx) (x, y) = ((*H) (xp1, y) - (*H) (x, y)) * 0.5f * ((*FI) (xp1, y) + (*FI) (x, y)); + (*Gy) (x, y) = ((*H) (x, yp1) - (*H) (x, y)) * 0.5f * ((*FI) (x, yp1) + (*FI) (x, y)); } } @@ -747,7 +747,7 @@ void transform_ev2normal (Array2Df *A, Array2Df *T, bool multithread) } for (int y = 1 ; y < height - 1 ; y++ ) { - (*A) (0, y) *= 0.5; + (*A) (0, y) *= 0.5f; (*A) (width - 1, y) *= 0.5f; } @@ -912,7 +912,7 @@ void solve_pde_fft (Array2Df *F, Array2Df *U, Array2Df *buf, bool multithread)/* for (int y = 0 ; y < height ; y++ ) { for (int x = 0 ; x < width ; x++ ) { - (*F_tr) (x, y) = (*F_tr) (x, y) / (l1[y] + l2[x]); + (*F_tr) (x, y) = static_cast((*F_tr) (x, y)) / (l1[y] + l2[x]); } } diff --git a/rtengine/utils.cc b/rtengine/utils.cc index a07a1235f..0674c9806 100644 --- a/rtengine/utils.cc +++ b/rtengine/utils.cc @@ -22,7 +22,6 @@ #include "rt_math.h" #include "utils.h" -#include "rt_math.h" using namespace std; diff --git a/rtengine/xtrans_demosaic.cc b/rtengine/xtrans_demosaic.cc index cb1315ed0..b01b0ac1c 100644 --- a/rtengine/xtrans_demosaic.cc +++ b/rtengine/xtrans_demosaic.cc @@ -31,7 +31,7 @@ namespace rtengine { -const double xyz_rgb[3][3] = { // XYZ from RGB +const float xyz_rgb[3][3] = { // XYZ from RGB { 0.412453, 0.357580, 0.180423 }, { 0.212671, 0.715160, 0.072169 }, { 0.019334, 0.119193, 0.950227 } diff --git a/rtexif/canonattribs.cc b/rtexif/canonattribs.cc index ee451c7d7..636bf4328 100644 --- a/rtexif/canonattribs.cc +++ b/rtexif/canonattribs.cc @@ -16,8 +16,6 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#ifndef _CANONATTRIBS_ -#define _CANONATTRIBS_ #include #include @@ -1231,7 +1229,7 @@ public: int a = Interpreter::toInt (t, ofs, astype); if (a > 1) { - int i = int (double (powf (2.f, float (a) / 32.f - 4.f)) * 50.f + 0.5f); + int i = static_cast(powf (2.f, static_cast(a) / 32.f - 4.f)) * 50.0 + 0.5; return i; } else { return 0; @@ -2142,5 +2140,4 @@ const TagAttrib canonAttribs[] = { { -1, AC_DONTWRITE, 0, nullptr, 0, AUTO, "", nullptr} }; } -#endif diff --git a/rtexif/fujiattribs.cc b/rtexif/fujiattribs.cc index 0eaa505f6..ffbf3a0be 100644 --- a/rtexif/fujiattribs.cc +++ b/rtexif/fujiattribs.cc @@ -16,8 +16,6 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#ifndef _FUJIATTRIBS_ -#define _FUJIATTRIBS_ #include "rtexif.h" @@ -312,5 +310,4 @@ const TagAttrib fujiAttribs[] = { { -1, AC_DONTWRITE, 0, nullptr, 0, AUTO, "", nullptr} }; } -#endif diff --git a/rtexif/kodakattribs.cc b/rtexif/kodakattribs.cc index a9c168a70..c89ca2298 100644 --- a/rtexif/kodakattribs.cc +++ b/rtexif/kodakattribs.cc @@ -1,8 +1,6 @@ /* * This file is part of RawTherapee. */ -#ifndef _KODAKATTRIBS_ -#define _KODAKATTRIBS_ #include #include "rtexif.h" @@ -58,7 +56,7 @@ void parseKodakIfdTextualInfo (Tag *textualInfo, Tag* exif_) // Proback645 may have "Lens" but not "Focal Length" float flen = atof (val.c_str()); - if (flen != 0.0) { + if (flen != 0.f) { t = new Tag (exif, lookupAttrib (exifAttribs, "FocalLength")); t->initRational (flen * 32, 32); exif->replaceTag (t); @@ -66,7 +64,7 @@ void parseKodakIfdTextualInfo (Tag *textualInfo, Tag* exif_) } else if (key == "Focal Length") { float flen = atof (val.c_str()); - if (flen != 0.0) { + if (flen != 0.f) { t = new Tag (exif, lookupAttrib (exifAttribs, "FocalLength")); t->initRational (flen * 32, 32); exif->replaceTag (t); @@ -74,7 +72,7 @@ void parseKodakIfdTextualInfo (Tag *textualInfo, Tag* exif_) } else if (key == "Aperture") { float aperture = atof (&val.c_str()[1]); - if (aperture != 0.0) { + if (aperture != 0.f) { t = new Tag (exif, lookupAttrib (exifAttribs, "FNumber")); t->initRational ((int) (aperture * 10), 10); exif->replaceTag (t); @@ -161,5 +159,4 @@ const TagAttrib kodakIfdAttribs[] = { }; } -#endif diff --git a/rtexif/nikonattribs.cc b/rtexif/nikonattribs.cc index 2ef37b8fb..0bc9ce730 100644 --- a/rtexif/nikonattribs.cc +++ b/rtexif/nikonattribs.cc @@ -16,8 +16,6 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#ifndef _NIKONATTRIBS_ -#define _NIKONATTRIBS_ #include #include @@ -70,7 +68,7 @@ public: int a = t->getValue()[ofs]; if (a > 1) { - int i = int (double (powf (2.f, float (a) / 12.f - 5.f)) * 100.f + 0.5f); + int i = static_cast(powf(2.f, float (a) / 12.f - 5.f)) * 100.0 + 0.5; return i; } else { return 0; @@ -1229,5 +1227,3 @@ const TagAttrib nikon3Attribs[] = { }; } -#endif - diff --git a/rtexif/olympusattribs.cc b/rtexif/olympusattribs.cc index f590b8154..ec7ab98c7 100644 --- a/rtexif/olympusattribs.cc +++ b/rtexif/olympusattribs.cc @@ -16,8 +16,6 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#ifndef _OLYMPUSATTRIBS_ -#define _OLYMPUSATTRIBS_ #include #include @@ -850,5 +848,3 @@ const TagAttrib olympusAttribs[] = { { -1, AC_DONTWRITE, 0, nullptr, 0, AUTO, "", nullptr} }; } -#endif - diff --git a/rtexif/panasonicattribs.cc b/rtexif/panasonicattribs.cc index 3062824cf..4ebcf2447 100644 --- a/rtexif/panasonicattribs.cc +++ b/rtexif/panasonicattribs.cc @@ -1,8 +1,6 @@ /* * This file is part of RawTherapee. */ -#ifndef _PANASONICATTRIBS_ -#define _PANASONICATTRIBS_ #include #include "rtexif.h" @@ -138,5 +136,3 @@ const TagAttrib panasonicRawAttribs[] = { }; } -#endif - diff --git a/rtexif/pentaxattribs.cc b/rtexif/pentaxattribs.cc index 46ae9f67e..da940f5cb 100644 --- a/rtexif/pentaxattribs.cc +++ b/rtexif/pentaxattribs.cc @@ -16,8 +16,6 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#ifndef _PENTAXATTRIBS_ -#define _PENTAXATTRIBS_ #include #include @@ -696,7 +694,7 @@ public: }; PAColorSpaceInterpreter paColorSpaceInterpreter; -class PALensTypeInterpreter : public IntLensInterpreter< int > +class PALensTypeInterpreter final: public IntLensInterpreter< int > { public: PALensTypeInterpreter () @@ -1395,9 +1393,9 @@ public: std::string toString (const Tag* t) const override { int a = t->toInt (0, BYTE); - float b = float (10 * int (a >> 2)) * pow (4.f, float (int (a & 0x03) - 2)); + double b = static_cast(10 * (a >> 2)) * std::pow(4.0, static_cast((a & 0x03) - 2)); - if (b > 1.f) { + if (b > 1.0) { char buffer[32]; sprintf (buffer, "%.2f", b ); return buffer; @@ -1408,9 +1406,9 @@ public: double toDouble (const Tag* t, int ofs) override { int a = t->toInt (ofs, BYTE); - float b = float (10 * int (a >> 2)) * pow (4.f, float (int (a & 0x03) - 2)); + double b = static_cast(10 * (a >> 2)) * std::pow(4.0, static_cast((a & 0x03) - 2)); - if (b > 1.f) { + if (b > 1.0) { return b; } else { return 0.; @@ -2216,7 +2214,6 @@ const TagAttrib pentaxCameraInfoAttribs[] = { }; } -#endif diff --git a/rtexif/rtexif.cc b/rtexif/rtexif.cc index 89ff6cd33..06604ade5 100644 --- a/rtexif/rtexif.cc +++ b/rtexif/rtexif.cc @@ -2344,7 +2344,7 @@ void ExifManager::parseCIFF (int length, TagDirectory* root) ev = ((short)get2 (f, INTEL)) / 32.0f; fseek (f, 34, SEEK_CUR); - if (shutter > 1e6) { + if (shutter > 1e6f) { shutter = get2 (f, INTEL) / 10.0f; } diff --git a/rtexif/rtexif.h b/rtexif/rtexif.h index c37533352..1a956a4a5 100644 --- a/rtexif/rtexif.h +++ b/rtexif/rtexif.h @@ -163,14 +163,14 @@ public: // Try to get the Tag in the current directory and in subdirectories // if lookUpward = true, it will scan the parents TagDirectory up to the root one, // but w/o looking into their subdirs - virtual Tag* findTag (const char* name, bool lookUpward = false) const; + Tag* findTag (const char* name, bool lookUpward = false) const; // Find a all Tags with the given name by scanning the whole tag tree std::vector findTags (const char* name); // Find a all Tags with the given ID by scanning the whole tag tree std::vector findTags (int ID); // Try to get the Tag in the current directory and in parent directories // (won't look into subdirs) - virtual Tag* findTagUpward (const char* name) const; + Tag* findTagUpward (const char* name) const; bool getXMPTagValue (const char* name, char* value) const; void keepTag (int ID); @@ -191,10 +191,10 @@ public: virtual TagDirectory* clone (TagDirectory* parent) const; void applyChange (const std::string &field, const Glib::ustring &value); - virtual void printAll (unsigned int level = 0) const; // reentrant debug function, keep level=0 on first call ! - virtual bool CPBDump (const Glib::ustring &commFName, const Glib::ustring &imageFName, const Glib::ustring &profileFName, const Glib::ustring &defaultPParams, + void printAll (unsigned int level = 0) const; // reentrant debug function, keep level=0 on first call ! + bool CPBDump (const Glib::ustring &commFName, const Glib::ustring &imageFName, const Glib::ustring &profileFName, const Glib::ustring &defaultPParams, const CacheImageData* cfs, const bool flagMode, Glib::KeyFile *keyFile = nullptr, Glib::ustring tagDirName = "") const; - virtual void sort (); + void sort (); }; // a table of tags: id are offset from beginning and not identifiers diff --git a/rtexif/sonyminoltaattribs.cc b/rtexif/sonyminoltaattribs.cc index 61223edf0..88251b131 100644 --- a/rtexif/sonyminoltaattribs.cc +++ b/rtexif/sonyminoltaattribs.cc @@ -15,8 +15,6 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#ifndef _SONYMINOLTAATTRIBS_ -#define _SONYMINOLTAATTRIBS_ #include @@ -541,7 +539,7 @@ public: }; SAAntiBlurInterpreter saAntiBlurInterpreter; -class SALensIDInterpreter : public IntLensInterpreter +class SALensIDInterpreter final : public IntLensInterpreter { public: SALensIDInterpreter () @@ -1015,7 +1013,7 @@ public: }; SALensIDInterpreter saLensIDInterpreter; -class SALensID2Interpreter : public IntLensInterpreter< int > +class SALensID2Interpreter final : public IntLensInterpreter< int > { public: SALensID2Interpreter () @@ -2116,7 +2114,7 @@ public: // Decode the value if (a && a != 254) { // 254 = 'Auto' for CameraSettings3, but we might say the same for CameraSettings & CameraSettings2 (?) - return int (expf ((double (a) / 8.f - 6.f) * logf (2.f)) * 100.f + 0.5f); + return std::exp((a / 8.f - 6.f) * std::log(2.f)) * 100.f + 0.5f; } else { return 0; } @@ -2499,6 +2497,4 @@ const TagAttrib sonyCameraSettingsAttribs3[] = { {-1, AC_DONTWRITE, 0, 0, 0, AUTO, "", NULL}};*/ } -#endif - diff --git a/rtexif/stdattribs.cc b/rtexif/stdattribs.cc index 8e076152d..be7a28a5c 100644 --- a/rtexif/stdattribs.cc +++ b/rtexif/stdattribs.cc @@ -17,8 +17,6 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#ifndef _STDATTRIBS_ -#define _STDATTRIBS_ #include #include @@ -927,5 +925,3 @@ const TagAttrib ifdAttribs[] = { { -1, AC_DONTWRITE, 0, nullptr, 0, AUTO, "", nullptr} }; } - -#endif diff --git a/rtgui/adjuster.h b/rtgui/adjuster.h index 59250bc81..143268786 100644 --- a/rtgui/adjuster.h +++ b/rtgui/adjuster.h @@ -33,7 +33,7 @@ public: typedef double(*double2double_fun)(double val); -class Adjuster : public Gtk::Grid +class Adjuster final : public Gtk::Grid { protected: diff --git a/rtgui/batchqueueentry.h b/rtgui/batchqueueentry.h index c4cd48615..f06b65046 100644 --- a/rtgui/batchqueueentry.h +++ b/rtgui/batchqueueentry.h @@ -50,7 +50,7 @@ struct BatchQueueEntryIdleHelper { int pending; }; -class BatchQueueEntry : public ThumbBrowserEntryBase, public BQEntryUpdateListener, public rtengine::NonCopyable +class BatchQueueEntry final : public ThumbBrowserEntryBase, public BQEntryUpdateListener, public rtengine::NonCopyable { guint8* opreview; diff --git a/rtgui/batchtoolpanelcoord.h b/rtgui/batchtoolpanelcoord.h index 7a5fe77ed..ea11f97c8 100644 --- a/rtgui/batchtoolpanelcoord.h +++ b/rtgui/batchtoolpanelcoord.h @@ -28,7 +28,7 @@ class FilePanel; class Thumbnail; -class BatchToolPanelCoordinator : +class BatchToolPanelCoordinator final : public ToolPanelCoordinator, public FileSelectionChangeListener, public BatchPParamsChangeListener, diff --git a/rtgui/blackwhite.cc b/rtgui/blackwhite.cc index 596d99607..ea493d6e1 100644 --- a/rtgui/blackwhite.cc +++ b/rtgui/blackwhite.cc @@ -70,7 +70,7 @@ BlackWhite::BlackWhite (): FoldableToolPanel(this, "blackwhite", M("TP_BWMIX_LAB // -0.1 rad < Hue < 1.6 rad for (int i = 0; i < 7; i++) { - float x = float(i) * (1.0f / 6.0); + float x = float(i) * (1.0f / 6.f); Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); bottomMilestones.push_back( GradientMilestone(double(x), double(R), double(G), double(B)) ); } @@ -1185,10 +1185,10 @@ void BlackWhite::updateRGBLabel () RGBLabels->set_text( Glib::ustring::compose(M("TP_BWMIX_RGBLABEL"), - Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.), - Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.), - Glib::ustring::format(std::fixed, std::setprecision(1), b * 100.), - Glib::ustring::format(std::fixed, std::setprecision(0), ceil(kcorrec * 100./*(r+g+b)*100.)*/))) + Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.f), + Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.f), + Glib::ustring::format(std::fixed, std::setprecision(1), b * 100.f), + Glib::ustring::format(std::fixed, std::setprecision(0), ceil(kcorrec * 100.f/*(r+g+b)*100.)*/))) ); // We have to update the RGB sliders too if preset values has been chosen diff --git a/rtgui/cachemanager.cc b/rtgui/cachemanager.cc index c37964e23..93dafc1ba 100644 --- a/rtgui/cachemanager.cc +++ b/rtgui/cachemanager.cc @@ -39,7 +39,7 @@ namespace { constexpr int cacheDirMode = 0777; -constexpr const char* cacheDirs[] = { "profiles", "images", "aehistograms", "embprofiles", "data" }; +constexpr const char* cacheDirs[] = { "profiles", "images", "embprofiles", "data" }; } @@ -59,9 +59,7 @@ void CacheManager::init () auto error = g_mkdir_with_parents (baseDir.c_str(), cacheDirMode); for (const auto& cacheDir : cacheDirs) { - if (strncmp(cacheDir, "aehistograms", 12)) { // don't create aehistograms folder. - error |= g_mkdir_with_parents (Glib::build_filename (baseDir, cacheDir).c_str(), cacheDirMode); - } + error |= g_mkdir_with_parents (Glib::build_filename (baseDir, cacheDir).c_str(), cacheDirMode); } if (error != 0 && rtengine::settings->verbose) { @@ -187,7 +185,6 @@ void CacheManager::renameEntry (const std::string& oldfilename, const std::strin auto error = g_rename (getCacheFileName ("profiles", oldfilename, paramFileExtension, oldmd5).c_str (), getCacheFileName ("profiles", newfilename, paramFileExtension, newmd5).c_str ()); error |= g_rename (getCacheFileName ("images", oldfilename, ".rtti", oldmd5).c_str (), getCacheFileName ("images", newfilename, ".rtti", newmd5).c_str ()); - error |= g_rename (getCacheFileName ("aehistograms", oldfilename, "", oldmd5).c_str (), getCacheFileName ("aehistograms", newfilename, "", newmd5).c_str ()); error |= g_rename (getCacheFileName ("embprofiles", oldfilename, ".icc", oldmd5).c_str (), getCacheFileName ("embprofiles", newfilename, ".icc", newmd5).c_str ()); error |= g_rename (getCacheFileName ("data", oldfilename, ".txt", oldmd5).c_str (), getCacheFileName ("data", newfilename, ".txt", newmd5).c_str ()); @@ -241,7 +238,6 @@ void CacheManager::clearImages () const deleteDir ("data"); deleteDir ("images"); - deleteDir ("aehistograms"); deleteDir ("embprofiles"); } @@ -277,7 +273,6 @@ void CacheManager::deleteFiles (const Glib::ustring& fname, const std::string& m } auto error = g_remove (getCacheFileName ("images", fname, ".rtti", md5).c_str ()); - error |= g_remove (getCacheFileName ("aehistograms", fname, "", md5).c_str ()); error |= g_remove (getCacheFileName ("embprofiles", fname, ".icc", md5).c_str ()); if (purgeData) { diff --git a/rtgui/colorappearance.cc b/rtgui/colorappearance.cc index 62f6eee2c..9468770fc 100644 --- a/rtgui/colorappearance.cc +++ b/rtgui/colorappearance.cc @@ -523,7 +523,7 @@ ColorAppearance::ColorAppearance () : FoldableToolPanel (this, "colorappearance" float R, G, B; for (int i = 0; i < 7; i++) { - float x = float (i) * (1.0f / 6.0); + float x = float (i) * (1.0f / 6.f); Color::hsv2rgb01 (x, 0.5f, 0.5f, R, G, B); shape3Milestones.push_back ( GradientMilestone (double (x), double (R), double (G), double (B)) ); } diff --git a/rtgui/coloredbar.h b/rtgui/coloredbar.h index 6cc121cd5..69cfa47d1 100644 --- a/rtgui/coloredbar.h +++ b/rtgui/coloredbar.h @@ -30,7 +30,7 @@ * the bar itself, i.e. use render_background (depending on its Gtk::Style) * */ -class ColoredBar : private BackBuffer, public ColorCaller +class ColoredBar final : private BackBuffer, public ColorCaller { private: diff --git a/rtgui/colortoning.cc b/rtgui/colortoning.cc index 59768a6ce..ddf917149 100644 --- a/rtgui/colortoning.cc +++ b/rtgui/colortoning.cc @@ -74,7 +74,7 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR // whole hue range for (int i = 0; i < 7; i++) { float R, G, B; - float x = float(i) * (1.0f / 6.0); + float x = float(i) * (1.0f / 6.f); Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); milestones.push_back( GradientMilestone(double(x), double(R), double(G), double(B)) ); } @@ -1203,11 +1203,11 @@ void ColorToning::colorForValue (double valX, double valY, enum ColorCaller::Ele // the strength applied to the current hue double strength, hue; hlColSat->getValue(strength, hue); - Color::hsv2rgb01(hue / 360.f, 1.f, 1.f, R, G, B); + Color::hsv2rgb01(hue / 360.0, 1.f, 1.f, R, G, B); const double gray = 0.46; - R = (gray * (1.0 - valX)) + R * valX; - G = (gray * (1.0 - valX)) + G * valX; - B = (gray * (1.0 - valX)) + B * valX; + R = (gray * (1.0 - valX)) + static_cast(R) * valX; + G = (gray * (1.0 - valX)) + static_cast(G) * valX; + B = (gray * (1.0 - valX)) + static_cast(B) * valX; } } else if (callerId == 3) { // Slider 2 background if (valY <= 0.5) @@ -1218,17 +1218,17 @@ void ColorToning::colorForValue (double valX, double valY, enum ColorCaller::Ele // the strength applied to the current hue double strength, hue; shadowsColSat->getValue(strength, hue); - Color::hsv2rgb01(hue / 360.f, 1.f, 1.f, R, G, B); + Color::hsv2rgb01(hue / 360.0, 1.f, 1.f, R, G, B); const double gray = 0.46; - R = (gray * (1.0 - valX)) + R * valX; - G = (gray * (1.0 - valX)) + G * valX; - B = (gray * (1.0 - valX)) + B * valX; + R = (gray * (1.0 - valX)) + static_cast(R) * valX; + G = (gray * (1.0 - valX)) + static_cast(G) * valX; + B = (gray * (1.0 - valX)) + static_cast(B) * valX; } } else if (callerId == 4) { // color curve vertical and horizontal crosshair Color::hsv2rgb01(float(valY), 1.0f, 0.5f, R, G, B); } else if (callerId == ID_LABREGION_HUE) { // TODO - float x = valX - 1.f/6.f; + float x = valX - 1.0/6.0; if (x < 0.f) { x += 1.f; } diff --git a/rtgui/coordinateadjuster.cc b/rtgui/coordinateadjuster.cc index ebf36b7e7..57190cf63 100644 --- a/rtgui/coordinateadjuster.cc +++ b/rtgui/coordinateadjuster.cc @@ -69,14 +69,14 @@ void CoordinateAdjuster::AxisAdjuster::setValue(double newValue) { float range = rangeUpperBound - rangeLowerBound; spinButtonConn.block(true); - spinButton->set_value(newValue * range + rangeLowerBound); + spinButton->set_value(static_cast(newValue) * range + rangeLowerBound); spinButtonConn.block(false); } void CoordinateAdjuster::AxisAdjuster::valueChanged() { float range = rangeUpperBound - rangeLowerBound; - parent->updatePos(idx, (spinButton->get_value() - rangeLowerBound) / range); + parent->updatePos(idx, (static_cast(spinButton->get_value()) - rangeLowerBound) / range); } CoordinateAdjuster::CoordinateAdjuster(CoordinateProvider *provider, CurveEditorSubGroup *parent, const std::vector &axis) @@ -171,7 +171,7 @@ void CoordinateAdjuster::startNumericalAdjustment(const std::vector Gtk::SpinButton *currSpinButton = axisAdjusters.at(i)->spinButton; currSpinButton->set_sensitive(true); float range = axisAdjusters.at(i)->rangeUpperBound - axisAdjusters.at(i)->rangeLowerBound; - currSpinButton->set_range(newBoundaries.at(i).minVal * range + axisAdjusters.at(i)->rangeLowerBound, newBoundaries.at(i).maxVal * range + axisAdjusters.at(i)->rangeLowerBound); + currSpinButton->set_range(newBoundaries.at(i).minVal * static_cast(range) + static_cast(axisAdjusters.at(i)->rangeLowerBound), newBoundaries.at(i).maxVal * static_cast(range) + static_cast(axisAdjusters.at(i)->rangeLowerBound)); } axisAdjusters.at(0)->spinButton->grab_focus(); @@ -200,7 +200,7 @@ void CoordinateAdjuster::switchAdjustedPoint(std::vector &pos, const std // ...narrow the range to the new interval float range = axisAdjusters.at(i)->rangeUpperBound - axisAdjusters.at(i)->rangeLowerBound; - currAxis->spinButton->set_range(newBoundaries.at(i).minVal * range + axisAdjusters.at(i)->rangeLowerBound, newBoundaries.at(i).maxVal * range + axisAdjusters.at(i)->rangeLowerBound); + currAxis->spinButton->set_range(newBoundaries.at(i).minVal * static_cast(range) + static_cast(axisAdjusters.at(i)->rangeLowerBound), newBoundaries.at(i).maxVal * static_cast(range) + static_cast(axisAdjusters.at(i)->rangeLowerBound)); // enable events currAxis->spinButtonConn.block(false); diff --git a/rtgui/coordinateadjuster.h b/rtgui/coordinateadjuster.h index 70fe42233..24edc707a 100644 --- a/rtgui/coordinateadjuster.h +++ b/rtgui/coordinateadjuster.h @@ -69,7 +69,7 @@ public: * * The position of the Axis in the vector will be used in the communication between the Adjuster and the Provider to identify the Axis */ -class CoordinateAdjuster : public Gtk::FlowBox +class CoordinateAdjuster final : public Gtk::FlowBox { public: diff --git a/rtgui/crop.cc b/rtgui/crop.cc index 3bdcf14cf..d9d496523 100644 --- a/rtgui/crop.cc +++ b/rtgui/crop.cc @@ -1006,7 +1006,7 @@ void Crop::cropWidth1Resized (int &X, int &Y, int &W, int &H, float custom_ratio } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0.f ? custom_ratio : static_cast(getRatio()); H = (int)round(W / r); int Hmax = min(ny + nh, maxh - ny); @@ -1053,7 +1053,7 @@ void Crop::cropWidth2Resized (int &X, int &Y, int &W, int &H, float custom_ratio } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); H = (int)round(W / r); int Hmax = min(ny + nh, maxh - ny); @@ -1101,7 +1101,7 @@ void Crop::cropHeight1Resized (int &X, int &Y, int &W, int &H, float custom_rati } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); W = (int)round(H * r); int Wmax = min(nx + nw, maxw - nx); @@ -1148,7 +1148,7 @@ void Crop::cropHeight2Resized (int &X, int &Y, int &W, int &H, float custom_rati } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); W = (int)round(H * r); int Wmax = min(nx + nw, maxw - nx); @@ -1205,7 +1205,7 @@ void Crop::cropTopLeftResized (int &X, int &Y, int &W, int &H, float custom_rati } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); W = (int)round(H * r); if (W > oldXR) { @@ -1252,7 +1252,7 @@ void Crop::cropTopRightResized (int &X, int &Y, int &W, int &H, float custom_rat } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); W = (int)round(H * r); if (W > maxw - nx) { @@ -1298,7 +1298,7 @@ void Crop::cropBottomLeftResized (int &X, int &Y, int &W, int &H, float custom_r } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); W = (int)round(H * r); if (W > oldXR) { @@ -1342,7 +1342,7 @@ void Crop::cropBottomRightResized (int &X, int &Y, int &W, int &H, float custom_ } if (fixr->get_active() || custom_ratio > 0) { - double r = custom_ratio > 0 ? custom_ratio : getRatio(); + double r = custom_ratio > 0 ? custom_ratio : static_cast(getRatio()); W = (int)round(H * r); if (W > maxw - nx) { diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index 0a9b81112..d87876cec 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -37,6 +37,7 @@ #include "rtsurface.h" #include "../rtengine/dcrop.h" +#include "../rtengine/imagesource.h" #include "../rtengine/procparams.h" #include "../rtengine/rt_math.h" @@ -123,7 +124,7 @@ void CropWindow::initZoomSteps() zoomSteps.push_back(ZoomStep(" 8%", 1.0/12.0, 120, true)); char lbl[64]; for (int s = 100; s >= 11; --s) { - float z = 10./float(s); + float z = 10.f / s; sprintf(lbl, "% 2d%%", int(z * 100)); bool is_major = (s == s/10 * 10); zoomSteps.push_back(ZoomStep(lbl, z, s, is_major)); @@ -294,7 +295,7 @@ void CropWindow::flawnOver (bool isFlawnOver) void CropWindow::scroll (int state, GdkScrollDirection direction, int x, int y, double deltaX, double deltaY) { double delta = 0.0; - if (abs(deltaX) > abs(deltaY)) { + if (std::fabs(deltaX) > std::fabs(deltaY)) { delta = deltaX; } else { delta = deltaY; @@ -303,7 +304,7 @@ void CropWindow::scroll (int state, GdkScrollDirection direction, int x, int y, if (direction == GDK_SCROLL_SMOOTH) { scrollAccum += delta; //Only change zoom level if we've accumulated +/- 1.0 of deltas. This conditional handles the previous delta=0.0 case - if (abs(scrollAccum) < 1.0) { + if (std::fabs(scrollAccum) < 1.0) { return; } } diff --git a/rtgui/cropwindow.h b/rtgui/cropwindow.h index 491124ad5..623653d2d 100644 --- a/rtgui/cropwindow.h +++ b/rtgui/cropwindow.h @@ -54,7 +54,7 @@ public: }; class ImageArea; -class CropWindow : public LWButtonListener, public CropDisplayHandler, public EditCoordSystem, public ObjectMOBuffer, public rtengine::NonCopyable +class CropWindow final : public LWButtonListener, public CropDisplayHandler, public EditCoordSystem, public ObjectMOBuffer, public rtengine::NonCopyable { static bool initialized; diff --git a/rtgui/curveeditor.h b/rtgui/curveeditor.h index baae8f492..abc0cc10a 100644 --- a/rtgui/curveeditor.h +++ b/rtgui/curveeditor.h @@ -18,8 +18,8 @@ */ #pragma once -#include "coloredbar.h" #include "editcallbacks.h" +#include "guiutils.h" #include "../rtengine/diagonalcurvetypes.h" #include "../rtengine/flatcurvetypes.h" @@ -28,6 +28,7 @@ class CurveEditorGroup; class CurveEditorSubGroup; +class ColorProvider; class PopUpToggleButton; /* diff --git a/rtgui/defringe.cc b/rtgui/defringe.cc index cdec88edc..7aae8377a 100644 --- a/rtgui/defringe.cc +++ b/rtgui/defringe.cc @@ -37,7 +37,7 @@ Defringe::Defringe () : FoldableToolPanel(this, "defringe", M("TP_DEFRINGE_LABEL float R, G, B; for (int i = 0; i < 7; i++) { - float x = float(i) * (1.0f / 6.0); + float x = i / 6.f; Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); bottomMilestones.push_back( GradientMilestone(double(x), double(R), double(G), double(B)) ); } diff --git a/rtgui/diagonalcurveeditorsubgroup.cc b/rtgui/diagonalcurveeditorsubgroup.cc index eed6c63d3..079a083ea 100644 --- a/rtgui/diagonalcurveeditorsubgroup.cc +++ b/rtgui/diagonalcurveeditorsubgroup.cc @@ -477,13 +477,13 @@ void DiagonalCurveEditorSubGroup::pipetteMouseOver(EditDataProvider *provider, i double pos[3]; shcSelector->getPositions(pos[0], pos[1], pos[2]); - if (pipetteVal >= pos[2]) { + if (static_cast(pipetteVal) >= pos[2]) { editedAdjuster = highlights; paramCurve->setActiveParam(4); - } else if(pipetteVal >= pos[1]) { + } else if(static_cast(pipetteVal) >= pos[1]) { editedAdjuster = lights; paramCurve->setActiveParam(5); - } else if(pipetteVal >= pos[0]) { + } else if(static_cast(pipetteVal) >= pos[0]) { editedAdjuster = darks; paramCurve->setActiveParam(6); } else { diff --git a/rtgui/diagonalcurveeditorsubgroup.h b/rtgui/diagonalcurveeditorsubgroup.h index a077da807..9b1f67462 100644 --- a/rtgui/diagonalcurveeditorsubgroup.h +++ b/rtgui/diagonalcurveeditorsubgroup.h @@ -27,7 +27,7 @@ class DiagonalCurveEditor; class MyDiagonalCurve; -class DiagonalCurveEditorSubGroup : +class DiagonalCurveEditorSubGroup final : public CurveEditorSubGroup, public SHCListener, public AdjusterListener, diff --git a/rtgui/dirpyrequalizer.cc b/rtgui/dirpyrequalizer.cc index fd0268efa..34aecf095 100644 --- a/rtgui/dirpyrequalizer.cc +++ b/rtgui/dirpyrequalizer.cc @@ -428,7 +428,7 @@ void DirPyrEqualizer::lumacontrastPlusPressed () { for (int i = 0; i < 6; i++) { - float inc = 0.05 * (6 - i); + double inc = 0.05 * (6 - i); multiplier[i]->setValue(multiplier[i]->getValue() + inc); adjusterChanged(multiplier[i], multiplier[i]->getValue()); } @@ -439,7 +439,7 @@ void DirPyrEqualizer::lumacontrastMinusPressed () { for (int i = 0; i < 6; i++) { - float inc = -0.05 * (6 - i); + double inc = -0.05 * (6 - i); multiplier[i]->setValue(multiplier[i]->getValue() + inc); adjusterChanged(multiplier[i], multiplier[i]->getValue()); } diff --git a/rtgui/editcallbacks.h b/rtgui/editcallbacks.h index c2efcf53e..ee357c2f7 100644 --- a/rtgui/editcallbacks.h +++ b/rtgui/editcallbacks.h @@ -129,19 +129,19 @@ public: @param picked True if the cursor is still above the the same object than on button pressed and with the same modifier keys. If false, the user moved the cursor away or the modifier key is different, so the element is considered as NOT selected. @return true if the preview has to be redrawn, false otherwise */ - virtual bool pick1 (bool picked); + bool pick1 (bool picked); /** @brief Triggered when the user is releasing mouse button 2 while in action==ES_ACTION_PICKING mode @param picked True if the cursor is still above the the same object than on button pressed and with the same modifier keys. If false, the user moved the cursor away or the modifier key is different, so the element is considered as NOT selected. @return true if the preview has to be redrawn, false otherwise */ - virtual bool pick2 (bool picked); + bool pick2 (bool picked); /** @brief Triggered when the user is releasing mouse button 3 while in action==ES_ACTION_PICKING mode @param picked True if the cursor is still above the the same object than on button pressed and with the same modifier keys. If false, the user moved the cursor away or the modifier key is different, so the element is considered as NOT selected. @return true if the preview has to be redrawn, false otherwise */ - virtual bool pick3 (bool picked); + bool pick3 (bool picked); /** @brief Get the geometry to be shown to the user */ const std::vector& getVisibleGeometry (); diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 806af8b2e..6a0d41878 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -61,7 +61,7 @@ void setprogressStrUI(double val, const Glib::ustring str, MyProgressBar* pProgr } } - +#if !defined(__APPLE__) // monitor profile not supported on apple bool find_default_monitor_profile (GdkWindow *rootwin, Glib::ustring &defprof, Glib::ustring &defprofname) { #ifdef WIN32 @@ -91,7 +91,7 @@ bool find_default_monitor_profile (GdkWindow *rootwin, Glib::ustring &defprof, G ReleaseDC (NULL, hDC); } -#elif !defined(__APPLE__) +#else // taken from geeqie (image.c) and adapted // Originally licensed as GPL v2+, with the following copyright: // * Copyright (C) 2006 John Ellis @@ -129,7 +129,7 @@ bool find_default_monitor_profile (GdkWindow *rootwin, Glib::ustring &defprof, G #endif return false; } - +#endif } diff --git a/rtgui/editwidgets.cc b/rtgui/editwidgets.cc index f7c748744..e67b664db 100644 --- a/rtgui/editwidgets.cc +++ b/rtgui/editwidgets.cc @@ -126,13 +126,13 @@ void Circle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer if (filled && state != INSENSITIVE) { cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*rtengine::RT_PI); - if (innerLineWidth > 0.) { + if (innerLineWidth > 0.f) { cr->fill_preserve(); cr->stroke(); } else { cr->fill(); } - } else if (innerLineWidth > 0.) { + } else if (innerLineWidth > 0.f) { cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*rtengine::RT_PI); if (state == INSENSITIVE) { @@ -176,7 +176,7 @@ void Circle::drawToMOChannel (Cairo::RefPtr &cr, unsigned short cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0, 2.*rtengine::RT_PI); if (filled) { - if (innerLineWidth > 0.) { + if (innerLineWidth > 0.f) { cr->fill_preserve(); cr->stroke(); } else { @@ -224,7 +224,7 @@ void Line::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuffer * void Line::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { - if ((flags & F_VISIBLE) && innerLineWidth > 0.) { + if ((flags & F_VISIBLE) && innerLineWidth > 0.f) { if (state != INSENSITIVE) { RGBColor color; @@ -383,13 +383,13 @@ void Polyline::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuff } } - if (innerLineWidth > 0.) { + if (innerLineWidth > 0.f) { cr->fill_preserve(); cr->stroke(); } else { cr->fill(); } - } else if (innerLineWidth > 0.) { + } else if (innerLineWidth > 0.f) { rtengine::Coord currPos; for (unsigned int i = 0; i < points.size(); ++i) { @@ -459,7 +459,7 @@ void Polyline::drawToMOChannel (Cairo::RefPtr &cr, unsigned shor } if (filled) { - if (innerLineWidth > 0.) { + if (innerLineWidth > 0.f) { cr->fill_preserve(); cr->stroke(); } else { @@ -576,13 +576,13 @@ void Rectangle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuf if (filled && state != INSENSITIVE) { cr->rectangle(tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); - if (innerLineWidth > 0.) { + if (innerLineWidth > 0.f) { cr->fill_preserve(); cr->stroke(); } else { cr->fill(); } - } else if (innerLineWidth > 0.) { + } else if (innerLineWidth > 0.f) { cr->rectangle(tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); if (state == INSENSITIVE) { @@ -634,7 +634,7 @@ void Rectangle::drawToMOChannel(Cairo::RefPtr &cr, unsigned shor cr->rectangle(tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y); if (filled) { - if (innerLineWidth > 0.) { + if (innerLineWidth > 0.f) { cr->fill_preserve(); cr->stroke(); } else { diff --git a/rtgui/exifpanel.h b/rtgui/exifpanel.h index 0894c21ad..d336d83f9 100644 --- a/rtgui/exifpanel.h +++ b/rtgui/exifpanel.h @@ -25,7 +25,7 @@ #include "toolpanel.h" #include "../rtexif/rtexif.h" -class ExifPanel : +class ExifPanel final : public Gtk::VBox, public ToolPanel { diff --git a/rtgui/filebrowser.h b/rtgui/filebrowser.h index 86ab59395..53f3f1f2b 100644 --- a/rtgui/filebrowser.h +++ b/rtgui/filebrowser.h @@ -56,7 +56,7 @@ public: /* * Class handling actions common to all thumbnails of the file browser */ -class FileBrowser : public ThumbBrowserBase, +class FileBrowser final : public ThumbBrowserBase, public LWButtonListener, public ExportPanelListener, public ProfileStoreListener, diff --git a/rtgui/filebrowserentry.h b/rtgui/filebrowserentry.h index ea5140ed6..67b953514 100644 --- a/rtgui/filebrowserentry.h +++ b/rtgui/filebrowserentry.h @@ -43,7 +43,7 @@ struct FileBrowserEntryIdleHelper { }; class FileThumbnailButtonSet; -class FileBrowserEntry : public ThumbBrowserEntryBase, +class FileBrowserEntry final : public ThumbBrowserEntryBase, public ThumbnailListener, public ThumbImageUpdateListener, public rtengine::NonCopyable diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index bb34072e2..102c17daf 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -45,8 +45,6 @@ using namespace std; -#define CHECKTIME 2000 - FileCatalog::FileCatalog (CoarsePanel* cp, ToolBar* tb, FilePanel* filepanel) : filepanel(filepanel), selectedDirectoryId(1), diff --git a/rtgui/filecatalog.h b/rtgui/filecatalog.h index 10f2bc88f..194153921 100644 --- a/rtgui/filecatalog.h +++ b/rtgui/filecatalog.h @@ -43,7 +43,7 @@ class ToolBar; * - handling the thumbnail toolbar, * - monitoring the directory (for any change) */ -class FileCatalog : public Gtk::VBox, +class FileCatalog final : public Gtk::VBox, public PreviewLoaderListener, public FilterPanelListener, public FileBrowserListener, diff --git a/rtgui/flatcurveeditorsubgroup.h b/rtgui/flatcurveeditorsubgroup.h index c358dde3b..865a0ef83 100644 --- a/rtgui/flatcurveeditorsubgroup.h +++ b/rtgui/flatcurveeditorsubgroup.h @@ -27,7 +27,7 @@ class FlatCurveEditor; class MyFlatCurve; -class FlatCurveEditorSubGroup: +class FlatCurveEditorSubGroup final : public CurveEditorSubGroup, public rtengine::NonCopyable { diff --git a/rtgui/gradient.cc b/rtgui/gradient.cc index 4f389e112..b46f8e1ca 100644 --- a/rtgui/gradient.cc +++ b/rtgui/gradient.cc @@ -164,7 +164,7 @@ void Gradient::updateGeometry(const int centerX, const int centerY, const double const auto decay = feather * rtengine::norm2 (imW, imH) / 200.0; rtengine::Coord origin (imW / 2 + centerX * imW / 200, imH / 2 + centerY * imH / 200); - const auto updateLine = [&](Geometry* geometry, const float radius, const float begin, const float end) + const auto updateLine = [&](Geometry* geometry, const double radius, const double begin, const double end) { const auto line = static_cast(geometry); line->begin = PolarCoord(radius, -degree + begin); @@ -173,7 +173,7 @@ void Gradient::updateGeometry(const int centerX, const int centerY, const double line->end += origin; }; - const auto updateLineWithDecay = [&](Geometry* geometry, const float radius, const float offSetAngle) + const auto updateLineWithDecay = [&](Geometry* geometry, const double radius, const double offSetAngle) { const auto line = static_cast(geometry); line->begin = PolarCoord (radius, -degree + 180.) + PolarCoord (decay, -degree + offSetAngle); diff --git a/rtgui/guiutils.cc b/rtgui/guiutils.cc index 02a28607f..d759751c3 100644 --- a/rtgui/guiutils.cc +++ b/rtgui/guiutils.cc @@ -20,7 +20,6 @@ #include "guiutils.h" #include "options.h" -#include "../rtengine/rt_math.h" #include "../rtengine/utils.h" #include "../rtengine/procparams.h" #include "rtimage.h" @@ -827,12 +826,6 @@ void MyExpander::set_expanded( bool expanded ) return; } - bool isVisible = expBox->is_visible(); - - if (isVisible == expanded) { - return; - } - if (!useEnabled) { if (expanded ) { statusImage->set(openedImage->get_surface()); diff --git a/rtgui/guiutils.h b/rtgui/guiutils.h index 97c72513b..d4c91734a 100644 --- a/rtgui/guiutils.h +++ b/rtgui/guiutils.h @@ -92,7 +92,7 @@ private: * } * */ -class GThreadLock +class GThreadLock final { public: GThreadLock() @@ -110,7 +110,7 @@ public: * * Will relock on destruction. */ -class GThreadUnLock +class GThreadUnLock final { public: GThreadUnLock() @@ -125,7 +125,7 @@ public: #pragma GCC diagnostic pop -class ConnectionBlocker +class ConnectionBlocker final { public: explicit ConnectionBlocker (Gtk::Widget *associatedWidget, sigc::connection& connection) : connection (associatedWidget ? &connection : nullptr), wasBlocked(false) @@ -152,7 +152,7 @@ private: /** * @brief Glue box to control visibility of the MyExpender's content ; also handle the frame around it */ -class ExpanderBox: public Gtk::EventBox +class ExpanderBox final : public Gtk::EventBox { private: Gtk::Container *pC; @@ -185,7 +185,7 @@ public: * * Warning: once you've instantiated this class with a text label or a widget label, you won't be able to revert to the other solution. */ -class MyExpander : public Gtk::VBox +class MyExpander final : public Gtk::VBox { public: typedef sigc::signal type_signal_enabled_toggled; @@ -295,7 +295,7 @@ public: /** * @brief subclass of Gtk::ScrolledWindow in order to handle the scrollwheel */ -class MyScrolledWindow : public Gtk::ScrolledWindow +class MyScrolledWindow final : public Gtk::ScrolledWindow { bool on_scroll_event (GdkEventScroll* event) override; @@ -310,7 +310,7 @@ public: /** * @brief subclass of Gtk::ScrolledWindow in order to handle the large toolbars (wider than available space) */ -class MyScrolledToolbar : public Gtk::ScrolledWindow +class MyScrolledToolbar final : public Gtk::ScrolledWindow { bool on_scroll_event (GdkEventScroll* event) override; @@ -340,7 +340,7 @@ public: /** * @brief subclass of Gtk::ComboBoxText in order to handle the scrollwheel */ -class MyComboBoxText : public Gtk::ComboBoxText +class MyComboBoxText final : public Gtk::ComboBoxText { int naturalWidth, minimumWidth; sigc::connection myConnection; @@ -360,7 +360,7 @@ public: /** * @brief subclass of Gtk::SpinButton in order to handle the scrollwheel */ -class MySpinButton : public Gtk::SpinButton +class MySpinButton final : public Gtk::SpinButton { protected: @@ -375,7 +375,7 @@ public: /** * @brief subclass of Gtk::HScale in order to handle the scrollwheel */ -class MyHScale : public Gtk::HScale +class MyHScale final : public Gtk::HScale { bool on_scroll_event (GdkEventScroll* event) override; @@ -385,7 +385,7 @@ class MyHScale : public Gtk::HScale /** * @brief subclass of Gtk::FileChooserButton in order to handle the scrollwheel */ -class MyFileChooserButton: public Gtk::Button { +class MyFileChooserButton final : public Gtk::Button { private: void show_chooser(); @@ -473,14 +473,14 @@ typedef enum RTNav { /** * @brief Handle the switch between text and image to be displayed in the HBox (to be used in a button/toolpanel) */ -class TextOrIcon : public Gtk::HBox +class TextOrIcon final : public Gtk::HBox { public: TextOrIcon (const Glib::ustring &filename, const Glib::ustring &labelTx, const Glib::ustring &tooltipTx); }; -class MyImageMenuItem : public Gtk::MenuItem +class MyImageMenuItem final : public Gtk::MenuItem { private: Gtk::Grid *box; @@ -493,7 +493,7 @@ public: const Gtk::Label* getLabel () const; }; -class MyProgressBar : public Gtk::ProgressBar +class MyProgressBar final : public Gtk::ProgressBar { private: int w; @@ -512,7 +512,7 @@ public: /** * @brief Define a gradient milestone */ -class GradientMilestone +class GradientMilestone final { public: double position; diff --git a/rtgui/histogrampanel.cc b/rtgui/histogrampanel.cc index dd0cbde46..b8338e4e8 100644 --- a/rtgui/histogrampanel.cc +++ b/rtgui/histogrampanel.cc @@ -518,26 +518,26 @@ void HistogramRGBArea::updateBackBuffer (int r, int g, int b, const Glib::ustrin // Luma cc->set_source_rgb(1.0, 1.0, 1.0); if (options.histogramDrawMode < 2) { - cc->move_to(Lab_L * (winw - 3.*s) / 100.0 + 0.5*s, 0); - cc->line_to(Lab_L * (winw - 3.*s) / 100.0 + 0.5*s, winh - 0); + cc->move_to(static_cast(Lab_L) * (winw - 3. * s) / 100.0 + 0.5 * s, 0); + cc->line_to(static_cast(Lab_L) * (winw - 3. * s) / 100.0 + 0.5 * s, winh - 0); } else { - cc->move_to(HistogramScaling::log (100, Lab_L) * (winw - 1.) / 100.0 + 0.5*s, 0); - cc->line_to(HistogramScaling::log (100, Lab_L) * (winw - 1.) / 100.0 + 0.5*s, winh - 0); + cc->move_to(HistogramScaling::log(100, Lab_L) * (winw - 1.) / 100.0 + 0.5 * s, 0); + cc->line_to(HistogramScaling::log(100, Lab_L) * (winw - 1.) / 100.0 + 0.5 * s, winh - 0); } cc->stroke(); } if (needChroma) { // Chroma - float chromaval = sqrt(Lab_a * Lab_a + Lab_b * Lab_b) / 1.8; + double chromaval = sqrt(Lab_a * Lab_a + Lab_b * Lab_b) / 1.8; // float chromaval = sqrt(Lab_a*Lab_a + Lab_b*Lab_b); cc->set_source_rgb(0.9, 0.9, 0.0); if (options.histogramDrawMode < 2) { - cc->move_to(chromaval * (winw - 1.) / 100.0 + 0.5*s, 0); - cc->line_to(chromaval * (winw - 1.) / 100.0 + 0.5*s, winh - 0); + cc->move_to(chromaval * (winw - 1.) / 100.0 + 0.5 * s, 0); + cc->line_to(chromaval * (winw - 1.) / 100.0 + 0.5 * s, winh - 0); } else { - cc->move_to(HistogramScaling::log (100, chromaval) * (winw - 1.) / 100.0 + 0.5*s, 0); - cc->line_to(HistogramScaling::log (100, chromaval) * (winw - 1.) / 100.0 + 0.5*s, winh - 0); + cc->move_to(HistogramScaling::log(100, chromaval) * (winw - 1.) / 100.0 + 0.5 * s, 0); + cc->line_to(HistogramScaling::log(100, chromaval) * (winw - 1.) / 100.0 + 0.5 * s, winh - 0); } cc->stroke(); } @@ -989,7 +989,7 @@ void HistogramArea::drawCurve(Cairo::RefPtr &cr, cr->set_line_width(s); cr->move_to (0, vsize - 1); - scale = scale <= 0.f ? 0.001f : scale; // avoid division by zero and negative values + scale = scale <= 0.0 ? 0.001 : scale; // avoid division by zero and negative values for (int i = 0; i < 256; i++) { double val = data[i] * (double)vsize / scale; diff --git a/rtgui/histogrampanel.h b/rtgui/histogrampanel.h index 4fd21bcc2..cec44ed03 100644 --- a/rtgui/histogrampanel.h +++ b/rtgui/histogrampanel.h @@ -53,7 +53,7 @@ public: double log (double vsize, double val); }; -class HistogramRGBArea : public Gtk::DrawingArea, public BackBuffer, private HistogramScaling, public rtengine::NonCopyable +class HistogramRGBArea final : public Gtk::DrawingArea, public BackBuffer, private HistogramScaling, public rtengine::NonCopyable { private: typedef const double (*TMatrix)[3]; @@ -116,7 +116,7 @@ public: virtual void toggleButtonMode() = 0; }; -class HistogramArea : public Gtk::DrawingArea, public BackBuffer, private HistogramScaling, public rtengine::NonCopyable +class HistogramArea final : public Gtk::DrawingArea, public BackBuffer, private HistogramScaling, public rtengine::NonCopyable { public: typedef sigc::signal type_signal_factor_changed; @@ -174,7 +174,7 @@ private: void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const override; }; -class HistogramPanel : public Gtk::Grid, public PointerMotionListener, public DrawModeListener, public rtengine::NonCopyable +class HistogramPanel final : public Gtk::Grid, public PointerMotionListener, public DrawModeListener, public rtengine::NonCopyable { protected: diff --git a/rtgui/hsvequalizer.cc b/rtgui/hsvequalizer.cc index ee3eb90a7..817ba1f4d 100644 --- a/rtgui/hsvequalizer.cc +++ b/rtgui/hsvequalizer.cc @@ -38,7 +38,7 @@ HSVEqualizer::HSVEqualizer () : FoldableToolPanel(this, "hsvequalizer", M("TP_HS // -0.1 rad < Hue < 1.6 rad for (int i = 0; i < 7; i++) { - float x = float(i) * (1.0f / 6.0); + float x = i / 6.0; Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); bottomMilestones.push_back( GradientMilestone(double(x), double(R), double(G), double(B)) ); } diff --git a/rtgui/iccprofilecreator.h b/rtgui/iccprofilecreator.h index 2cd19e14f..8ee46a71d 100644 --- a/rtgui/iccprofilecreator.h +++ b/rtgui/iccprofilecreator.h @@ -27,7 +27,7 @@ class RTWindow; -class ICCProfileCreator : public Gtk::Dialog, public AdjusterListener +class ICCProfileCreator final : public Gtk::Dialog, public AdjusterListener { private: diff --git a/rtgui/imagearea.h b/rtgui/imagearea.h index 28b52dcd2..586bba7a7 100644 --- a/rtgui/imagearea.h +++ b/rtgui/imagearea.h @@ -34,7 +34,7 @@ class ImageAreaPanel; -class ImageArea : +class ImageArea final : public Gtk::DrawingArea, public CropWindowListener, public EditDataProvider, diff --git a/rtgui/imageareapanel.h b/rtgui/imageareapanel.h index 831371dbb..f52ca9060 100644 --- a/rtgui/imageareapanel.h +++ b/rtgui/imageareapanel.h @@ -22,7 +22,7 @@ class ImageArea; -class ImageAreaPanel : +class ImageAreaPanel final : public Gtk::VBox { diff --git a/rtgui/inspector.h b/rtgui/inspector.h index 8338259bf..1526f90be 100644 --- a/rtgui/inspector.h +++ b/rtgui/inspector.h @@ -40,7 +40,7 @@ public: //~InspectorBuffer(); }; -class Inspector : public Gtk::DrawingArea +class Inspector final : public Gtk::DrawingArea { private: diff --git a/rtgui/iptcpanel.h b/rtgui/iptcpanel.h index 15d117f87..100904d1a 100644 --- a/rtgui/iptcpanel.h +++ b/rtgui/iptcpanel.h @@ -25,7 +25,7 @@ #include "guiutils.h" #include "toolpanel.h" -class IPTCPanel : +class IPTCPanel final : public Gtk::VBox, public ToolPanel { diff --git a/rtgui/labcurve.cc b/rtgui/labcurve.cc index 491b02c4c..5f4febc0a 100644 --- a/rtgui/labcurve.cc +++ b/rtgui/labcurve.cc @@ -203,7 +203,7 @@ LCurve::LCurve () : FoldableToolPanel(this, "labcurves", M("TP_LABCURVE_LABEL"), for (int i = 0; i < 7; i++) { float R, G, B; - float x = float(i) * (1.0f / 6.0); + float x = i / 6.0; Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); milestones.emplace_back(x, R, G, B); } diff --git a/rtgui/labgrid.cc b/rtgui/labgrid.cc index 516dbb825..d8a22b1d9 100644 --- a/rtgui/labgrid.cc +++ b/rtgui/labgrid.cc @@ -209,8 +209,8 @@ bool LabGridArea::on_draw(const ::Cairo::RefPtr &crf) float x, y, z; int ii = i - cells/2; int jj = j - cells/2; - float a = step * (ii + 0.5); - float b = step * (jj + 0.5); + float a = step * (ii + 0.5f); + float b = step * (jj + 0.5f); Color::Lab2XYZ(25000.f, a, b, x, y, z); Color::xyz2srgb(x, y, z, R, G, B); cr->set_source_rgb(R / 65535.f, G / 65535.f, B / 65535.f); @@ -231,10 +231,10 @@ bool LabGridArea::on_draw(const ::Cairo::RefPtr &crf) // drawing the connection line cr->set_antialias(Cairo::ANTIALIAS_DEFAULT); float loa, hia, lob, hib; - loa = .5f * (width + width * low_a); - hia = .5f * (width + width * high_a); - lob = .5f * (height + height * low_b); - hib = .5f * (height + height * high_b); + loa = .5 * (width + width * low_a); + hia = .5 * (width + width * high_a); + lob = .5 * (height + height * low_b); + hib = .5 * (height + height * high_b); cr->set_line_width(2. * double(s)); cr->set_source_rgb(0.6, 0.6, 0.6); cr->move_to(loa, lob); @@ -319,8 +319,8 @@ bool LabGridArea::on_motion_notify_event(GdkEventMotion *event) int height = get_allocated_height() - 2 * inset * s - padding.get_top() - padding.get_bottom(); const float mouse_x = std::min(double(std::max(event->x - inset * s - padding.get_right(), 0.)), double(width)); const float mouse_y = std::min(double(std::max(get_allocated_height() - 1 - event->y - inset * s - padding.get_bottom(), 0.)), double(height)); - const float ma = (2.0 * mouse_x - width) / (float)width; - const float mb = (2.0 * mouse_y - height) / (float)height; + const float ma = (2.f * mouse_x - width) / width; + const float mb = (2.f * mouse_y - height) / height; if (isDragged) { if (litPoint == LOW) { low_a = ma; diff --git a/rtgui/lockablecolorpicker.cc b/rtgui/lockablecolorpicker.cc index 071847424..0a08bb945 100644 --- a/rtgui/lockablecolorpicker.cc +++ b/rtgui/lockablecolorpicker.cc @@ -37,7 +37,7 @@ void LockableColorPicker::updateBackBuffer () int newW, newH; // -------------------- setting some key constants --------------------- - constexpr float circlePadding = 3.f; // keep this value odd + constexpr double circlePadding = 3.0; // keep this value odd constexpr double opacity = 0.62; // --------------------------------------------------------------------- @@ -121,18 +121,18 @@ void LockableColorPicker::updateBackBuffer () bbcr->set_antialias (Cairo::ANTIALIAS_SUBPIXEL); bbcr->set_line_width (0.); - float center = (float)size / 2.f + circlePadding; + double center = static_cast(size) / 2.0 + circlePadding; // black background of the whole color picker bbcr->set_line_width (0.); bbcr->set_source_rgba (0., 0., 0., opacity); - bbcr->arc_negative (center, center, center, 0., (double)rtengine::RT_PI); + bbcr->arc_negative (center, center, center, 0., rtengine::RT_PI); bbcr->line_to (0, 2. * center + textHeight); - bbcr->arc_negative (2. * textPadding, 2. * center + textHeight, 2. * textPadding, (double)rtengine::RT_PI, (double)rtengine::RT_PI / 2.); + bbcr->arc_negative (2. * textPadding, 2. * center + textHeight, 2. * textPadding, rtengine::RT_PI, rtengine::RT_PI / 2.); bbcr->line_to (textWidth, 2. * center + textHeight + 2. * textPadding); - bbcr->arc_negative (textWidth, 2. * center + textHeight, 2. * textPadding, (double)rtengine::RT_PI / 2., 0.); + bbcr->arc_negative (textWidth, 2. * center + textHeight, 2. * textPadding, rtengine::RT_PI / 2., 0.); bbcr->line_to (textWidth + 2. * textPadding, 2. * center + 2. * textPadding); - bbcr->arc_negative (textWidth, 2. * center + 2. * textPadding, 2. * textPadding, 0., (double)rtengine::RT_PI * 1.5); + bbcr->arc_negative (textWidth, 2. * center + 2. * textPadding, 2. * textPadding, 0., rtengine::RT_PI * 1.5); bbcr->line_to (2. * center, 2. * center); bbcr->close_path(); bbcr->set_line_join (Cairo::LINE_JOIN_BEVEL); @@ -222,7 +222,7 @@ void LockableColorPicker::updateBackBuffer () bbcr->set_antialias(Cairo::ANTIALIAS_SUBPIXEL); - float center = (float)size / 2.f + circlePadding; + double center = static_cast(size) / 2. + circlePadding; // light grey circle around the color mark bbcr->arc (center, center, center - circlePadding / 2., 0., 2. * (double)rtengine::RT_PI); diff --git a/rtgui/lockablecolorpicker.h b/rtgui/lockablecolorpicker.h index 77d2e8e9f..baeea41ef 100644 --- a/rtgui/lockablecolorpicker.h +++ b/rtgui/lockablecolorpicker.h @@ -33,7 +33,7 @@ public: virtual void switchPickerVisibility(bool isVisible) = 0; }; -class LockableColorPicker : BackBuffer +class LockableColorPicker final : BackBuffer { public: enum class Size { diff --git a/rtgui/mycurve.cc b/rtgui/mycurve.cc index 7401570c8..d460713fb 100644 --- a/rtgui/mycurve.cc +++ b/rtgui/mycurve.cc @@ -183,7 +183,7 @@ float MyCurve::getVal(LUTf &curve, int x) if (size_t(graphW) == curve.getSize()) { return curve[x]; } else { - return curve.getVal01(float(x) / graphW); + return curve.getVal01(x / graphW); } } diff --git a/rtgui/mydiagonalcurve.cc b/rtgui/mydiagonalcurve.cc index abd339ce0..ac7976b7e 100644 --- a/rtgui/mydiagonalcurve.cc +++ b/rtgui/mydiagonalcurve.cc @@ -358,14 +358,14 @@ void MyDiagonalCurve::draw (int handle) // draw upper and lower bounds if (curve.type == DCT_Parametric && activeParam > 0 && lpoint.getUpperBound() > 1 && upoint.getUpperBound() > 1) { cr->set_source_rgba (1.0, 1.0, 1.0, 0.1); - cr->move_to (graphX, getVal(upoint, 0) * -graphH + graphY); + cr->move_to (graphX, static_cast(getVal(upoint, 0)) * -graphH + graphY); for (int i = 1; i < graphW - 2; ++i) { - cr->line_to ((double)i + graphX, getVal(upoint, i) * -graphH + graphY); + cr->line_to ((double)i + graphX, static_cast(getVal(upoint, i)) * -graphH + graphY); } for (int i = graphW - 3; i >= 0; --i) { - cr->line_to ((double)i + graphX, getVal(lpoint, i) * -graphH + graphY); + cr->line_to ((double)i + graphX, static_cast(getVal(lpoint, i)) * -graphH + graphY); } cr->fill (); @@ -390,21 +390,21 @@ void MyDiagonalCurve::draw (int handle) if (n > 1) { if (pipetteR > -1.f) { cr->set_source_rgba (1., 0., 0., 0.5); // WARNING: assuming that red values are stored in pipetteR, which might not be the case! - cr->move_to (graphX + graphW*pipetteR, graphY + 1. * s); + cr->move_to (graphX + graphW * static_cast(pipetteR), graphY + 1. * s); cr->rel_line_to (0, -graphH - 1. * s); cr->stroke (); } if (pipetteG > -1.f) { cr->set_source_rgba (0., 1., 0., 0.5); // WARNING: assuming that green values are stored in pipetteG, which might not be the case! - cr->move_to (graphX + graphW*pipetteG, graphY + 1. * s); + cr->move_to (graphX + graphW * static_cast(pipetteG), graphY + 1. * s); cr->rel_line_to (0, -graphH - 1. * s); cr->stroke (); } if (pipetteB > -1.f) { cr->set_source_rgba (0., 0., 1., 0.5); // WARNING: assuming that blue values are stored in pipetteB, which might not be the case! - cr->move_to (graphX + graphW*pipetteB, graphY + 1. * s); + cr->move_to (graphX + graphW * static_cast(pipetteB), graphY + 1. * s); cr->rel_line_to (0, -graphH - 1. * s); cr->stroke (); } @@ -414,7 +414,7 @@ void MyDiagonalCurve::draw (int handle) cr->set_line_width (2. * s); c = style->get_color (state); cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue()); - cr->move_to (graphX + graphW*pipetteVal, graphY + 1. * s); + cr->move_to (graphX + graphW * static_cast(pipetteVal), graphY + 1. * s); cr->rel_line_to (0, -graphH - 1. * s); cr->stroke (); cr->set_line_width (1. * s); @@ -460,7 +460,7 @@ void MyDiagonalCurve::draw (int handle) // draw curve cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue()); - cr->move_to (graphX, getVal(point, 0) * -graphH + graphY); + cr->move_to (graphX, static_cast(getVal(point, 0)) * -graphH + graphY); for (int i = 1; i < graphW; ++i) { cr->line_to ((double)i + graphX, (double)getVal(point, i) * -graphH + graphY); diff --git a/rtgui/mydiagonalcurve.h b/rtgui/mydiagonalcurve.h index b38373006..b2b83c02e 100644 --- a/rtgui/mydiagonalcurve.h +++ b/rtgui/mydiagonalcurve.h @@ -41,7 +41,7 @@ public: std::vector x, y; // in case of parametric curves the curve parameters are stored in vector x. In other cases these vectors store the coordinates of the bullets. }; -class MyDiagonalCurve : public MyCurve +class MyDiagonalCurve final : public MyCurve { private: IdleRegister idle_register; diff --git a/rtgui/myflatcurve.cc b/rtgui/myflatcurve.cc index 362d34f35..da993987c 100644 --- a/rtgui/myflatcurve.cc +++ b/rtgui/myflatcurve.cc @@ -233,21 +233,21 @@ void MyFlatCurve::draw () if (n > 1) { if (pipetteR > -1.f) { cr->set_source_rgba (1., 0., 0., 0.5); // WARNING: assuming that red values are stored in pipetteR, which might not be the case! - cr->move_to (graphX + graphW*pipetteR, graphY + 1. * s); + cr->move_to (graphX + graphW * static_cast(pipetteR), graphY + 1. * s); cr->rel_line_to (0, -graphH - 1. * s); cr->stroke (); } if (pipetteG > -1.f) { cr->set_source_rgba (0., 1., 0., 0.5); // WARNING: assuming that green values are stored in pipetteG, which might not be the case! - cr->move_to (graphX + graphW*pipetteG, graphY + 1. * s); + cr->move_to (graphX + graphW * static_cast(pipetteG), graphY + 1. * s); cr->rel_line_to (0, -graphH - 1. * s); cr->stroke (); } if (pipetteB > -1.f) { cr->set_source_rgba (0., 0., 1., 0.5); // WARNING: assuming that blue values are stored in pipetteB, which might not be the case! - cr->move_to (graphX + graphW*pipetteB, graphY + 1. * s); + cr->move_to (graphX + graphW * static_cast(pipetteB), graphY + 1. * s); cr->rel_line_to (0, -graphH - 1. * s); cr->stroke (); } @@ -257,7 +257,7 @@ void MyFlatCurve::draw () cr->set_line_width (2. * s); c = style->get_color (state); cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue()); - cr->move_to (graphX + graphW*pipetteVal, graphY + 1. * s); + cr->move_to (graphX + graphW * static_cast(pipetteVal), graphY + 1. * s); cr->rel_line_to (0, -graphH - 1. * s); cr->stroke (); cr->set_line_width (1. * s); @@ -437,10 +437,10 @@ void MyFlatCurve::draw () // draw curve c = style->get_color(state); cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue()); - cr->move_to (graphX, getVal(point, 0) * -graphH + graphY); + cr->move_to (graphX, static_cast(getVal(point, 0)) * -graphH + graphY); for (int i = 1; i < graphW; ++i) { - cr->line_to ((double)i + graphX, (double)getVal(point, i) * -graphH + graphY); + cr->line_to ((double)i + graphX, static_cast(getVal(point, i)) * -graphH + graphY); } cr->stroke (); diff --git a/rtgui/myflatcurve.h b/rtgui/myflatcurve.h index 88d651a05..5da1d09ad 100644 --- a/rtgui/myflatcurve.h +++ b/rtgui/myflatcurve.h @@ -66,7 +66,7 @@ public: double centerY; }; -class MyFlatCurve : public MyCurve +class MyFlatCurve final : public MyCurve { protected: diff --git a/rtgui/navigator.h b/rtgui/navigator.h index c1c23c6dc..e9d40e309 100644 --- a/rtgui/navigator.h +++ b/rtgui/navigator.h @@ -25,7 +25,7 @@ class PreviewWindow; -class Navigator : +class Navigator final : public Gtk::Frame, public PointerMotionListener { diff --git a/rtgui/partialpastedlg.h b/rtgui/partialpastedlg.h index 1403e7c1b..75e18e83c 100644 --- a/rtgui/partialpastedlg.h +++ b/rtgui/partialpastedlg.h @@ -34,7 +34,7 @@ class ProcParams; struct ParamsEdited; -class PartialPasteDlg : public Gtk::Dialog +class PartialPasteDlg final : public Gtk::Dialog { public: diff --git a/rtgui/popupbutton.h b/rtgui/popupbutton.h index 87b1b73a6..a67339a9f 100644 --- a/rtgui/popupbutton.h +++ b/rtgui/popupbutton.h @@ -24,7 +24,7 @@ #include "popupcommon.h" -class PopUpButton : +class PopUpButton final : public Gtk::Button, public PopUpCommon { diff --git a/rtgui/preferences.h b/rtgui/preferences.h index 76a104ffa..a6cbe7939 100644 --- a/rtgui/preferences.h +++ b/rtgui/preferences.h @@ -29,7 +29,7 @@ class RTWindow; class Splash; -class Preferences : +class Preferences final : public Gtk::Dialog, public ProfileStoreListener { diff --git a/rtgui/previewhandler.h b/rtgui/previewhandler.h index d9c91f6ad..4fd9a1e82 100644 --- a/rtgui/previewhandler.h +++ b/rtgui/previewhandler.h @@ -44,7 +44,7 @@ struct PreviewHandlerIdleHelper { int pending; }; -class PreviewHandler : public rtengine::PreviewImageListener, public rtengine::NonCopyable +class PreviewHandler final : public rtengine::PreviewImageListener, public rtengine::NonCopyable { private: friend int setImageUI (void* data); diff --git a/rtgui/previewloader.h b/rtgui/previewloader.h index 9a74ee2eb..a8032fcaf 100644 --- a/rtgui/previewloader.h +++ b/rtgui/previewloader.h @@ -20,10 +20,15 @@ #include -#include - #include "../rtengine/noncopyable.h" +namespace Glib +{ + +class ustring; + +} + class FileBrowserEntry; class PreviewLoaderListener diff --git a/rtgui/profilepanel.h b/rtgui/profilepanel.h index b3c968682..c3a125c49 100644 --- a/rtgui/profilepanel.h +++ b/rtgui/profilepanel.h @@ -49,7 +49,7 @@ class PartialProfile; } class RTImage; -class ProfilePanel : +class ProfilePanel final : public Gtk::Grid, public PParamsChangeListener, public ProfileStoreListener, diff --git a/rtgui/progressconnector.h b/rtgui/progressconnector.h index f4d1d8f7e..90c9f67f0 100644 --- a/rtgui/progressconnector.h +++ b/rtgui/progressconnector.h @@ -28,7 +28,7 @@ #undef THREAD_PRIORITY_NORMAL -class PLDBridge : +class PLDBridge final : public rtengine::ProgressListener { public: diff --git a/rtgui/renamedlg.h b/rtgui/renamedlg.h index f9447fbac..3c92965f8 100644 --- a/rtgui/renamedlg.h +++ b/rtgui/renamedlg.h @@ -26,7 +26,7 @@ class CacheImageData; -class RenameDialog : +class RenameDialog final : public Gtk::Dialog { diff --git a/rtgui/retinex.cc b/rtgui/retinex.cc index c78be375f..2fdd8f319 100644 --- a/rtgui/retinex.cc +++ b/rtgui/retinex.cc @@ -278,7 +278,7 @@ Retinex::Retinex () : FoldableToolPanel (this, "retinex", M ("TP_RETINEX_LABEL") for (int i = 0; i < 7; i++) { float R, G, B; - float x = float (i) * (1.0f / 6.0); + float x = i / 6.0; Color::hsv2rgb01 (x, 0.5f, 0.5f, R, G, B); milestones.push_back ( GradientMilestone (double (x), double (R), double (G), double (B)) ); } @@ -659,10 +659,16 @@ void Retinex::writeOptions (std::vector &tpOpen) tpOpen.push_back (expsettings->get_expanded ()); } -void Retinex::updateToolState (std::vector &tpOpen) +void Retinex::updateToolState(const std::vector& tpOpen) { + if (tpOpen.empty()) { + expsettings->set_expanded(false); + + return; + } + if (tpOpen.size() >= 10) { - expsettings->set_expanded (tpOpen.at (9)); + expsettings->set_expanded(tpOpen[9]); } } diff --git a/rtgui/retinex.h b/rtgui/retinex.h index ff524f854..dea65daab 100644 --- a/rtgui/retinex.h +++ b/rtgui/retinex.h @@ -104,32 +104,32 @@ protected: sigc::connection medianmapConn; public: - Retinex (); - ~Retinex () override; + Retinex(); + ~Retinex() override; - void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr) override; - void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr) override; - void setBatchMode (bool batchMode) override; - void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr) override; - void trimValues (rtengine::procparams::ProcParams* pp) override; - void adjusterChanged (Adjuster* a, double newval) override; - void autoOpenCurve () override; - void medianmapChanged (); - void minmaxChanged (double cdma, double cdmin, double mini, double maxi, double Tmean, double Tsigma, double Tmin, double Tmax) override; - void updateLabel (); - void updateTrans (); - void neutral_pressed (); + void read(const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr) override; + void write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr) override; + void setBatchMode(bool batchMode) override; + void setDefaults(const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr) override; + void trimValues(rtengine::procparams::ProcParams* pp) override; + void adjusterChanged(Adjuster* a, double newval) override; + void autoOpenCurve() override; + void medianmapChanged(); + void minmaxChanged(double cdma, double cdmin, double mini, double maxi, double Tmean, double Tsigma, double Tmin, double Tmax) override; + void updateLabel(); + void updateTrans(); + void neutral_pressed(); - void enabledChanged () override; - void curveChanged (CurveEditor* ce) override; + void enabledChanged() override; + void curveChanged(CurveEditor* ce) override; void retinexMethodChanged(); void mapMethodChanged(); void viewMethodChanged(); void retinexColorSpaceChanged(); void gammaretinexChanged(); void ColorSpaceUpdateUI(); - void writeOptions (std::vector &tpOpen); - void updateToolState (std::vector &tpOpen); + void writeOptions(std::vector &tpOpen); + void updateToolState(const std::vector& tpOpen); void setAdjusterBehavior (bool strAdd, bool neighAdd, bool limdAdd, bool offsAdd, bool vartAdd, bool gamAdd, bool slopeAdd); void updateCurveBackgroundHistogram( const LUTu& histToneCurve, @@ -144,9 +144,8 @@ public: const LUTu& histLRETI ); - void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller) override; + void colorForValue(double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller) override; private: - void foldAllButMe (GdkEventButton* event, MyExpander *expander); - + void foldAllButMe(GdkEventButton* event, MyExpander *expander); }; diff --git a/rtgui/rtimage.h b/rtgui/rtimage.h index b68becd82..eb1930d28 100644 --- a/rtgui/rtimage.h +++ b/rtgui/rtimage.h @@ -25,7 +25,7 @@ /** * @brief A derived class of Gtk::Image in order to handle theme-related icon sets. */ -class RTImage : public Gtk::Image, public RTScalable +class RTImage final : public Gtk::Image, public RTScalable { static double dpiBack; // used to keep track of master dpi change static int scaleBack; // used to keep track of master scale change diff --git a/rtgui/rtscalable.cc b/rtgui/rtscalable.cc index a48a95fd2..78202326a 100644 --- a/rtgui/rtscalable.cc +++ b/rtgui/rtscalable.cc @@ -68,7 +68,7 @@ double RTScalable::getDPI () double RTScalable::getTweakedDPI () { - return dpi * fontScale; + return dpi * static_cast(fontScale); } int RTScalable::getScale () diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index 514685a16..fc315e1b7 100644 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -99,6 +99,8 @@ RTWindow::RTWindow () , bpanel (nullptr) , splash (nullptr) , btn_fullscreen (nullptr) + , iFullscreen (nullptr) + , iFullscreen_exit (nullptr) , epanel (nullptr) , fpanel (nullptr) { @@ -179,7 +181,7 @@ RTWindow::RTWindow () fontScale = options.fontSize / (float)RTScalable::baseFontSize; } if (rtengine::settings->verbose) { - printf("\"Non-Default\" font size(%d) * scale(%d) / fontScale(%.3f)\n", options.fontSize, (int)initialGdkScale, fontScale); + printf("\"Non-Default\" font size(%d) * scale(%d) / fontScale(%.3f)\n", options.fontSize, (int)initialGdkScale, static_cast(fontScale)); } } else { Glib::RefPtr style = Gtk::StyleContext::create(); @@ -209,7 +211,7 @@ RTWindow::RTWindow () if ((int)initialGdkScale > 1 || pt != RTScalable::baseFontSize) { css = Glib::ustring::compose ("* { font-size: %1pt}", pt * (int)initialGdkScale); if (rtengine::settings->verbose) { - printf("\"Default\" font size(%d) * scale(%d) / fontScale(%.3f)\n", pt, (int)initialGdkScale, fontScale); + printf("\"Default\" font size(%d) * scale(%d) / fontScale(%.3f)\n", pt, (int)initialGdkScale, static_cast(fontScale)); } } } diff --git a/rtgui/rtwindow.h b/rtgui/rtwindow.h index 4791ac6c1..c493c2db4 100644 --- a/rtgui/rtwindow.h +++ b/rtgui/rtwindow.h @@ -35,7 +35,7 @@ class BatchQueuePanel; class EditorPanel; class FilePanel; class PLDBridge; -class RTWindow : +class RTWindow final : public Gtk::Window, public rtengine::ProgressListener, public rtengine::NonCopyable diff --git a/rtgui/saveasdlg.h b/rtgui/saveasdlg.h index 448b37fd7..445452a54 100644 --- a/rtgui/saveasdlg.h +++ b/rtgui/saveasdlg.h @@ -22,7 +22,7 @@ #include "saveformatpanel.h" -class SaveAsDialog : +class SaveAsDialog final : public Gtk::Dialog, public FormatChangeListener { diff --git a/rtgui/shcselector.h b/rtgui/shcselector.h index 5c4421e0a..e03ca8e06 100644 --- a/rtgui/shcselector.h +++ b/rtgui/shcselector.h @@ -29,7 +29,7 @@ public: virtual void shcChanged() = 0; }; -class SHCSelector : public Gtk::DrawingArea, BackBuffer +class SHCSelector final : public Gtk::DrawingArea, BackBuffer { protected: diff --git a/rtgui/splash.h b/rtgui/splash.h index 363c51489..bc63cef91 100644 --- a/rtgui/splash.h +++ b/rtgui/splash.h @@ -20,7 +20,7 @@ #include -class SplashImage : +class SplashImage final : public Gtk::DrawingArea { @@ -39,7 +39,7 @@ public: }; //class Splash : public Gtk::Window { -class Splash : public Gtk::Dialog +class Splash final : public Gtk::Dialog { private: diff --git a/rtgui/thresholdselector.h b/rtgui/thresholdselector.h index f948b56ad..4ae86560e 100644 --- a/rtgui/thresholdselector.h +++ b/rtgui/thresholdselector.h @@ -113,10 +113,10 @@ protected: void updateBackBuffer(); Gtk::SizeRequestMode get_request_mode_vfunc () const override; - void get_preferred_height_vfunc (int& minimum_height, int& natural_height) const override; - void get_preferred_width_vfunc (int &minimum_width, int &natural_width) const override; - void get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const override; - void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const override; + void get_preferred_height_vfunc (int& minimum_height, int& natural_height) const final; + void get_preferred_width_vfunc (int &minimum_width, int &natural_width) const final; + void get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const final; + void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const final; void on_realize () override; bool on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr) override; bool on_button_press_event (GdkEventButton* event) override; diff --git a/rtgui/thumbbrowserbase.h b/rtgui/thumbbrowserbase.h index b4caac0a9..69017b183 100644 --- a/rtgui/thumbbrowserbase.h +++ b/rtgui/thumbbrowserbase.h @@ -60,10 +60,10 @@ class ThumbBrowserBase : bool on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr) override; Gtk::SizeRequestMode get_request_mode_vfunc () const override; - void get_preferred_height_vfunc (int &minimum_height, int &natural_height) const override; - void get_preferred_width_vfunc (int &minimum_width, int &natural_width) const override; - void get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const override; - void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const override; + void get_preferred_height_vfunc (int &minimum_height, int &natural_height) const final; + void get_preferred_width_vfunc (int &minimum_width, int &natural_width) const final; + void get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const final; + void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const final; bool on_button_press_event (GdkEventButton* event) override; bool on_button_release_event (GdkEventButton* event) override; diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index 5295b9d61..87bc730eb 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -887,11 +887,6 @@ void Thumbnail::_loadThumbnail(bool firstTrial) } if ( cfs.thumbImgType == CacheImageData::FULL_THUMBNAIL ) { - if(!tpp->isAeValid()) { - // load aehistogram - tpp->readAEHistogram (getCacheFileName ("aehistograms", "")); - } - // load embedded profile tpp->readEmbProfile (getCacheFileName ("embprofiles", ".icc")); @@ -937,10 +932,6 @@ void Thumbnail::_saveThumbnail () // save thumbnail image tpp->writeImage (getCacheFileName ("images", "")); - if(!tpp->isAeValid()) { - // save aehistogram - tpp->writeAEHistogram (getCacheFileName ("aehistograms", "")); - } // save embedded profile tpp->writeEmbProfile (getCacheFileName ("embprofiles", ".icc")); diff --git a/rtgui/toolpanel.h b/rtgui/toolpanel.h index aecf1f39f..12b3eebcc 100644 --- a/rtgui/toolpanel.h +++ b/rtgui/toolpanel.h @@ -143,7 +143,7 @@ public: this->batchMode = batchMode; } - virtual Glib::ustring getToolName () { + Glib::ustring getToolName () { return toolName; } }; @@ -164,11 +164,11 @@ public: FoldableToolPanel(Gtk::Box* content, Glib::ustring toolName, Glib::ustring UILabel, bool need11 = false, bool useEnabled = false); - MyExpander* getExpander() override + MyExpander* getExpander() final { return exp; } - void setExpanded (bool expanded) override + void setExpanded (bool expanded) final { if (exp) { exp->set_expanded( expanded ); @@ -186,7 +186,7 @@ public: exp->show(); } } - bool getExpanded () override + bool getExpanded () final { if (exp) { return exp->get_expanded(); @@ -194,11 +194,11 @@ public: return false; } - void setParent (Gtk::Box* parent) override + void setParent (Gtk::Box* parent) final { parentContainer = parent; } - Gtk::Box* getParent () override + Gtk::Box* getParent () final { return parentContainer; } diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 57f61a09c..00ad96328 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -632,40 +632,52 @@ void ToolPanelCoordinator::closeImage () void ToolPanelCoordinator::closeAllTools() { - - for (size_t i = 0; i < options.tpOpen.size(); i++) + for (size_t i = 0; i < options.tpOpen.size(); ++i) { if (i < expList.size()) { - expList.at (i)->set_expanded (false); + expList[i]->set_expanded(false); } + } } void ToolPanelCoordinator::openAllTools() { - - for (size_t i = 0; i < options.tpOpen.size(); i++) + for (size_t i = 0; i < options.tpOpen.size(); ++i) { if (i < expList.size()) { - expList.at (i)->set_expanded (true); + expList[i]->set_expanded(true); } + } } void ToolPanelCoordinator::updateToolState() { - - for (size_t i = 0; i < options.tpOpen.size(); i++) - if (i < expList.size()) { - expList.at (i)->set_expanded (options.tpOpen.at (i)); + if (options.tpOpen.empty()) { + for (auto expander : expList) { + expander->set_expanded(false); } + wavelet->updateToolState({}); + retinex->updateToolState({}); + + return; + } + + for (size_t i = 0; i < options.tpOpen.size(); ++i) { + if (i < expList.size()) { + expList[i]->set_expanded(options.tpOpen[i]); + } + } + if (options.tpOpen.size() > expList.size()) { - size_t sizeWavelet = options.tpOpen.size() - expList.size(); + const size_t sizeWavelet = options.tpOpen.size() - expList.size(); + std::vector temp; - for (size_t i = 0; i < sizeWavelet; i++) { - temp.push_back (options.tpOpen.at (i + expList.size())); + for (size_t i = 0; i < sizeWavelet; ++i) { + temp.push_back(options.tpOpen[i + expList.size()]); } - wavelet->updateToolState (temp); - retinex->updateToolState (temp); + wavelet->updateToolState(temp); + retinex->updateToolState(temp); } } diff --git a/rtgui/toolpanelcoord.h b/rtgui/toolpanelcoord.h index 4313f6d12..0fc1a9070 100644 --- a/rtgui/toolpanelcoord.h +++ b/rtgui/toolpanelcoord.h @@ -314,11 +314,11 @@ public: // imageareatoollistener interface void spotWBselected(int x, int y, Thumbnail* thm = nullptr) override; - void sharpMaskSelected(bool sharpMask) override; + void sharpMaskSelected(bool sharpMask) override final; int getSpotWBRectSize() const override; void cropSelectionReady() override; void rotateSelectionReady(double rotate_deg, Thumbnail* thm = nullptr) override; - ToolBar* getToolBar() const override; + ToolBar* getToolBar() const final; CropGUIListener* startCropEditing(Thumbnail* thm = nullptr) override; void updateTPVScrollbar (bool hide); @@ -326,7 +326,7 @@ public: // ToolBarListener interface void toolSelected (ToolMode tool) override; - void editModeSwitchedOff () override; + void editModeSwitchedOff () final; void setEditProvider (EditDataProvider *provider); diff --git a/rtgui/wavelet.cc b/rtgui/wavelet.cc index 252ed0abe..7d9a65f2a 100644 --- a/rtgui/wavelet.cc +++ b/rtgui/wavelet.cc @@ -3360,18 +3360,32 @@ void Wavelet::writeOptions(std::vector &tpOpen) tpOpen.push_back(expclari->get_expanded()); } -void Wavelet::updateToolState(std::vector &tpOpen) +void Wavelet::updateToolState(const std::vector& tpOpen) { + if (tpOpen.empty()) { + expsettings->set_expanded(false); + expcontrast->set_expanded(false); + expchroma->set_expanded(false); + exptoning->set_expanded(false); + expnoise->set_expanded(false); + expedge->set_expanded(false); + expgamut->set_expanded(false); + expresid->set_expanded(false); + expfinal->set_expanded(false); + expclari->set_expanded(false); + return; + } + if (tpOpen.size() >= 10) { - expsettings->set_expanded(tpOpen.at(0)); - expcontrast->set_expanded(tpOpen.at(1)); - expchroma->set_expanded(tpOpen.at(2)); - exptoning->set_expanded(tpOpen.at(3)); - expnoise->set_expanded(tpOpen.at(4)); - expedge->set_expanded(tpOpen.at(5)); - expgamut->set_expanded(tpOpen.at(6)); - expresid->set_expanded(tpOpen.at(7)); - expfinal->set_expanded(tpOpen.at(8)); + expsettings->set_expanded(tpOpen[0]); + expcontrast->set_expanded(tpOpen[1]); + expchroma->set_expanded(tpOpen[2]); + exptoning->set_expanded(tpOpen[3]); + expnoise->set_expanded(tpOpen[4]); + expedge->set_expanded(tpOpen[5]); + expgamut->set_expanded(tpOpen[6]); + expresid->set_expanded(tpOpen[7]); + expfinal->set_expanded(tpOpen[8]); expclari->set_expanded(tpOpen.at(9)); } } diff --git a/rtgui/wavelet.h b/rtgui/wavelet.h index 9d9502670..d3b66657e 100644 --- a/rtgui/wavelet.h +++ b/rtgui/wavelet.h @@ -20,12 +20,13 @@ #pragma once #include + #include "adjuster.h" -#include "toolpanel.h" -#include "curvelistener.h" -#include "thresholdadjuster.h" #include "colorprovider.h" +#include "curvelistener.h" #include "guiutils.h" +#include "thresholdadjuster.h" +#include "toolpanel.h" class CurveEditor; class CurveEditorGroup; @@ -43,21 +44,22 @@ class Wavelet final : public FoldableToolPanel { public: - Wavelet (); - ~Wavelet () override; + Wavelet(); + ~Wavelet() override; - bool wavComputed_ (); + bool wavComputed_(); void adjusterChanged(Adjuster* a, double newval) override; - void autoOpenCurve () override; - void curveChanged (CurveEditor* ce) override; - void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr) override; + void autoOpenCurve() override; + void curveChanged(CurveEditor* ce) override; + void read(const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr) override; +// void setAdjusterBehavior(bool multiplieradd, bool thresholdadd, bool threshold2add, bool thresadd, bool chroadd, bool chromaadd, bool contrastadd, bool skinadd, bool reschroadd, bool tmrsadd, bool resconadd, bool resconHadd, bool thradd, bool thrHadd, bool skyadd, bool edgradadd, bool edgvaladd, bool strengthadd, bool gammaadd, bool edgedetectadd, bool edgedetectthradd, bool edgedetectthr2add); void setAdjusterBehavior (bool multiplieradd, bool thresholdadd, bool threshold2add, bool thresadd, bool chroadd, bool chromaadd, bool contrastadd, bool skinadd, bool reschroadd, bool tmrsadd, bool edgsadd, bool scaleadd, bool resconadd, bool resconHadd, bool thradd, bool thrHadd, bool radiusadd, bool skyadd, bool edgradadd, bool edgvaladd, bool strengthadd, bool gammaadd, bool edgedetectadd, bool edgedetectthradd, bool edgedetectthr2add); - void setBatchMode (bool batchMode) override; - void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr) override; - void setEditProvider (EditDataProvider *provider) override; - void updateToolState (std::vector &tpOpen); - void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr) override; - void writeOptions (std::vector &tpOpen); + void setBatchMode(bool batchMode) override; + void setDefaults(const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr) override; + void setEditProvider(EditDataProvider *provider) override; + void updateToolState(const std::vector& tpOpen); + void write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr) override; + void writeOptions(std::vector &tpOpen); void adjusterChanged(ThresholdAdjuster* a, double newBottom, double newTop) override; void adjusterChanged(ThresholdAdjuster* a, double newBottomLeft, double newTopLeft, double newBottomRight, double newTopRight) override; @@ -78,39 +80,39 @@ private: rtengine::ProcEvent EvWavradius; rtengine::ProcEvent EvWavsigma; - void foldAllButMe (GdkEventButton* event, MyExpander *expander); + void foldAllButMe(GdkEventButton* event, MyExpander *expander); - void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller) override; - void BAmethodChanged (); - void NPmethodChanged (); - void BackmethodChanged (); - void CHSLmethodChanged (); - void CHmethodChanged (); - void CLmethodChanged (); - void DirmethodChanged (); - void EDmethodChanged (); - void HSmethodChanged (); - void LmethodChanged (); - void MedgreinfChanged (); - void TMmethodChanged (); - void TilesmethodChanged (); - void avoidToggled (); + void colorForValue(double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller) override; + void BAmethodChanged(); + void NPmethodChanged(); + void BackmethodChanged(); + void CHSLmethodChanged(); + void CHmethodChanged(); + void CLmethodChanged(); + void DirmethodChanged(); + void EDmethodChanged(); + void HSmethodChanged(); + void LmethodChanged(); + void MedgreinfChanged(); + void TMmethodChanged(); + void TilesmethodChanged(); + void avoidToggled(); void showmaskToggled (); - void cbenabToggled (); - void contrastMinusPressed (); - void contrastPlusPressed (); - void daubcoeffmethodChanged (); - void enabledChanged () override; - void linkedgToggled (); - void lipstToggled (); - void medianToggled (); - void medianlevToggled (); - void neutralPressed (); - void neutral_pressed (); - void neutralchPressed (); - void tmrToggled (); + void cbenabToggled(); + void contrastMinusPressed(); + void contrastPlusPressed(); + void daubcoeffmethodChanged(); + void enabledChanged() override; + void linkedgToggled(); + void lipstToggled(); + void medianToggled(); + void medianlevToggled(); + void neutralPressed(); + void neutral_pressed(); + void neutralchPressed(); + void tmrToggled(); void updatewavLabel (); - void wavChanged (double nlevel) override; + void wavChanged(double nlevel) override; void ushamethodChanged(); void HSmethodUpdateUI(); @@ -127,13 +129,13 @@ private: // void MedgreinfUpdateUI(); // void DirmethodUpdateUI(); // void LmethodUpdateUI(); - void adjusterUpdateUI (Adjuster* a); - void enabledUpdateUI (); - void medianlevUpdateUI (); - void cbenabUpdateUI (); - void lipstUpdateUI (); + void adjusterUpdateUI(Adjuster* a); + void enabledUpdateUI(); + void medianlevUpdateUI(); + void cbenabUpdateUI(); + void lipstUpdateUI(); - void enableToggled(MyExpander *expander); + void enableToggled(MyExpander* expander); CurveEditorGroup* const curveEditorG; diff --git a/tools/generateRtexifUpdates b/tools/generateRtexifUpdates index 72a97862e..b4ace209d 100755 --- a/tools/generateRtexifUpdates +++ b/tools/generateRtexifUpdates @@ -32,7 +32,10 @@ echo #------------------------------------------------------------------------------ # Canon printf '%s\n' "Saving ${tmpdir}/canon_lenses" -xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -canon:all) | sort -fuV > "${tmpdir}/canon_lenses" +xmlstarlet sel -T -t \ + -m "taginfo/table/tag[@name='LensType']/values/key" \ + -v "concat(@id,' ',val)" \ + -n < <("$et" -listx -canon:all) | sort -fuV > "${tmpdir}/canon_lenses" #In :10.1 Sigma 50mm f/2.8 EX #Out: {10, "Sigma 50mm f/2.8 EX"}, @@ -55,7 +58,11 @@ sed -r -i \ # replace with '] = "' # append '";' printf '%s\n' "Saving ${tmpdir}/canon_cameras" -xmlstarlet sel -T -t -m "taginfo/table/tag[@name='CanonModelID']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -canon:all) | sort -fuV > "${tmpdir}/canon_cameras" +xmlstarlet sel -T -t \ + -m "taginfo/table/tag[@name='CanonModelID']/values/key" \ + -v "concat(@id,' ',val)" \ + -n < <("$et" -listx -canon:all) | sort -fuV > "${tmpdir}/canon_cameras" + sed -r -i \ -e 's/^/ choices[/' \ -e 's/\t/] = "/' \ @@ -65,28 +72,84 @@ sed -r -i \ #------------------------------------------------------------------------------ # Nikon LensIDs are composite tags printf '%s\n' "Saving ${tmpdir}/nikon" -xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensID']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -composite:all) > "${tmpdir}/nikon" -sed -r -i -e '/^... /d' -e 's/^/ {"/' -e 's/([A-F0-9]+)[A-F0-9.]*\t/\1", "/' -e 's/$/"},/' -e 's|(.* ")(.*) F([0-9]+)|\1\2 f/\3|' -e 's| F/([0-9]+)| f/\1|' "${tmpdir}/nikon" + +xmlstarlet sel -T -t \ + -m "taginfo/table/tag[@name='LensID']/values/key" \ + -v "concat(@id,' ',val)" \ + -n < <("$et" -listx -composite:all) > "${tmpdir}/nikon" + +sed -r -i \ + -e '/^... /d' \ + -e 's/^/ {"/' \ + -e 's/([A-F0-9]+)[A-F0-9.]*\t/\1", "/' \ + -e 's/$/"},/' \ + -e 's|(.* ")(.*) F([0-9]+)|\1\2 f/\3|' \ + -e 's| F/([0-9]+)| f/\1|' \ + "${tmpdir}/nikon" #------------------------------------------------------------------------------ # Olympus printf '%s\n' "Saving ${tmpdir}/olympus" -xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -olympus:all) | sort -fuV > "${tmpdir}/olympus" -sed -r -i -e '/0 00 00\tNone/d' -e 's/^/ lenses["0/' -e 's/\t/"] = "/' -e 's/$/";/' -e 's| F([0-9]+)| f/\1|g' "${tmpdir}/olympus" + +xmlstarlet sel -T -t \ + -m "taginfo/table/tag[@name='LensType']/values/key" \ + -v "concat(@id,' ',val)" \ + -n < <("$et" -listx -olympus:all) | sort -fuV > "${tmpdir}/olympus" + +sed -r -i \ + -e '/0 00 00\tNone/d' \ + -e 's/^/ lenses["0/' \ + -e 's/\t/"] = "/' \ + -e 's/$/";/' \ + -e 's| F([0-9]+)| f/\1|g' \ + "${tmpdir}/olympus" #------------------------------------------------------------------------------ # Pentax printf '%s\n' "Saving ${tmpdir}/pentax" -xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -pentax:all) | sort -fuV > "${tmpdir}/pentax" -sed -r -i -e 's/^/ choices.insert (p_t (256 * /' -e 's/([0-9]+) ([0-9]+)([0-9.]*)/\1 + \2/' -e 's/\t/, "/' -e 's/$/"));/' -e 's| F([0-9]+)| f/\1|' "${tmpdir}/pentax" + +xmlstarlet sel -T -t \ + -m "taginfo/table/tag[@name='LensType']/values/key" \ + -v "concat(@id,' ',val)" \ + -n < <("$et" -listx -pentax:all) | sort -fuV > "${tmpdir}/pentax" + +sed -r -i \ + -e 's/^/ choices.insert (p_t (256 * /' \ + -e 's/([0-9]+) ([0-9]+)([0-9.]*)/\1 + \2/' \ + -e 's/\t/, "/' \ + -e 's/$/"));/' \ + -e 's| F([0-9]+)| f/\1|' \ + "${tmpdir}/pentax" #------------------------------------------------------------------------------ # Sony printf '%s\n' "Saving ${tmpdir}/sony" -xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -sony:all) | sort -fuV > "${tmpdir}/sony" + +xmlstarlet sel -T -t \ + -m "taginfo/table/tag[@name='LensType']/values/key" \ + -v "concat(@id,' ',val)" \ + -n < <("$et" -listx -sony:all) | sort -fuV > "${tmpdir}/sony" + # Sony has more lenses under the LensType2 tag printf '%s\n' "Saving ${tmpdir}/sony-lenstype2" -xmlstarlet sel -T -t -m "taginfo/table/tag[@name='LensType2']/values/key" -v "concat(@id,' ',val)" -n < <("$et" -listx -sony:all) | sort -fuV > "${tmpdir}/sony-lenstype2" -sed -r -i -e 's/^/ {/' -e 's/([0-9]+)[0-9.]*\t/\1, "/' -e 's/$/"},/' -e 's| F([0-9]+)| f/\1|g' "${tmpdir}/sony" -sed -r -i -e '/255\tTamron Lens (255)/d' -e 's/([0-9]+)[0-9.]*\t/\1, "/' -e 's/^/ choices.insert (p_t (/' -e 's/$/"));/' -e 's| F([0-9]+)| f/\1|g' "${tmpdir}/sony-lenstype2" + +xmlstarlet sel -T -t \ + -m "taginfo/table/tag[@name='LensType2']/values/key" \ + -v "concat(@id,' ',val)" \ + -n < <("$et" -listx -sony:all) | sort -fuV > "${tmpdir}/sony-lenstype2" + +sed -r -i \ + -e 's/^/ {/' \ + -e 's/([0-9]+)[0-9.]*\t/\1, "/' \ + -e 's/$/"},/' \ + -e 's| F([0-9]+)| f/\1|g' \ + "${tmpdir}/sony" + +sed -r -i \ + -e '/255\tTamron Lens (255)/d' \ + -e 's/([0-9]+)[0-9.]*\t/\1, "/' \ + -e 's/^/ choices.insert (p_t (/' \ + -e 's/$/"));/' \ + -e 's| F([0-9]+)| f/\1|g' \ + "${tmpdir}/sony-lenstype2" diff --git a/tools/osx/macosx_bundle.sh b/tools/osx/macosx_bundle.sh index f21915cab..08740f696 100644 --- a/tools/osx/macosx_bundle.sh +++ b/tools/osx/macosx_bundle.sh @@ -114,60 +114,31 @@ msg "Copying release files:" ditto "${CMAKE_BUILD_TYPE}/MacOS" "${MACOS}" ditto "Resources" "${RESOURCES}" +# Copy the Lensfun database into the app bundle +mkdir -p "${RESOURCES}/share/lensfun" +ditto ${LOCAL_PREFIX}/local/share/lensfun/version_2/* "${RESOURCES}/share/lensfun" + +# Copy liblensfun to Frameworks +ditto ${LOCAL_PREFIX}/local/lib/liblensfun.2.dylib "${CONTENTS}/Frameworks/liblensfun.2.dylib" + +# Copy libomp to Frameworks +ditto ${LOCAL_PREFIX}/local/lib/libomp.dylib "${CONTENTS}/Frameworks" + msg "Copying dependencies from ${GTK_PREFIX}:" CheckLink "${EXECUTABLE}" -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 - -msg "Removing static libraries and cache files:" -find -E "${LIB}" -type f -regex '.*\.(a|la|cache)$' | while read -r; do rm "${REPLY}"; done - -msg "Copying configuration files from ${GTK_PREFIX}:" -install -d "${ETC}/gtk-3.0" - -# Make Frameworks folder flat -ditto "${LIB}"/gdk-pixbuf-2.0/2*/loaders/*.so "${LIB}" -ditto "${LIB}"/gtk-3.0/3*/immodules/*.{dylib,so} "${LIB}" -rm -r "${LIB}"/gtk-3.0 -rm -r "${LIB}"/gdk-pixbuf-2.0 - -"${LOCAL_PREFIX}"/local/bin/gdk-pixbuf-query-loaders "${LIB}"/libpix*.so > "${ETC}"/gtk-3.0/gdk-pixbuf.loaders -"${LOCAL_PREFIX}"/local/bin/gtk-query-immodules-3.0 "${LIB}"/im-* > "${ETC}"/gtk-3.0/gtk.immodules -sed -i "" -e "s|${PWD}/RawTherapee.app/Contents/|/Applications/RawTherapee.app/Contents/|" "${ETC}/gtk-3.0/gdk-pixbuf.loaders" "${ETC}/gtk-3.0/gtk.immodules" -sed -i "" -e "s|/opt/local/|/usr/|" "${ETC}/gtk-3.0/gtk.immodules" - -mkdir -p ${RESOURCES}/share/glib-2.0 -ditto {"${LOCAL_PREFIX}/local","${RESOURCES}"}/share/glib-2.0/schemas -"${LOCAL_PREFIX}/local/bin/glib-compile-schemas" "${RESOURCES}/share/glib-2.0/schemas" - -msg "Copying shared files from ${GTK_PREFIX}:" -ditto {"${LOCAL_PREFIX}/local","${RESOURCES}"}/share/mime - -# GTK3 themes -ditto {"${LOCAL_PREFIX}/local","${RESOURCES}"}/share/themes/Mac/gtk-3.0/gtk-keys.css -ditto {"${LOCAL_PREFIX}/local","${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 - mkdir -p ${RESOURCES}/share/icons/Adwaita/${f} - ditto ${LOCAL_PREFIX}/local/share/icons/Adwaita/${f}/* "${RESOURCES}"/share/icons/Adwaita/${f} -done -ditto {"${LOCAL_PREFIX}/local","${RESOURCES}"}/share/icons/Adwaita/index.theme -"${LOCAL_PREFIX}/local/bin/gtk-update-icon-cache" "${RESOURCES}/share/icons/Adwaita" -ditto "${LOCAL_PREFIX}/local/share/icons/hicolor" "${RESOURCES}/share/icons/hicolor" - # Copy libjpeg-turbo ("62") into the app bundle ditto ${LOCAL_PREFIX}/local/lib/libjpeg.62.dylib "${CONTENTS}/Frameworks/libjpeg.62.dylib" # Copy libexpat into the app bundle (which is keg-only) - if [[ -d /usr/local/Cellar/expat ]]; then ditto /usr/local/Cellar/expat/*/lib/libexpat.1.dylib "${CONTENTS}/Frameworks"; else ditto "${EXPATLIB}" "${CONTENTS}/Frameworks/libexpat.1.dylib"; fi # Copy libz into the app bundle ditto ${LOCAL_PREFIX}/local/lib/libz.1.dylib "${CONTENTS}/Frameworks" +# Copy libpng16 to the app bundle +ditto ${LOCAL_PREFIX}/local/lib/libpng16.16.dylib "${CONTENTS}/Frameworks/libpng16.16.dylib" + # Copy libtiff 5 into the app bundle ditto ${LOCAL_PREFIX}/local/lib/libtiff.5.dylib "${CONTENTS}/Frameworks/libtiff.5.dylib" @@ -181,6 +152,43 @@ ditto ${LOCAL_PREFIX}/local/lib/liblensfun.2.dylib "${CONTENTS}/Frameworks/lible # Copy libomp to Frameworks ditto ${LOCAL_PREFIX}/local/lib/libomp.dylib "${CONTENTS}/Frameworks" +# Prepare GTK+3 installation +msg "Copying configuration files from ${GTK_PREFIX}:" +install -d "${ETC}/gtk-3.0" +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 +msg "Removing static libraries and cache files:" +find -E "${LIB}" -type f -regex '.*\.(a|la|cache)$' | while read -r; do rm "${REPLY}"; done + +# Make Frameworks folder flat +msg "Flattening the Frameworks folder" +ditto "${LIB}"/gdk-pixbuf-2.0/2*/loaders/*.so "${LIB}" +ditto "${LIB}"/gtk-3.0/3*/immodules/*.{dylib,so} "${LIB}" +rm -r "${LIB}"/gtk-3.0 +rm -r "${LIB}"/gdk-pixbuf-2.0 + +msg "Build glib database:" +mkdir -p ${RESOURCES}/share/glib-2.0 +ditto {"${LOCAL_PREFIX}/local","${RESOURCES}"}/share/glib-2.0/schemas +"${LOCAL_PREFIX}/local/bin/glib-compile-schemas" "${RESOURCES}/share/glib-2.0/schemas" + +# GTK+3 themes +msg "Copy GTK+3 theme and icon resources:" +ditto {"${LOCAL_PREFIX}/local","${RESOURCES}"}/share/themes/Mac/gtk-3.0/gtk-keys.css +ditto {"${LOCAL_PREFIX}/local","${RESOURCES}"}/share/themes/Default/gtk-3.0/gtk-keys.css + +# Adwaita icons +msg "Copy Adwaita icons" +iconfolders=("16x16/actions" "16x16/devices" "16x16/mimetypes" "16x16/places" "16x16/status" "48x48/devices") +for f in "${iconfolders[@]}"; do + mkdir -p ${RESOURCES}/share/icons/Adwaita/${f} + ditto ${LOCAL_PREFIX}/local/share/icons/Adwaita/${f}/* "${RESOURCES}"/share/icons/Adwaita/${f} +done +ditto {"${LOCAL_PREFIX}/local","${RESOURCES}"}/share/icons/Adwaita/index.theme +"${LOCAL_PREFIX}/local/bin/gtk-update-icon-cache" "${RESOURCES}/share/icons/Adwaita" +ditto "${LOCAL_PREFIX}/local/share/icons/hicolor" "${RESOURCES}/share/icons/hicolor" + # Install names find -E "${CONTENTS}" -type f -regex '.*/(rawtherapee-cli|rawtherapee|.*\.(dylib|so))' | while read -r x; do msg "Modifying install names: ${x}" @@ -194,7 +202,23 @@ find -E "${CONTENTS}" -type f -regex '.*/(rawtherapee-cli|rawtherapee|.*\.(dylib } | bash -v done +# fix @rpath in Frameworks +msg "Registering @rpath in Frameworks folder:" +for frameworklibs in ${CONTENTS}/Frameworks/* ; do + echo " install_name_tool -delete_rpath /opt/local/lib '${frameworklibs}'" | bash -v + echo " install_name_tool -add_rpath /Applications/RawTherapee.app/Contents/Frameworks '${frameworklibs}'" | bash -v +done +# pixbuf loaders & immodules +msg "Build GTK3 databases:" +"${LOCAL_PREFIX}"/local/bin/gdk-pixbuf-query-loaders "${LIB}"/libpix*.so > "${ETC}"/gtk-3.0/gdk-pixbuf.loaders +"${LOCAL_PREFIX}"/local/bin/gtk-query-immodules-3.0 "${LIB}"/im-* > "${ETC}"/gtk-3.0/gtk.immodules +sed -i "" -e "s|${PWD}/RawTherapee.app/Contents/|/Applications/RawTherapee.app/Contents/|" "${ETC}/gtk-3.0/gdk-pixbuf.loaders" "${ETC}/gtk-3.0/gtk.immodules" +sed -i "" -e "s|/opt/local/|/usr/|" "${ETC}/gtk-3.0/gtk.immodules" + +# Mime directory +msg "Copying shared files from ${GTK_PREFIX}:" +ditto {"${LOCAL_PREFIX}/local","${RESOURCES}"}/share/mime msg "Installing required application bundle files:" PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}/tools/osx" @@ -203,7 +227,7 @@ ditto "${PROJECT_SOURCE_DIR}/build/Resources" "${RESOURCES}" # Note: executable is renamed to 'rawtherapee-bin'. mkdir "${MACOS}/bin" ditto "${MACOS}/rawtherapee" "${MACOS}/bin/rawtherapee-bin" -rm "${MACOS}/rawtherappe" +rm "${MACOS}/rawtherapee" install -m 0755 "${PROJECT_SOURCE_DATA_DIR}/executable_loader.in" "${MACOS}/rawtherapee" # App bundle resources ditto "${PROJECT_SOURCE_DATA_DIR}/"{rawtherapee,profile}.icns "${RESOURCES}" @@ -218,15 +242,13 @@ plutil -convert xml1 "${CONTENTS}/Info.plist" plutil -convert xml1 "${CONTENTS}/MacOS/bin/Info.plist" update-mime-database -V "${CONTENTS}/Resources/share/mime" +# Append an LC_RPATH msg "Registering @rpath into the executable:" echo " install_name_tool -add_rpath /Applications/RawTherapee.app/Contents/Frameworks '${MACOS}/bin/rawtherapee-bin'" | bash -v echo " install_name_tool -add_rpath /Applications/RawTherapee.app/Contents/Frameworks '${EXECUTABLE}-cli'" | bash -v -for frameworklibs in ${CONTENTS}/Frameworks/* ; do - echo " install_name_tool -delete_rpath /opt/local/lib '${frameworklibs}'" | bash -v - echo " install_name_tool -add_rpath /Applications/RawTherapee.app/Contents/Frameworks '${frameworklibs}'" | bash -v -done # Sign the app +msg "Codesigning:" CODESIGNID="$(cmake .. -LA -N | grep "CODESIGNID" | cut -d "=" -f2)" if ! test -z "$CODESIGNID" ; then install -m 0644 "${PROJECT_SOURCE_DATA_DIR}/rt.entitlements" "${CONTENTS}/Entitlements.plist" @@ -237,17 +259,16 @@ codesign -v -s "${CODESIGNID}" -i "com.rawtherapee.rawtherapee-bin" -o runtime - for frameworklibs in ${CONTENTS}/Frameworks/* ; do codesign -v -s "${CODESIGNID}" -i "com.rawtherapee.rawtherapee-bin" -o runtime --timestamp "${frameworklibs}" done -codesign --deep --preserve-metadata=identifier,entitlements,runtime --timestamp --strict -v -s "${CODESIGNID}" -i "com.rawtherapee.rawtherapee" -o runtime --entitlements "${CONTENTS}/Entitlements.plist" "${APP}" +codesign --deep --preserve-metadata=identifier,entitlements,runtime --timestamp --strict -v -s "${CODESIGNID}" -i "com.rawtherapee.RawTherapee" -o runtime --entitlements "${CONTENTS}/Entitlements.plist" "${APP}" spctl -a -vvvv "${APP}" fi # Notarize the app - NOTARY="$(cmake .. -LA -N | grep "NOTARY" | cut -d "=" -f2)" if ! test -z "$NOTARY" ; then msg "Notarizing the application:" ditto -c -k --sequesterRsrc --keepParent "${APP}" "${APP}.zip" - uuid=`xcrun altool --notarize-app --primary-bundle-id "com.rawtherapee.rawtherapee" ${NOTARY} --file "${APP}.zip" 2>&1 | grep 'RequestUUID' | awk '{ print $3 }'` + uuid=`xcrun altool --notarize-app --primary-bundle-id "com.rawtherapee.RawTherapee" ${NOTARY} --file "${APP}.zip" 2>&1 | grep 'RequestUUID' | awk '{ print $3 }'` echo "Result= $uuid" # Display identifier string sleep 15 while : @@ -329,7 +350,6 @@ function CreateDmg { done fi - # Zip disk image for redistribution msg "Zipping disk image for redistribution:" @@ -340,3 +360,5 @@ function CreateDmg { rm -rf "${srcDir}" } CreateDmg +msg "Finishing build:" +echo "Script complete."