[poppler] CMakeLists.txt config.h.cmake configure.ac poppler/Stream.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Sun May 21 16:07:52 UTC 2017


 CMakeLists.txt    |   29 +++++++++++++++++++++++------
 config.h.cmake    |    3 +++
 configure.ac      |   40 +++++++++++++++++++++++++++++++---------
 poppler/Stream.cc |    7 ++++++-
 4 files changed, 63 insertions(+), 16 deletions(-)

New commits:
commit b286a6b5b1a63563263072305da04604cb022488
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun May 21 17:45:00 2017 +0200

    Fail by default if libjpeg is not available
    
    You can "force" to use the unmaintained DCT decoder or none at all

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b3ff39de..bb663a1e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,7 @@ option(ENABLE_UTILS "Compile poppler command line utils." ON)
 option(ENABLE_CPP "Compile poppler cpp wrapper." ON)
 set(ENABLE_LIBOPENJPEG "auto" CACHE STRING "Use libopenjpeg for JPX streams. Possible values: auto, openjpeg1, openjpeg2. 'auto' prefers openjpeg1 over openjpeg2 if both are available. Unset to not use openjpeg.")
 set(ENABLE_CMS "auto" CACHE STRING "Use color management system. Possible values: auto, lcms1, lcms2. 'auto' prefers lcms2 over lcms1 if both are available. Unset to disable color management system.")
+set(ENABLE_DCTDECODER "libjpeg" CACHE STRING "Use libjpeg for DCT streams. Possible values: libjpeg, unmaintained, none. will use libjpeg if available or fail if not. 'unmaintained' gives you the internal unmaintained decoder. Use at your own risk. 'none' compiles no DCT decoder at all. Default: libjpeg")
 option(ENABLE_LIBCURL "Build libcurl based HTTP support." OFF)
 option(ENABLE_ZLIB "Build with zlib." ON)
 option(ENABLE_ZLIB_UNCOMPRESS "Use zlib to uncompress flate streams (not totally safe)." OFF)
@@ -109,9 +110,22 @@ macro_optional_find_package(JPEG)
 macro_optional_find_package(PNG)
 macro_optional_find_package(TIFF)
 macro_optional_find_package(NSS3)
-if(JPEG_FOUND)
-  set(ENABLE_LIBJPEG ${JPEG_FOUND})
-endif(JPEG_FOUND)
+if(ENABLE_DCTDECODER STREQUAL "libjpeg")
+  if(JPEG_FOUND)
+    set(ENABLE_LIBJPEG ${JPEG_FOUND})
+  else()
+    message(FATAL_ERROR "Install libjpeg before trying to build poppler. You can also decide to use the internal unmaintained DCT decoder or none at all.")
+  endif()
+  set(HAVE_DCT_DECODER ON)
+elseif(ENABLE_DCTDECODER STREQUAL "unmaintained")
+  set(ENABLE_LIBJPEG OFF)
+  set(HAVE_DCT_DECODER ON)
+elseif(ENABLE_DCTDECODER STREQUAL "none")
+  set(ENABLE_LIBJPEG OFF)
+  set(HAVE_DCT_DECODER OFF)
+else()
+  message(FATAL_ERROR "Invalid ENABLE_DCTDECODER value.")
+endif()
 macro_optional_find_package(Qt4)
 if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.7)
   find_package(Qt5Core)
@@ -249,7 +263,6 @@ if (NSS3_FOUND)
 endif(NSS3_FOUND)
 if(JPEG_FOUND)
   include_directories(${JPEG_INCLUDE_DIR})
-  set(ENABLE_LIBJPEG ON)
 endif(JPEG_FOUND)
 if(PNG_FOUND)
   include_directories(${PNG_INCLUDE_DIR})
@@ -772,9 +785,13 @@ if(USE_FIXEDPOINT AND USE_FLOAT)
   message("Warning: Single precision and fixed point options should not be enabled at the same time")
 endif(USE_FIXEDPOINT AND USE_FLOAT)
 
-if(NOT ENABLE_LIBJPEG)
+if(NOT ENABLE_LIBJPEG AND HAVE_DCT_DECODER)
   message("Warning: Using libjpeg is recommended. The internal DCT decoder is unmaintained.")
-endif(NOT ENABLE_LIBJPEG)
+endif()
+
+if(NOT HAVE_DCT_DECODER)
+  message("Warning: You're not compiling any DCT decoder. Some files will fail to display properly.")
+endif()
 
 if(ENABLE_ZLIB_UNCOMPRESS)
   message("Warning: Using zlib is not totally safe")
diff --git a/config.h.cmake b/config.h.cmake
index 7988b74e..db7bfcb3 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -30,6 +30,9 @@
 /* Use cairo for rendering. */
 #cmakedefine HAVE_CAIRO 1
 
+/* Do we have any DCT decoder?. */
+#cmakedefine HAVE_DCT_DECODER 1
+
 /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
    */
 #cmakedefine HAVE_DIRENT_H 1
