diff --git a/3005237a5d68d1e1f465d925040a9507f55e8895.patch b/3005237.patch similarity index 83% rename from 3005237a5d68d1e1f465d925040a9507f55e8895.patch rename to 3005237.patch index d3ea4df..d9a5f05 100644 --- a/3005237a5d68d1e1f465d925040a9507f55e8895.patch +++ b/3005237.patch @@ -5,11 +5,9 @@ Subject: [PATCH] ReadWebP: fix for big-endian Change-Id: I36b3c12ccf02eb5dad350c460387c0528fff8df3 --- - imageio/webpdec.c | 8 ++++++++ - 1 file changed, 8 insertions(+) diff --git a/imageio/webpdec.c b/imageio/webpdec.c -index 15d87ea44..82f646db3 100644 +index 15d87ea..82f646d 100644 --- a/imageio/webpdec.c +++ b/imageio/webpdec.c @@ -9,6 +9,10 @@ @@ -23,7 +21,7 @@ index 15d87ea44..82f646db3 100644 #include "./webpdec.h" #include -@@ -150,7 +154,11 @@ int ReadWebP(const uint8_t* const data, size_t data_size, +@@ -150,7 +154,11 @@ break; } if (pic->use_argb) { diff --git a/d51d03e.patch b/d51d03e.patch new file mode 100644 index 0000000..c23efdf --- /dev/null +++ b/d51d03e.patch @@ -0,0 +1,96 @@ +From d51d03edd54d01aee638ac6f294c2ae105ff2929 Mon Sep 17 00:00:00 2001 +From: Pascal Massimino +Date: Thu, 15 Feb 2018 21:44:39 -0800 +Subject: [PATCH] fix for BigEndian import + ++ simplification of the logic + +Change-Id: Ia20ce844793ed35ea03a17cef45838f3d0ae4afa +--- + +diff --git a/src/enc/picture_csp_enc.c b/src/enc/picture_csp_enc.c +index d531dd0..7444094 100644 +--- a/src/enc/picture_csp_enc.c ++++ b/src/enc/picture_csp_enc.c +@@ -11,6 +11,10 @@ + // + // Author: Skal (pascal.massimino@gmail.com) + ++#ifdef HAVE_CONFIG_H ++#include "src/webp/config.h" ++#endif ++ + #include + #include + #include +@@ -28,11 +32,11 @@ + // If defined, use table to compute x / alpha. + #define USE_INVERSE_ALPHA_TABLE + +-static const union { +- uint32_t argb; +- uint8_t bytes[4]; +-} test_endian = { 0xff000000u }; +-#define ALPHA_IS_LAST (test_endian.bytes[3] == 0xff) ++#ifdef WORDS_BIGENDIAN ++#define ALPHA_OFFSET 0 // uint32_t 0xff000000 is 0xff,00,00,00 in memory ++#else ++#define ALPHA_OFFSET 3 // uint32_t 0xff000000 is 0x00,00,00,ff in memory ++#endif + + //------------------------------------------------------------------------------ + // Detection of non-trivial transparency +@@ -61,7 +65,7 @@ + return CheckNonOpaque(picture->a, picture->width, picture->height, + 1, picture->a_stride); + } else { +- const int alpha_offset = ALPHA_IS_LAST ? 3 : 0; ++ const int alpha_offset = ALPHA_OFFSET; + return CheckNonOpaque((const uint8_t*)picture->argb + alpha_offset, + picture->width, picture->height, + 4, picture->argb_stride * sizeof(*picture->argb)); +@@ -990,10 +994,10 @@ + return WebPEncodingSetError(picture, VP8_ENC_ERROR_INVALID_CONFIGURATION); + } else { + const uint8_t* const argb = (const uint8_t*)picture->argb; +- const uint8_t* const r = ALPHA_IS_LAST ? argb + 2 : argb + 1; +- const uint8_t* const g = ALPHA_IS_LAST ? argb + 1 : argb + 2; +- const uint8_t* const b = ALPHA_IS_LAST ? argb + 0 : argb + 3; +- const uint8_t* const a = ALPHA_IS_LAST ? argb + 3 : argb + 0; ++ const uint8_t* const a = argb + (0 ^ ALPHA_OFFSET); ++ const uint8_t* const r = argb + (1 ^ ALPHA_OFFSET); ++ const uint8_t* const g = argb + (2 ^ ALPHA_OFFSET); ++ const uint8_t* const b = argb + (3 ^ ALPHA_OFFSET); + + picture->colorspace = WEBP_YUV420; + return ImportYUVAFromRGBA(r, g, b, a, 4, 4 * picture->argb_stride, +@@ -1044,7 +1048,8 @@ + const int argb_stride = 4 * picture->argb_stride; + uint8_t* dst = (uint8_t*)picture->argb; + const uint8_t *cur_u = picture->u, *cur_v = picture->v, *cur_y = picture->y; +- WebPUpsampleLinePairFunc upsample = WebPGetLinePairConverter(ALPHA_IS_LAST); ++ WebPUpsampleLinePairFunc upsample = ++ WebPGetLinePairConverter(ALPHA_OFFSET > 0); + + // First row, with replicated top samples. + upsample(cur_y, NULL, cur_u, cur_v, cur_u, cur_v, dst, NULL, width); +@@ -1087,6 +1092,7 @@ + const uint8_t* rgb, int rgb_stride, + int step, int swap_rb, int import_alpha) { + int y; ++ // swap_rb -> b,g,r,a , !swap_rb -> r,g,b,a + const uint8_t* r_ptr = rgb + (swap_rb ? 2 : 0); + const uint8_t* g_ptr = rgb + 1; + const uint8_t* b_ptr = rgb + (swap_rb ? 0 : 2); +@@ -1104,9 +1110,9 @@ + WebPInitAlphaProcessing(); + + if (import_alpha) { ++ // dst[] byte order is {a,r,g,b} for big-endian, {b,g,r,a} for little endian + uint32_t* dst = picture->argb; +- const int do_copy = +- (!swap_rb && !ALPHA_IS_LAST) || (swap_rb && ALPHA_IS_LAST); ++ const int do_copy = (ALPHA_OFFSET == 3) && swap_rb; + assert(step == 4); + for (y = 0; y < height; ++y) { + if (do_copy) { diff --git a/libwebp.spec b/libwebp.spec index 7c4f560..308582a 100644 --- a/libwebp.spec +++ b/libwebp.spec @@ -2,15 +2,16 @@ Name: libwebp Version: 0.6.1 -Release: 5%{?dist} +Release: 6%{?dist} URL: http://webmproject.org/ Summary: Library and tools for the WebP graphics format # Additional IPR is licensed as well. See PATENTS file for details License: BSD Source0: http://downloads.webmproject.org/releases/webp/%{name}-%{version}.tar.gz Source1: libwebp_jni_example.java -# Backport upstream big-endian fix -Patch0: 3005237a5d68d1e1f465d925040a9507f55e8895.patch +# Backport upstream big-endian fixes +Patch0: 3005237.patch +Patch1: d51d03e.patch BuildRequires: libjpeg-devel BuildRequires: libpng-devel @@ -142,6 +143,9 @@ cp swig/*.jar swig/*.so %{buildroot}/%{_libdir}/%{name}-java/ %changelog +* Fri Feb 16 2018 Sandro Mani - 0.6.1-6 +- Backport another big-endian fix + * Fri Feb 16 2018 Sandro Mani - 0.6.1-5 - Backport upstream big-endian fix