From 2852ce07c4e5b1053420cbf375e098e09faf679c Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Thu, 10 Mar 2016 11:06:16 -0800 Subject: openjpeg: Don't build with SSE instrinsics for 32-bit x86. Fixes 32-bit clang-cl build. These intrinsics require addresses with 16-byte alignment, which doesn't cause issues for 64-bit builds because of allocator alignment. MSVC doesn't recognise the __SSE__, __SSE2__ defines, which is why this problem never surfaced before. R=tsepez@chromium.org BUG=pdfium:433 Review URL: https://codereview.chromium.org/1783813003 . --- third_party/libopenjpeg20/0012-mct_sse.patch | 60 ++++++++++++++++++++++++++++ third_party/libopenjpeg20/README.pdfium | 1 + third_party/libopenjpeg20/mct.c | 17 ++++---- 3 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 third_party/libopenjpeg20/0012-mct_sse.patch (limited to 'third_party/libopenjpeg20') diff --git a/third_party/libopenjpeg20/0012-mct_sse.patch b/third_party/libopenjpeg20/0012-mct_sse.patch new file mode 100644 index 0000000000..bf08276764 --- /dev/null +++ b/third_party/libopenjpeg20/0012-mct_sse.patch @@ -0,0 +1,60 @@ +diff --git a/third_party/libopenjpeg20/mct.c b/third_party/libopenjpeg20/mct.c +index 8b0276f..7731c15 100644 +--- a/third_party/libopenjpeg20/mct.c ++++ b/third_party/libopenjpeg20/mct.c +@@ -37,13 +37,16 @@ + * POSSIBILITY OF SUCH DAMAGE. + */ + +-#ifdef __SSE__ ++#if defined(__SSE__) && !defined(_M_IX86) && !defined(__i386) ++#define USE_SSE + #include + #endif +-#ifdef __SSE2__ ++#if defined(__SSE2__) && !defined(_M_IX86) && !defined(__i386) ++#define USE_SSE2 + #include + #endif +-#ifdef __SSE4_1__ ++#if defined(__SSE4_1__) && !defined(_M_IX86) && !defined(__i386) ++#define USE_SSE4 + #include + #endif + +@@ -72,7 +75,7 @@ const OPJ_FLOAT64 * opj_mct_get_mct_norms_real () + /* */ + /* Forward reversible MCT. */ + /* */ +-#ifdef __SSE2__ ++#ifdef USE_SSE2 + void opj_mct_encode( + OPJ_INT32* restrict c0, + OPJ_INT32* restrict c1, +@@ -137,7 +140,7 @@ void opj_mct_encode( + /* */ + /* Inverse reversible MCT. */ + /* */ +-#ifdef __SSE2__ ++#ifdef USE_SSE2 + void opj_mct_decode( + OPJ_INT32* restrict c0, + OPJ_INT32* restrict c1, +@@ -204,7 +207,7 @@ OPJ_FLOAT64 opj_mct_getnorm(OPJ_UINT32 compno) { + /* */ + /* Forward irreversible MCT. */ + /* */ +-#ifdef __SSE4_1__ ++#ifdef USE_SSE4 + void opj_mct_encode_real( + OPJ_INT32* restrict c0, + OPJ_INT32* restrict c1, +@@ -377,7 +380,7 @@ void opj_mct_decode_real( + OPJ_UINT32 n) + { + OPJ_UINT32 i; +-#ifdef __SSE__ ++#ifdef USE_SSE + __m128 vrv, vgu, vgv, vbu; + vrv = _mm_set1_ps(1.402f); + vgu = _mm_set1_ps(0.34413f); diff --git a/third_party/libopenjpeg20/README.pdfium b/third_party/libopenjpeg20/README.pdfium index 0a60ed7691..cec6064ea2 100644 --- a/third_party/libopenjpeg20/README.pdfium +++ b/third_party/libopenjpeg20/README.pdfium @@ -21,4 +21,5 @@ Local Modifications: 0009-opj_pi_next.patch: Fix potential bad precno value in opj_pi_next* functions. 0010-pi_update_decode_poc.patch: Set proper upper bound for an array in opj_pi_update_decode_poc(). 0011-j2k_update_image_data.patch: Prevent bad signed -> unsigned casting. +0012-mct_sse.patch: Don't use SSE intrinsics in 32-bit builds. TODO(thestig): List all the other patches. diff --git a/third_party/libopenjpeg20/mct.c b/third_party/libopenjpeg20/mct.c index 8b0276f32d..7731c15ddb 100644 --- a/third_party/libopenjpeg20/mct.c +++ b/third_party/libopenjpeg20/mct.c @@ -37,13 +37,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __SSE__ +#if defined(__SSE__) && !defined(_M_IX86) && !defined(__i386) +#define USE_SSE #include #endif -#ifdef __SSE2__ +#if defined(__SSE2__) && !defined(_M_IX86) && !defined(__i386) +#define USE_SSE2 #include #endif -#ifdef __SSE4_1__ +#if defined(__SSE4_1__) && !defined(_M_IX86) && !defined(__i386) +#define USE_SSE4 #include #endif @@ -72,7 +75,7 @@ const OPJ_FLOAT64 * opj_mct_get_mct_norms_real () /* */ /* Forward reversible MCT. */ /* */ -#ifdef __SSE2__ +#ifdef USE_SSE2 void opj_mct_encode( OPJ_INT32* restrict c0, OPJ_INT32* restrict c1, @@ -137,7 +140,7 @@ void opj_mct_encode( /* */ /* Inverse reversible MCT. */ /* */ -#ifdef __SSE2__ +#ifdef USE_SSE2 void opj_mct_decode( OPJ_INT32* restrict c0, OPJ_INT32* restrict c1, @@ -204,7 +207,7 @@ OPJ_FLOAT64 opj_mct_getnorm(OPJ_UINT32 compno) { /* */ /* Forward irreversible MCT. */ /* */ -#ifdef __SSE4_1__ +#ifdef USE_SSE4 void opj_mct_encode_real( OPJ_INT32* restrict c0, OPJ_INT32* restrict c1, @@ -377,7 +380,7 @@ void opj_mct_decode_real( OPJ_UINT32 n) { OPJ_UINT32 i; -#ifdef __SSE__ +#ifdef USE_SSE __m128 vrv, vgu, vgv, vbu; vrv = _mm_set1_ps(1.402f); vgu = _mm_set1_ps(0.34413f); -- cgit v1.2.3