media-libs/libheif: add support for libjpeg-turbo-2.0

Package-Manager: Portage-2.3.50, Repoman-2.3.11
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
This commit is contained in:
Thomas Deutschmann
2018-10-06 18:05:33 +02:00
parent b4c20c2e77
commit b8a3b060c5
2 changed files with 96 additions and 3 deletions
@@ -0,0 +1,93 @@
Support building against libjpeg-turbo 2.0.
Backport of https://github.com/strukturag/libheif/pull/85
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,22 @@ AC_CHECK_LIB([jpeg], [jpeg_destroy_compress], [
], [have_libjpeg="no"])
fi
AM_CONDITIONAL([HAVE_LIBJPEG], [test "x$have_libjpeg" = "xyes"])
+if eval "test x$have_libjpeg = xyes"; then
+AC_MSG_CHECKING([for jpeg_write_icc_profile])
+AC_LANG_PUSH(C++)
+AC_TRY_COMPILE([
+ #include <stddef.h>
+ #include <stdio.h>
+ #include <jpeglib.h>
+],[
+ jpeg_write_icc_profile(NULL, NULL, 0);
+],[has_jpeg_write_icc_profile=yes],[has_jpeg_write_icc_profile=no]);
+AC_LANG_POP(C++)
+AC_MSG_RESULT([$has_jpeg_write_icc_profile])
+if eval "test x$has_jpeg_write_icc_profile = xyes"; then
+ AC_DEFINE(HAVE_JPEG_WRITE_ICC_PROFILE, 1, [Define to 1 if jpeg_write_icc_profile is available in libjpeg.])
+fi
+fi
PKG_CHECK_MODULES([libpng], [libpng], [
AC_DEFINE([HAVE_LIBPNG], [1], [Whether libpng was found.])
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -8,6 +8,24 @@ include (${CMAKE_ROOT}/Modules/FindJPEG.cmake)
if(JPEG_FOUND)
add_definitions(-DHAVE_LIBJPEG=1)
+
+include (${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake)
+
+set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES})
+check_cxx_source_compiles("
+#include <stddef.h>
+#include <stdio.h>
+#include <jpeglib.h>
+
+int main() {
+ jpeg_write_icc_profile(NULL, NULL, 0);
+ return 0;
+}
+" HAVE_JPEG_WRITE_ICC_PROFILE)
+if(HAVE_JPEG_WRITE_ICC_PROFILE)
+ add_definitions(-DHAVE_JPEG_WRITE_ICC_PROFILE=1)
+endif()
+
set (heif_convert_sources
${heif_convert_sources}
encoder_jpeg.cc
--- a/examples/encoder_jpeg.cc
+++ b/examples/encoder_jpeg.cc
@@ -17,6 +17,10 @@
* You should have received a copy of the GNU General Public License
* along with convert. If not, see <http://www.gnu.org/licenses/>.
*/
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
#include <assert.h>
#include <errno.h>
#include <string.h>
--- a/examples/encoder_jpeg.h
+++ b/examples/encoder_jpeg.h
@@ -24,6 +24,9 @@
#include <stddef.h>
#include <stdio.h>
+// Prevent duplicate definition for newer versions of libjpeg-turbo.
+#undef HAVE_STDDEF_H
+#undef HAVE_STDLIB_H
#include <jpeglib.h>
#include <string>
--- a/examples/heif_enc.cc
+++ b/examples/heif_enc.cc
@@ -35,6 +35,9 @@
#if HAVE_LIBJPEG
extern "C" {
+// Prevent duplicate definition for newer versions of libjpeg-turbo.
+#undef HAVE_STDDEF_H
+#undef HAVE_STDLIB_H
#include <jpeglib.h>
}
#endif
@@ -1,4 +1,4 @@
# Copyright 1999-2018 Gentoo Foundation
# Copyright 1999-2018 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI="7"
@@ -11,6 +11,8 @@ if [[ ${PV} == "9999" ]] ; then
else
SRC_URI="https://github.com/strukturag/${PN}/releases/download/v${PV}/${P}.tar.gz"
KEYWORDS="~amd64 ~x86"
PATCHES=( "${FILESDIR}"/${P}-openjpeg-2.patch )
fi
DESCRIPTION="ISO/IEC 23008-12:2017 HEIF file format decoder and encoder"
@@ -20,14 +22,12 @@ LICENSE="GPL-3"
SLOT="0/1.3"
IUSE="static-libs +threads"
# Doesn't yet support libjpeg-turbo-2, https://github.com/strukturag/libheif/issues/70
DEPEND="
media-libs/libde265:=[${MULTILIB_USEDEP}]
media-libs/libpng:0=[${MULTILIB_USEDEP}]
media-libs/x265:=[${MULTILIB_USEDEP}]
sys-libs/zlib:=[${MULTILIB_USEDEP}]
virtual/jpeg:0=[${MULTILIB_USEDEP}]
!>=media-libs/libjpeg-turbo-2
"
RDEPEND="${DEPEND}"