summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2012-01-27 00:36:18 +0100
committerAlbert Astals Cid <aacid@kde.org>2012-01-27 00:43:21 +0100
commitcbe7131e63c5896010e7e1ad5c0c3aa91611704d (patch)
tree2329ff596ceb19e898bce3980ad3b2206cabdf6a
parent641526d1a7e8032ea8f7b8ac42c5ad8c20448d9b (diff)
Set OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG if you have it
Fixes/workarounds bug 43414 with openjpeg 1.5 (unreleased) (cherry picked from commit de6415af1a39ec7dfa4f149c6c5e311b86352cec)
-rw-r--r--cmake/modules/FindLIBOPENJPEG.cmake13
-rw-r--r--config.h.cmake3
-rw-r--r--configure.ac8
-rw-r--r--poppler/JPEG2000Stream.cc7
4 files changed, 30 insertions, 1 deletions
diff --git a/cmake/modules/FindLIBOPENJPEG.cmake b/cmake/modules/FindLIBOPENJPEG.cmake
index 978ee7d9..ab1721d9 100644
--- a/cmake/modules/FindLIBOPENJPEG.cmake
+++ b/cmake/modules/FindLIBOPENJPEG.cmake
@@ -26,6 +26,19 @@ else (LIBOPENJPEG_LIBRARIES AND LIBOPENJPEG_INCLUDE_DIR)
find_path (LIBOPENJPEG_INCLUDE_DIR openjpeg.h PATH_SUFFIXES openjpeg)
find_library(LIBOPENJPEG_LIBRARIES openjpeg)
if(LIBOPENJPEG_INCLUDE_DIR AND LIBOPENJPEG_LIBRARIES)
+
+ set(CMAKE_REQUIRED_INCLUDES ${LIBOPENJPEG_INCLUDE_DIR})
+ set(CMAKE_REQUIRED_LIBRARIES ${LIBOPENJPEG_LIBRARIES})
+
+check_cxx_source_compiles("
+#include <openjpeg.h>
+int main()
+{
+ int foo = OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG;
+ return 0;
+}
+" WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG)
+
set(LIBOPENJPEG_FOUND TRUE)
endif(LIBOPENJPEG_INCLUDE_DIR AND LIBOPENJPEG_LIBRARIES)
diff --git a/config.h.cmake b/config.h.cmake
index cae2e71f..7dcb1f70 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -189,6 +189,9 @@
/* Use win32 font configuration backend */
#cmakedefine WITH_FONTCONFIGURATION_WIN32 1
+/* OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag */
+#cmakedefine WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG 1
+
/* Define to 1 if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */
diff --git a/configure.ac b/configure.ac
index 5b1d04a6..3ab66097 100644
--- a/configure.ac
+++ b/configure.ac
@@ -171,6 +171,14 @@ if test x$enable_libopenjpeg = xyes; then
LIBOPENJPEG_LIBS="-lopenjpeg"
AC_SUBST(LIBOPENJPEG_LIBS)
AC_DEFINE(ENABLE_LIBOPENJPEG)
+ AC_TRY_COMPILE([
+#include <openjpeg.h>
+], [
+ int foo = OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG;
+], have_openjpeg_flag="yes", am_cv_proto_iconv_arg1="no")
+ if test x$have_openjpeg_flag = xyes; then
+ AC_DEFINE(WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG, 1, [OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag.])
+ fi
fi
AM_CONDITIONAL(BUILD_LIBOPENJPEG, test x$enable_libopenjpeg = xyes)
diff --git a/poppler/JPEG2000Stream.cc b/poppler/JPEG2000Stream.cc
index b7a29bf2..5ea6406e 100644
--- a/poppler/JPEG2000Stream.cc
+++ b/poppler/JPEG2000Stream.cc
@@ -4,7 +4,7 @@
//
// A JPX stream decoder using OpenJPEG
//
-// Copyright 2008-2010 Albert Astals Cid <aacid@kde.org>
+// Copyright 2008-2010, 2012 Albert Astals Cid <aacid@kde.org>
// Copyright 2011 Daniel Glöckner <daniel-gl@gmx.net>
//
// Licensed under GPLv2 or later
@@ -13,6 +13,8 @@
#include "JPEG2000Stream.h"
+#include "config.h"
+
JPXStream::JPXStream(Stream *strA) : FilterStream(strA)
{
inited = gFalse;
@@ -127,6 +129,9 @@ void JPXStream::init2(unsigned char *buf, int bufLen, OPJ_CODEC_FORMAT format)
/* Use default decompression parameters */
opj_dparameters_t parameters;
opj_set_default_decoder_parameters(&parameters);
+#ifdef WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG
+ parameters.flags = OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG;
+#endif
/* Configure the event manager to receive errors and warnings */
opj_event_mgr_t event_mgr;