mirror of
https://github.com/google/brotli.git
synced 2024-11-25 21:10:05 +00:00
Merge pull request #123 from szabadka/master
Fix some VS compilation errors in the encoder.
This commit is contained in:
commit
9c9bb00f7f
@ -17,13 +17,15 @@
|
||||
#include "./backward_references.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
#include "./command.h"
|
||||
#include "./fast_log.h"
|
||||
|
||||
namespace brotli {
|
||||
|
||||
static const double kInfinity = 1.0 / 0.0;
|
||||
static const double kInfinity = std::numeric_limits<double>::infinity();
|
||||
|
||||
// Histogram based cost model for zopflification.
|
||||
class ZopfliCostModel {
|
||||
@ -130,18 +132,19 @@ class ZopfliCostModel {
|
||||
private:
|
||||
void Set(const std::vector<int>& histogram, std::vector<double>* cost) {
|
||||
cost->resize(histogram.size());
|
||||
double sum = 0;
|
||||
int sum = 0;
|
||||
for (size_t i = 0; i < histogram.size(); i++) {
|
||||
sum += histogram[i];
|
||||
}
|
||||
double log2sum = FastLog2(sum);
|
||||
for (size_t i = 0; i < histogram.size(); i++) {
|
||||
if (histogram[i] == 0) {
|
||||
(*cost)[i] = -log2(0.25 / sum);
|
||||
(*cost)[i] = log2sum + 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Shannon bits for this symbol.
|
||||
(*cost)[i] = -log2(histogram[i] / sum);
|
||||
(*cost)[i] = log2sum - FastLog2(histogram[i]);
|
||||
|
||||
// Cannot be coded with less than 1 bit
|
||||
if ((*cost)[i] < 1) (*cost)[i] = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user