diff --git a/configure.ac b/configure.ac
index 050a8912..6f8eef97 100644
--- a/configure.ac
+++ b/configure.ac
@@ -425,14 +425,15 @@ fi
 
 AM_CONDITIONAL(BUILD_LIBCURL, test x$enable_libcurl = xyes)
 
-dnl Test for libjpeg
-AC_ARG_ENABLE(libjpeg,
-	      AC_HELP_STRING([--disable-libjpeg],
-	                     [Don't build against libjpeg.]),
-              enable_libjpeg=$enableval,
-              enable_libjpeg="try")
+dnl Test for dct decoder
+AC_ARG_ENABLE(dctdecoder,
+	      AC_HELP_STRING([--enable-dctdecoder=@<:@libjpeg/unmaintained/none@:>@],
+                             [Decides which DCT decoder to use. 'libjpeg' will use libjpeg if available or fail if not. 'unmaintained' gives you the internal unmaintained decoder. Use at your own risk. 'none' compiles no DCT decoder at all. [[default=libjpeg]]]),
+              [dctdecoder=$enableval],
+              [dctdecoder="libjpeg"])
+
 AC_ARG_VAR([LIBJPEG_CFLAGS], [C compiler flags for LIBJPEG])
-if test x$enable_libjpeg != xno; then
+if test x$dctdecoder = x"libjpeg"; then
 
   dnl
   dnl POPPLER_FIND_JPEG uses "USER_INCLUDES" and "USER_LIBS"
@@ -488,11 +489,28 @@ if test x$enable_libjpeg != xno; then
   AC_SUBST(LIBJPEG_CFLAGS)
   USER_INCLUDES="$ac_save_USER_INCLUDES"
   USER_LDFLAGS="$ac_save_USER_LDFLAGS"
+
+  if test x$enable_libjpeg != x"yes"; then
+    AC_MSG_ERROR([Install libjpeg before trying to build poppler. You can also decide to use the internal unmaintained DCT decoder or none at all. See --help.])
+  fi
+  have_dct_decoder="yes"
+  AC_DEFINE(HAVE_DCT_DECODER)
+elif test x$dctdecoder = x"unmaintained"; then
+  enable_libjpeg="no"
+  have_dct_decoder="yes"
+  AC_DEFINE(HAVE_DCT_DECODER)
+elif test x$dctdecoder = x"none"; then
+  enable_libjpeg="no"
+  have_dct_decoder="no"
+else
+    AC_MSG_ERROR([Invalid --enable-dctdecoder value. See --help.])
 fi
 
+AH_TEMPLATE([HAVE_DCT_DECODER], [Do we have any DCT decoder?.])
+
 AM_CONDITIONAL(BUILD_LIBJPEG, test x$enable_libjpeg = xyes)
 AH_TEMPLATE([ENABLE_LIBJPEG],
-            [Use libjpeg instead of builtin jpeg decoder.])
+            [Use libjpeg instead of builtin unmaintained jpeg decoder.])
 
 dnl Test for libpng
 AC_ARG_ENABLE(libpng,
@@ -1078,10 +1096,14 @@ if test x$enable_single_precision = xyes -a x$enable_fixedpoint = xyes; then
 	echo "  Warning: Single precision and fixed point options should not be enabled at the same time"
 fi
 
-if test x$enable_libjpeg != xyes; then
+if test x$enable_libjpeg != xyes -a x$have_dct_decoder = xyes; then
 	echo "  Warning: Using libjpeg is recommended. The internal DCT decoder is unmaintained."
 fi
 
+if test x$have_dct_decoder = xno; then
+	echo "  Warning: You're not compiling any DCT decoder. Some files will fail to display properly."
+fi
+
 if test x$enable_zlib_uncompress != xno; then
 	echo "  Warning: Using zlib for decompression is not totally safe"
 fi
diff --git a/poppler/Stream.cc b/poppler/Stream.cc
index 4a9babe4..d1abf3ff 100644
--- a/poppler/Stream.cc
+++ b/poppler/Stream.cc
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2005 Jeff Muizelaar <jeff at infidigm.net>
-// Copyright (C) 2006-2010, 2012-2014, 2016 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006-2010, 2012-2014, 2016, 2017 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk at gmail.com>
 // Copyright (C) 2008 Julien Rebetez <julien at fhtagn.net>
 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
@@ -313,7 +313,12 @@ Stream *Stream::makeFilter(char *name, Stream *str, Object *params, int recursio
       }
       obj.free();
     }
+#ifdef HAVE_DCT_DECODER
     str = new DCTStream(str, colorXform, dict, recursion);
+#else
+    error(errSyntaxError, getPos(), "Unknown filter '{0:s}'", name);
+    str = new EOFStream(str);
+#endif
   } else if (!strcmp(name, "FlateDecode") || !strcmp(name, "Fl")) {
     pred = 1;
     columns = 1;


More information about the poppler mailing list