rationalize use of color-cache

* ~1-4% faster
* if it's not used, don't use it
* remove the special handling of cache_bits = 0
* remove some tests in the loops

Change-Id: I19d87c3ca731052ff532ea8b2d8e89816507b75f
This commit is contained in:
Pascal Massimino
2012-08-01 00:32:12 -07:00
parent 7d732f905b
commit 906be65744
2 changed files with 70 additions and 40 deletions

View File

@ -21,11 +21,9 @@ extern "C" {
// VP8LColorCache.
int VP8LColorCacheInit(VP8LColorCache* const cc, int hash_bits) {
int hash_size;
const int hash_size = 1 << hash_bits;
assert(cc != NULL);
if (hash_bits == 0) hash_bits = 1;
hash_size = 1 << hash_bits;
assert(hash_bits > 0);
cc->colors_ = (uint32_t*)calloc(hash_size, sizeof(*cc->colors_));
if (cc->colors_ == NULL) return 0;
cc->hash_shift_ = 32 - hash_bits;