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

@ -186,9 +186,9 @@ static int GetHuffBitLengthsAndCodes(
const VP8LHistogram* const histo = histogram_image->histograms[i];
HuffmanTreeCode* const codes = &huffman_codes[5 * i];
for (k = 0; k < 5; ++k) {
const int num_symbols = (k == 0) ? VP8LHistogramNumCodes(histo)
: (k == 4) ? NUM_DISTANCE_CODES
: 256;
const int num_symbols =
(k == 0) ? VP8LHistogramNumCodes(histo->palette_code_bits_) :
(k == 4) ? NUM_DISTANCE_CODES : 256;
codes[k].num_symbols = num_symbols;
total_length_size += num_symbols;
}