From 54dad7e553c6a831ef83b1181b96835d5e9dfbc8 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Tue, 17 Apr 2012 10:07:34 +0000 Subject: [PATCH] Color cache size should be counted as 0 when cache bits = 0 Change-Id: I1d05e0561a92aebaf62162fe11ffc4b12496d698 --- src/enc/vp8l.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/enc/vp8l.c b/src/enc/vp8l.c index 0a62e57a..eb59e097 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -743,7 +743,8 @@ static int EncodeImageInternal(VP8LBitWriter* const bw, uint16_t** bit_codes = NULL; const int use_2d_locality = 1; int backward_refs_size; - const int use_color_cache = cache_bits ? 1 : 0; + const int use_color_cache = (cache_bits > 0) ? 1 : 0; + const int color_cache_size = use_color_cache ? (1 << cache_bits) : 0; const int histogram_image_xysize = VP8LSubSampleSize(width, histogram_bits) * VP8LSubSampleSize(height, histogram_bits); VP8LHistogram** histogram_image; @@ -826,7 +827,7 @@ static int EncodeImageInternal(VP8LBitWriter* const bw, for (k = 0; k < 5; ++k) { const uint8_t* const cur_bit_lengths = bit_lengths[5 * i + k]; const int cur_bit_lengths_size = (k == 0) ? - 256 + kLengthCodes + (1 << cache_bits) : + 256 + kLengthCodes + color_cache_size : bit_lengths_sizes[5 * i + k]; if (!StoreHuffmanCode(bw, cur_bit_lengths, cur_bit_lengths_size)) { goto Error;