summaryrefslogtreecommitdiffstats
path: root/hostTools/lzma/compress/AriBitCoder.cpp
blob: ade188820817630295e9ede40405f6a726fa72e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "AriBitCoder.h"
#include "AriPrice.h"

#include <cmath>

namespace NCompression {
namespace NArithmetic {

static const double kDummyMultMid = (1.0 / kBitPrice) / 2;

CPriceTables::CPriceTables()
{
  double aLn2 = log(2);
  double aLnAll = log(kBitModelTotal >> kNumMoveReducingBits);
  for(UINT32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++)
    m_StatePrices[i] = UINT32((fabs(aLnAll - log(i)) / aLn2 + kDummyMultMid) * kBitPrice);
}

CPriceTables g_PriceTables;

}}