Skip to content

Commit

Permalink
Better estimate of the cache cost.
Browse files Browse the repository at this point in the history
Change-Id: I171a8f80f1597bbdeb724957e789b947df3c2885
  • Loading branch information
vrabaud committed Jun 5, 2020
1 parent 4f9f00c commit 749a8b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/enc/backward_references_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 749a8b9

Please sign in to comment.