summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2018-09-14 00:46:28 +0800
committerRobin Watts <robin.watts@artifex.com>2018-09-19 17:13:45 +0100
commit2b06a50140b7eb81eb55dcc1547fee4e8842e697 (patch)
tree63b760b18c429a1b916c97f6a9994dc657bda400
parent687a3b20407e1489d63194137d14cf61d2b72721 (diff)
downloadmupdf-2b06a50140b7eb81eb55dcc1547fee4e8842e697.tar.xz
Update to OpenJPEG 2.3.0.
There is a regression for 2325_-_JPX_image_with_padding_rejected.pdf. Object 3 in that document is a JPX-encoded image. Its EOC marker is preceded by two extra bytes of data, 0x80 0x80. This makes the file broken according to the JPEG 2000 specification. Acrobat Reader and the Kakadu JPX decoder accepts this file without issues, so OpenJPEG 2.1.0 added code to fix this (bug 226, commit 005e75bdc). That fix detects exactly two bytes of 0x80 0x80, a rather brittle fix. Adding more padding or changing the padding byte values is not accepted. Adding more padding is acceptable to Acrobat Reader and Kakadu. An unrelated fix for another problem has since broken OpenJPEG's support for this broken image.
-rw-r--r--Makethird3
-rw-r--r--platform/win32/libthirdparty.vcproj4
-rw-r--r--source/fitz/load-jpx.c16
m---------thirdparty/openjpeg0
4 files changed, 17 insertions, 6 deletions
diff --git a/Makethird b/Makethird
index 044a21e6..76151f71 100644
--- a/Makethird
+++ b/Makethird
@@ -307,6 +307,7 @@ else
OPENJPEG_CFLAGS += -Ithirdparty/openjpeg/src/lib/openjp2
OPENJPEG_CFLAGS += -DOPJ_STATIC
OPENJPEG_CFLAGS += -DOPJ_HAVE_STDINT_H -DOPJ_HAVE_INTTYPES_H
+OPENJPEG_CFLAGS += -DMUTEX_pthread=0
THIRD_SRC += thirdparty/openjpeg/src/lib/openjp2/bio.c
THIRD_SRC += thirdparty/openjpeg/src/lib/openjp2/cio.c
@@ -321,7 +322,7 @@ THIRD_SRC += thirdparty/openjpeg/src/lib/openjp2/mct.c
THIRD_SRC += thirdparty/openjpeg/src/lib/openjp2/mqc.c
THIRD_SRC += thirdparty/openjpeg/src/lib/openjp2/openjpeg.c
THIRD_SRC += thirdparty/openjpeg/src/lib/openjp2/pi.c
-THIRD_SRC += thirdparty/openjpeg/src/lib/openjp2/raw.c
+THIRD_SRC += thirdparty/openjpeg/src/lib/openjp2/sparse_array.c
THIRD_SRC += thirdparty/openjpeg/src/lib/openjp2/t1.c
THIRD_SRC += thirdparty/openjpeg/src/lib/openjp2/t2.c
THIRD_SRC += thirdparty/openjpeg/src/lib/openjp2/tcd.c
diff --git a/platform/win32/libthirdparty.vcproj b/platform/win32/libthirdparty.vcproj
index cffc0ca1..fb3468ac 100644
--- a/platform/win32/libthirdparty.vcproj
+++ b/platform/win32/libthirdparty.vcproj
@@ -1016,11 +1016,11 @@
>
</File>
<File
- RelativePath="..\..\thirdparty\openjpeg\src\lib\openjp2\raw.c"
+ RelativePath="..\..\thirdparty\openjpeg\src\lib\openjp2\sparse_array.c"
>
</File>
<File
- RelativePath="..\..\thirdparty\openjpeg\src\lib\openjp2\raw.h"
+ RelativePath="..\..\thirdparty\openjpeg\src\lib\openjp2\sparse_array.h"
>
</File>
<File
diff --git a/source/fitz/load-jpx.c b/source/fitz/load-jpx.c
index 49d7a811..da9ce087 100644
--- a/source/fitz/load-jpx.c
+++ b/source/fitz/load-jpx.c
@@ -575,7 +575,7 @@ void opj_free(void *ptr)
fz_free(ctx, ptr);
}
-void * opj_aligned_malloc(size_t size)
+static void * opj_aligned_malloc_n(size_t alignment, size_t size)
{
uint8_t *ptr;
int off;
@@ -583,15 +583,25 @@ void * opj_aligned_malloc(size_t size)
if (size == 0)
return NULL;
- size += 16 + sizeof(uint8_t);
+ size += alignment + sizeof(uint8_t);
ptr = opj_malloc(size);
if (ptr == NULL)
return NULL;
- off = 16-(((int)(intptr_t)ptr) & 15);
+ off = alignment-(((int)(intptr_t)ptr) & (alignment - 1));
ptr[off-1] = off;
return ptr + off;
}
+void * opj_aligned_malloc(size_t size)
+{
+ return opj_aligned_malloc_n(16, size);
+}
+
+void * opj_aligned_32_malloc(size_t size)
+{
+ return opj_aligned_malloc_n(32, size);
+}
+
void opj_aligned_free(void* ptr_)
{
uint8_t *ptr = (uint8_t *)ptr_;
diff --git a/thirdparty/openjpeg b/thirdparty/openjpeg
-Subproject 19b3d33e7547682364a36a51e61ae38e068262a
+Subproject 0c286d07292f780b2a154e9b47c2a675decf204