Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Unified Diff: third_party/libwebp/utils/color_cache_utils.h

Issue 2651883004: libwebp-0.6.0-rc1 (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libwebp/utils/color_cache.c ('k') | third_party/libwebp/utils/color_cache_utils.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libwebp/utils/color_cache_utils.h
diff --git a/third_party/libwebp/utils/color_cache.h b/third_party/libwebp/utils/color_cache_utils.h
similarity index 85%
rename from third_party/libwebp/utils/color_cache.h
rename to third_party/libwebp/utils/color_cache_utils.h
index a9a9f64270fe18f630ecdd36073d8f3e85d1db59..c373e6b3610676d6a179be4fd3b2977406d0bc1f 100644
--- a/third_party/libwebp/utils/color_cache.h
+++ b/third_party/libwebp/utils/color_cache_utils.h
@@ -28,7 +28,11 @@ typedef struct {
int hash_bits_;
} VP8LColorCache;
-static const uint32_t kHashMul = 0x1e35a7bd;
+static const uint64_t kHashMul = 0x1e35a7bdull;
+
+static WEBP_INLINE int HashPix(uint32_t argb, int shift) {
+ return (int)(((argb * kHashMul) & 0xffffffffu) >> shift);
+}
static WEBP_INLINE uint32_t VP8LColorCacheLookup(
const VP8LColorCache* const cc, uint32_t key) {
@@ -44,19 +48,20 @@ static WEBP_INLINE void VP8LColorCacheSet(const VP8LColorCache* const cc,
static WEBP_INLINE void VP8LColorCacheInsert(const VP8LColorCache* const cc,
uint32_t argb) {
- const uint32_t key = (kHashMul * argb) >> cc->hash_shift_;
+ const int key = HashPix(argb, cc->hash_shift_);
cc->colors_[key] = argb;
}
static WEBP_INLINE int VP8LColorCacheGetIndex(const VP8LColorCache* const cc,
uint32_t argb) {
- return (kHashMul * argb) >> cc->hash_shift_;
+ return HashPix(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 uint32_t key = (kHashMul * argb) >> cc->hash_shift_;
- return (cc->colors_[key] == argb);
+ const int key = HashPix(argb, cc->hash_shift_);
+ return (cc->colors_[key] == argb) ? key : -1;
}
//------------------------------------------------------------------------------
« no previous file with comments | « third_party/libwebp/utils/color_cache.c ('k') | third_party/libwebp/utils/color_cache_utils.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698