summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libwebp/src/utils/color_cache_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/libwebp/src/utils/color_cache_utils.h')
-rw-r--r--src/3rdparty/libwebp/src/utils/color_cache_utils.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/3rdparty/libwebp/src/utils/color_cache_utils.h b/src/3rdparty/libwebp/src/utils/color_cache_utils.h
index c373e6b..ec21d51 100644
--- a/src/3rdparty/libwebp/src/utils/color_cache_utils.h
+++ b/src/3rdparty/libwebp/src/utils/color_cache_utils.h
@@ -12,10 +12,13 @@
// Authors: Jyrki Alakuijala (jyrki@google.com)
// Urvang Joshi (urvang@google.com)
-#ifndef WEBP_UTILS_COLOR_CACHE_H_
-#define WEBP_UTILS_COLOR_CACHE_H_
+#ifndef WEBP_UTILS_COLOR_CACHE_UTILS_H_
+#define WEBP_UTILS_COLOR_CACHE_UTILS_H_
-#include "../webp/types.h"
+#include <assert.h>
+
+#include "src/dsp/dsp.h"
+#include "src/webp/types.h"
#ifdef __cplusplus
extern "C" {
@@ -28,10 +31,11 @@ typedef struct {
int hash_bits_;
} VP8LColorCache;
-static const uint64_t kHashMul = 0x1e35a7bdull;
+static const uint32_t kHashMul = 0x1e35a7bdu;
-static WEBP_INLINE int HashPix(uint32_t argb, int shift) {
- return (int)(((argb * kHashMul) & 0xffffffffu) >> shift);
+static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE
+int VP8LHashPix(uint32_t argb, int shift) {
+ return (int)((argb * kHashMul) >> shift);
}
static WEBP_INLINE uint32_t VP8LColorCacheLookup(
@@ -48,19 +52,19 @@ 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 int key = VP8LHashPix(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 VP8LHashPix(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_);
+ const int key = VP8LHashPix(argb, cc->hash_shift_);
return (cc->colors_[key] == argb) ? key : -1;
}
@@ -82,4 +86,4 @@ void VP8LColorCacheClear(VP8LColorCache* const color_cache);
}
#endif
-#endif // WEBP_UTILS_COLOR_CACHE_H_
+#endif // WEBP_UTILS_COLOR_CACHE_UTILS_H_