1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
|