Merge "rationalize use of color-cache" into 0.2.0

This commit is contained in:
Pascal Massimino
2012-08-01 11:55:36 -07:00
committed by Gerrit Code Review
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;