Better estimate of the cache cost.

Change-Id: I171a8f80f1597bbdeb724957e789b947df3c2885
This commit is contained in:
Vincent Rabaud 2020-06-05 16:07:58 +02:00
parent 4f9f00ccf4
commit 749a8b99f7

View File

@ -753,12 +753,18 @@ static int CalculateBestCacheSize(const uint32_t* argb, int quality,
}
}
} else {
int code, extra_bits, extra_bits_value;
// We should compute the contribution of the (distance,length)
// histograms but those are the same independently from the cache size.
// As those constant contributions are in the end added to the other
// histogram contributions, we can safely ignore them.
// histogram contributions, we can ignore them, except for the length
// prefix that is part of the literal_ histogram.
int len = PixOrCopyLength(v);
uint32_t argb_prev = *argb ^ 0xffffffffu;
VP8LPrefixEncode(len, &code, &extra_bits, &extra_bits_value);
for (i = 0; i <= cache_bits_max; ++i) {
++histos[i]->literal_[NUM_LITERAL_CODES + code];
}
// Update the color caches.
do {
if (*argb != argb_prev) {