mirror of
https://github.com/webmproject/libwebp.git
synced 2025-02-13 15:32:53 +01:00
near_lossless,FindClosestDiscretized: use unsigned ops
quiets undefined sanitizer warnings of the form: left shift of 128 by 24 places cannot be represented in type 'int' Change-Id: I8a389f2ac9238513517180f302f759425eeb7262
This commit is contained in:
parent
972104b34b
commit
f1784aee04
@ -26,9 +26,9 @@
|
||||
|
||||
// Quantizes the value up or down to a multiple of 1<<bits (or to 255),
|
||||
// choosing the closer one, resolving ties using bankers' rounding.
|
||||
static int FindClosestDiscretized(int a, int bits) {
|
||||
const int mask = (1 << bits) - 1;
|
||||
const int biased = a + (mask >> 1) + ((a >> bits) & 1);
|
||||
static uint32_t FindClosestDiscretized(uint32_t a, int bits) {
|
||||
const uint32_t mask = (1 << bits) - 1;
|
||||
const uint32_t biased = a + (mask >> 1) + ((a >> bits) & 1);
|
||||
assert(bits > 0);
|
||||
if (biased > 0xff) return 0xff;
|
||||
return biased & ~mask;
|
||||
|
Loading…
x
Reference in New Issue
Block a user