Refactor code for HistogramCombine.

Refactor code for HistogramCombine and optimize the code by calculating
the combined entropy and avoid un-necessary Histogram merges.

This speeds up lossless encoding by 1-2% and almost no impact on compression
density.

Change-Id: Iedfcf4c1f3e88077bc77fc7b8c780c4cd5d6362b
This commit is contained in:
Vikas Arora
2014-03-03 13:49:54 -08:00
parent ca1bfff53f
commit b33e8a05ee
4 changed files with 157 additions and 102 deletions

View File

@ -82,9 +82,9 @@ double VP8LHistogramEstimateBits(const VP8LHistogram* const p);
// represent the entropy code itself.
double VP8LHistogramEstimateBitsBulk(const VP8LHistogram* const p);
static WEBP_INLINE int VP8LHistogramNumCodes(const VP8LHistogram* const p) {
static WEBP_INLINE int VP8LHistogramNumCodes(int palette_code_bits) {
return 256 + NUM_LENGTH_CODES +
((p->palette_code_bits_ > 0) ? (1 << p->palette_code_bits_) : 0);
((palette_code_bits > 0) ? (1 << palette_code_bits) : 0);
}
// Builds the histogram image.