Revert "fix 'unsigned integer overflow' warnings in ubsan"

This reverts commit e44f5248ff.

contains unintentional changes in quant.c

Change-Id: I1928f072566788b0c9ea80f6fbc9e571061f9b3e
This commit is contained in:
James Zern
2016-08-16 16:54:42 -07:00
parent 9d4f209f80
commit 8a4ebc6ab0
7 changed files with 33 additions and 46 deletions

View File

@ -149,8 +149,7 @@ static WEBP_INLINE int VP8GetBit(VP8BitReader* const br, int prob) {
}
// simplified version of VP8GetBit() for prob=0x80 (note shift is always 1 here)
static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW
WEBP_INLINE int VP8GetSigned(VP8BitReader* const br, int v) {
static WEBP_INLINE int VP8GetSigned(VP8BitReader* const br, int v) {
if (br->bits_ < 0) {
VP8LoadNewBytes(br);
}

View File

@ -28,11 +28,7 @@ typedef struct {
int hash_bits_;
} VP8LColorCache;
static const uint64_t kHashMul = 0x1e35a7bdull;
static WEBP_INLINE int HashPix(uint32_t argb, int shift) {
return (int)(((argb * kHashMul) & 0xffffffffu) >> shift);
}
static const uint32_t kHashMul = 0x1e35a7bd;
static WEBP_INLINE uint32_t VP8LColorCacheLookup(
const VP8LColorCache* const cc, uint32_t key) {
@ -48,20 +44,20 @@ static WEBP_INLINE void VP8LColorCacheSet(const VP8LColorCache* const cc,
static WEBP_INLINE void VP8LColorCacheInsert(const VP8LColorCache* const cc,
uint32_t argb) {
const int key = HashPix(argb, cc->hash_shift_);
const uint32_t key = (kHashMul * argb) >> cc->hash_shift_;
cc->colors_[key] = argb;
}
static WEBP_INLINE int VP8LColorCacheGetIndex(const VP8LColorCache* const cc,
uint32_t argb) {
return HashPix(argb, cc->hash_shift_);
return (kHashMul * argb) >> cc->hash_shift_;
}
// Return the key if cc contains argb, and -1 otherwise.
static WEBP_INLINE int VP8LColorCacheContains(const VP8LColorCache* const cc,
uint32_t argb) {
const int key = HashPix(argb, cc->hash_shift_);
return (cc->colors_[key] == argb) ? key : -1;
const uint32_t key = (kHashMul * argb) >> cc->hash_shift_;
return (cc->colors_[key] == argb) ? (int)key : -1;
}
//------------------------------------------------------------------------------

View File

@ -248,7 +248,7 @@ int WebPGetColorPalette(const WebPPicture* const pic, uint32_t* const palette) {
int num_colors = 0;
uint8_t in_use[COLOR_HASH_SIZE] = { 0 };
uint32_t colors[COLOR_HASH_SIZE];
static const uint64_t kHashMul = 0x1e35a7bdull;
static const uint32_t kHashMul = 0x1e35a7bdU;
const uint32_t* argb = pic->argb;
const int width = pic->width;
const int height = pic->height;
@ -263,7 +263,7 @@ int WebPGetColorPalette(const WebPPicture* const pic, uint32_t* const palette) {
continue;
}
last_pix = argb[x];
key = ((last_pix * kHashMul) & 0xffffffffu) >> COLOR_HASH_RIGHT_SHIFT;
key = (kHashMul * last_pix) >> COLOR_HASH_RIGHT_SHIFT;
while (1) {
if (!in_use[key]) {
colors[key] = last_pix;