Merge pull request #233 from szabadka/master

Fix integer overflow and slowness in entropy estimation.
This commit is contained in:
szabadka 2015-10-23 11:54:56 +02:00
commit 9f7e4ce34f

View File

@ -389,7 +389,7 @@ bool BrotliCompressor::WriteMetaBlockInternal(const bool is_last,
static const int kSampleRate = 13;
static const double kMinEntropy = 7.92;
const double bit_cost_threshold = bytes * kMinEntropy / kSampleRate;
for (int i = last_flush_pos_; i < input_pos_; i += kSampleRate) {
for (size_t i = last_flush_pos_; i < input_pos_; i += kSampleRate) {
++literal_histo[data[i & mask]];
}
if (BitsEntropy(literal_histo, 256) > bit_cost_threshold) {