From ef4e6e901f242432d864b372a9aa993dbe46b212 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Sun, 14 Jul 2024 13:53:12 +0800 Subject: [PATCH] libkdcraw: fix build with modern libraw --- kde/libkdcraw/Portfile | 10 +- .../files/patch-CMake-return-type.diff | 11 - kde/libkdcraw/files/patch-CMakeLists.diff | 12 ++ kde/libkdcraw/files/patch-libraw.diff | 189 ++++++++++++++++++ 4 files changed, 210 insertions(+), 12 deletions(-) delete mode 100644 kde/libkdcraw/files/patch-CMake-return-type.diff create mode 100644 kde/libkdcraw/files/patch-CMakeLists.diff create mode 100644 kde/libkdcraw/files/patch-libraw.diff diff --git a/kde/libkdcraw/Portfile b/kde/libkdcraw/Portfile index e3a8e8df6e645..60f1b7933c2fc 100644 --- a/kde/libkdcraw/Portfile +++ b/kde/libkdcraw/Portfile @@ -6,7 +6,7 @@ PortGroup muniversal 1.0 name libkdcraw version 4.14.3 -revision 7 +revision 8 categories kde kde4 license GPL-2+ LGPL-2+ maintainers nomaintainer @@ -25,6 +25,14 @@ checksums rmd160 28d68f4ebcecaa8658c2d3838ab3c71ff1d9f50b \ # Binaries do not link to openssl, nor use the ssl backend of kdelibs4 license_noconflict openssl +# https://bugs.gentoo.org/659904 +# https://bugs.gentoo.org/887355 +patchfiles-append patch-libraw.diff + +# libraw_alloc.h: error: exception handling disabled, use -fexceptions to enable +# Cannot be done via passing the flag from portfile, since Qt adds conflicting flags. +patchfiles-append patch-CMakeLists.diff + depends_lib-append port:kdelibs4 \ port:libraw diff --git a/kde/libkdcraw/files/patch-CMake-return-type.diff b/kde/libkdcraw/files/patch-CMake-return-type.diff deleted file mode 100644 index ba1d379342a02..0000000000000 --- a/kde/libkdcraw/files/patch-CMake-return-type.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- CMakeLists.txt.orig 2013-12-23 21:06:50.000000000 +0900 -+++ CMakeLists.txt 2013-12-23 21:07:00.000000000 +0900 -@@ -35,6 +35,8 @@ - INCLUDE(MacroOptionalAddSubdirectory) - INCLUDE(FindPackageHandleStandardArgs) - -+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type") -+ - # NOTE: Libraw 0.16.x is prefered version to use because it's ported to Cmake with full features supported. - # Until libraw 0.16.0 is release (ends of 2013), we will support previous version (with limited support) - FIND_PACKAGE(LibRaw 0.15 REQUIRED) diff --git a/kde/libkdcraw/files/patch-CMakeLists.diff b/kde/libkdcraw/files/patch-CMakeLists.diff new file mode 100644 index 0000000000000..4ea2b2877116f --- /dev/null +++ b/kde/libkdcraw/files/patch-CMakeLists.diff @@ -0,0 +1,12 @@ +--- CMakeLists.txt 2014-07-06 15:20:12.000000000 +0800 ++++ CMakeLists.txt 2024-07-14 13:44:16.000000000 +0800 +@@ -131,6 +131,9 @@ + + # ================================================================================================== + ++string(REGEX REPLACE "-fno-exceptions -DQT_NO_EXCEPTIONS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) ++set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") ++ + ADD_SUBDIRECTORY(libkdcraw) + ADD_SUBDIRECTORY(icons) + ADD_SUBDIRECTORY(profiles) diff --git a/kde/libkdcraw/files/patch-libraw.diff b/kde/libkdcraw/files/patch-libraw.diff new file mode 100644 index 0000000000000..25e49998b7d22 --- /dev/null +++ b/kde/libkdcraw/files/patch-libraw.diff @@ -0,0 +1,189 @@ +From 0843c601cbb9a9bb5774ed01b7d90e68fd17950a Mon Sep 17 00:00:00 2001 +From: Antonio Rojas +Date: Sun, 18 Dec 2022 15:59:51 +0100 +Subject: [PATCH] Fix build with libraw 0.21 + +--- + src/kdcraw.cpp | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/kdcraw.cpp b/src/kdcraw.cpp +index 376a37d..1433c4b 100644 +--- libkdcraw/kdcraw.cpp ++++ libkdcraw/kdcraw.cpp +@@ -357,7 +357,11 @@ bool KDcraw::extractRAWData(const QString& filePath, QByteArray& rawData, DcrawI + d->setProgress(0.3); + + raw.imgdata.params.output_bps = 16; ++#if LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0, 21) ++ raw.imgdata.rawparams.shot_select = shotSelect; ++#else + raw.imgdata.params.shot_select = shotSelect; ++#endif + ret = raw.unpack(); + + if (ret != LIBRAW_SUCCESS) + + +From 3b7d0f2cbf66b06e12c57be26b262b71d8030d1a Mon Sep 17 00:00:00 2001 +From: Boudewijn Rempt +Date: Fri, 31 Aug 2018 11:04:18 +0200 +Subject: [PATCH] Fix build with dcraw 0.19 + +Port of https://phabricator.kde.org/D15132 +--- + .../raw/3rdparty/libkdcraw/src/kdcraw_p.cpp | 8 ++++++ + .../libkdcraw/src/rawdecodingsettings.h | 28 +++++++++++-------- + 2 files changed, 24 insertions(+), 12 deletions(-) + +diff --git a/plugins/impex/raw/3rdparty/libkdcraw/src/kdcraw_p.cpp b/plugins/impex/raw/3rdparty/libkdcraw/src/kdcraw_p.cpp +index 1c761f85632..adc26d26628 100644 +--- libkdcraw/kdcraw_p.cpp ++++ libkdcraw/kdcraw_p.cpp +@@ -375,6 +375,7 @@ bool KDcraw::Private::loadFromLibraw(const QString& filePath, QByteArray& imageD + raw.imgdata.params.fbdd_noiserd = lround(m_parent->m_rawDecodingSettings.NRThreshold / 100.0); + break; + } ++#if !LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0, 19) + case RawDecodingSettings::LINENR: + { + // (100 - 1000) => (0.001 - 0.02) conversion. +@@ -391,23 +392,28 @@ bool KDcraw::Private::loadFromLibraw(const QString& filePath, QByteArray& imageD + raw.imgdata.params.cfa_clean = true; + break; + } ++#endif + default: // No Noise Reduction + { + raw.imgdata.params.threshold = 0; + raw.imgdata.params.fbdd_noiserd = 0; ++#if !LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0, 19) + raw.imgdata.params.linenoise = 0; + raw.imgdata.params.cfaline = false; + raw.imgdata.params.lclean = 0; + raw.imgdata.params.cclean = 0; + raw.imgdata.params.cfa_clean = false; ++#endif + break; + } + } + ++#if !LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0, 19) + // Chromatic aberration correction. + raw.imgdata.params.ca_correc = m_parent->m_rawDecodingSettings.enableCACorrection; + raw.imgdata.params.cared = m_parent->m_rawDecodingSettings.caMultiplier[0]; + raw.imgdata.params.cablue = m_parent->m_rawDecodingSettings.caMultiplier[1]; ++#endif + + // Exposure Correction before interpolation. + raw.imgdata.params.exp_correc = m_parent->m_rawDecodingSettings.expoCorrection; +@@ -461,8 +467,10 @@ bool KDcraw::Private::loadFromLibraw(const QString& filePath, QByteArray& imageD + + raw.imgdata.params.dcb_iterations = m_parent->m_rawDecodingSettings.dcbIterations; + raw.imgdata.params.dcb_enhance_fl = m_parent->m_rawDecodingSettings.dcbEnhanceFl; ++#if !LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0, 19) + raw.imgdata.params.eeci_refine = m_parent->m_rawDecodingSettings.eeciRefine; + raw.imgdata.params.es_med_passes = m_parent->m_rawDecodingSettings.esMedPasses; ++#endif + + //------------------------------------------------------------------------------------------- + +diff --git a/plugins/impex/raw/3rdparty/libkdcraw/src/rawdecodingsettings.h b/plugins/impex/raw/3rdparty/libkdcraw/src/rawdecodingsettings.h +index 6d7c1063dba..5916fb2260c 100644 +--- libkdcraw/rawdecodingsettings.h ++++ libkdcraw/rawdecodingsettings.h +@@ -54,8 +54,6 @@ public: + + /** RAW decoding Interpolation methods + * +- * NOTE: from original dcraw demosaic +- * + * Bilinear: use high-speed but low-quality bilinear + * interpolation (default - for slow computer). In this method, + * the red value of a non-red pixel is computed as the average of +@@ -71,37 +69,38 @@ public: + * AHD: use Adaptive Homogeneity-Directed interpolation. + * This method selects the direction of interpolation so as to + * maximize a homogeneity metric, thus typically minimizing color artifacts. ++ * DCB: DCB interpolation (see http://www.linuxphoto.org/html/dcb.html for details) + * +- * NOTE: from GPL2 demosaic pack. ++ * NOTE: from GPL2/GPL3 demosaic packs - will not work with libraw>=0.19 + * +- * DCB: DCB interpolation (see http://www.linuxphoto.org/html/dcb.html for details) + * PL_AHD: modified AHD interpolation (see http://sites.google.com/site/demosaicalgorithms/modified-dcraw + * for details). + * AFD: demosaicing through 5 pass median filter from PerfectRaw project. + * VCD: VCD interpolation. + * VCD_AHD: mixed demosaicing between VCD and AHD. + * LMMSE: LMMSE interpolation from PerfectRaw. +- * +- * NOTE: from GPL3 demosaic pack. +- * + * AMAZE: AMaZE interpolation and color aberration removal from RawTherapee project. ++ * ++ * NOTE: for libraw>=0.19 only ++ * ++ * DHT: DHT interpolation. ++ * AAHD: Enhanced Adaptative AHD interpolation. + */ + enum DecodingQuality + { +- // from original dcraw demosaic + BILINEAR = 0, + VNG = 1, + PPG = 2, + AHD = 3, +- // Extended demosaicing method from GPL2 demosaic pack + DCB = 4, + PL_AHD = 5, + AFD = 6, + VCD = 7, + VCD_AHD = 8, + LMMSE = 9, +- // Extended demosaicing methods from GPL3 demosaic pack +- AMAZE = 10 ++ AMAZE = 10, ++ DHT = 11, ++ AAHD = 12 + }; + + /** White balances alternatives +@@ -261,6 +260,7 @@ public: + int NRThreshold; + + /** Turn on chromatic aberrations correction ++ * @deprecated does not work with libraw>=0.19 + */ + bool enableCACorrection; + +@@ -268,6 +268,7 @@ public: + * - caMultiplier[0] = amount of correction on red-green axis. + * - caMultiplier[1] = amount of correction on blue-yellow axis. + * - Both values set to 0.0 = automatic CA correction. ++ * @deprecated does not work with libraw>=0.19 + */ + double caMultiplier[2]; + +@@ -334,17 +335,20 @@ public: + /// For VCD_AHD interpolation. + + /** Turn on the EECI refine for VCD Demosaicing. ++ * @deprecated does not work with libraw>=0.19 + */ + bool eeciRefine; + + /** Use edge-sensitive median filtering for artifact supression after VCD demosaicing. + * 0 : disable (default) + * 1-10 : median filter passes. ++ * @deprecated does not work with libraw>=0.19 + */ + int esMedPasses; + + /** For IMPULSENR Noise reduction. Set the amount of Chrominance impulse denoise. +- Null value disable NR. Range is between 100 and 1000. ++ * Null value disable NR. Range is between 100 and 1000. ++ * @deprecated does not work with libraw>=0.19 + */ + int NRChroThreshold; +