Commit f0b84b50 authored by Jorge Lucangeli Obes's avatar Jorge Lucangeli Obes Committed by Commit Bot

Fix -Wshift-negative-value errors.

BUG=706832
TEST=Remove -Wno-shift-negative-values from Chrome OS build.
TEST=Build Chrome for Chrome OS, no warnings/errors.

Change-Id: Icb4f50452d87a8b2dc680752a2bb965f31c33639
Reviewed-on: https://chromium-review.googlesource.com/544198Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Jorge Lucangeli Obes <jorgelo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#481657}
parent 84bbf436
...@@ -8,7 +8,7 @@ License Android Compatible: yes ...@@ -8,7 +8,7 @@ License Android Compatible: yes
Description: Description:
This contains a copy of libjpeg-6b. This contains a copy of libjpeg-6b.
The project files does not incldue from the distribution: The project files does not include from the distribution:
jidctred.c : downsampling jidctred.c : downsampling
jdtrans.c : decoder transcoder jdtrans.c : decoder transcoder
...@@ -23,3 +23,6 @@ avoid conflicts that arise when system libraries attempt to use our libjpeg. ...@@ -23,3 +23,6 @@ avoid conflicts that arise when system libraries attempt to use our libjpeg.
Also patch in google.jdmarker.patch to better handle multiple SOS CSi values and Also patch in google.jdmarker.patch to better handle multiple SOS CSi values and
their ordering. their ordering.
Also patch in google.shift-negative-values.patch to fix -Wshift-negative-value
errors.
diff --git a/third_party/libjpeg/jdphuff.c b/third_party/libjpeg/jdphuff.c
index 22678099451a..32df3af76707 100644
--- a/third_party/libjpeg/jdphuff.c
+++ b/third_party/libjpeg/jdphuff.c
@@ -195,26 +195,22 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
/*
* Figure F.12: extend sign bit.
- * On some machines, a shift and add will be faster than a table lookup.
+ * On some machines, a shift and sub will be faster than a table lookup.
*/
#ifdef AVOID_TABLES
-#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x))
+#define BIT_MASK(nbits) ((1<<(nbits))-1)
+#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) - ((1<<(s))-1) : (x))
#else
-#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
+#define BIT_MASK(nbits) bmask[nbits]
+#define HUFF_EXTEND(x,s) ((x) <= bmask[(s) - 1] ? (x) - bmask[s] : (x))
-static const int extend_test[16] = /* entry n is 2**(n-1) */
- { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
- 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };
-
-static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
- { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,
- ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,
- ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,
- ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
+static const int bmask[16] = /* bmask[n] is mask for n rightmost bits */
+ { 0, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF,
+ 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF };
#endif /* AVOID_TABLES */
...@@ -195,26 +195,22 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo) ...@@ -195,26 +195,22 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
/* /*
* Figure F.12: extend sign bit. * Figure F.12: extend sign bit.
* On some machines, a shift and add will be faster than a table lookup. * On some machines, a shift and sub will be faster than a table lookup.
*/ */
#ifdef AVOID_TABLES #ifdef AVOID_TABLES
#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) #define BIT_MASK(nbits) ((1<<(nbits))-1)
#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) - ((1<<(s))-1) : (x))
#else #else
#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) #define BIT_MASK(nbits) bmask[nbits]
#define HUFF_EXTEND(x,s) ((x) <= bmask[(s) - 1] ? (x) - bmask[s] : (x))
static const int extend_test[16] = /* entry n is 2**(n-1) */ static const int bmask[16] = /* bmask[n] is mask for n rightmost bits */
{ 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, { 0, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF,
0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF };
static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
{ 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,
((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,
((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,
((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
#endif /* AVOID_TABLES */ #endif /* AVOID_TABLES */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment