Coverage Report

Created: 2025-04-11 06:56

/src/unrar/coder.cpp
Line
Count
Source
1
2
3
inline byte RangeCoder::GetChar()
4
10.9k
{
5
10.9k
  return UnpackRead->GetChar();
6
10.9k
}
7
8
9
void RangeCoder::InitDecoder(Unpack *UnpackRead)
10
2.74k
{
11
2.74k
  RangeCoder::UnpackRead=UnpackRead;
12
13
2.74k
  low=code=0;
14
2.74k
  range=0xffffffff;
15
13.7k
  for (uint i = 0; i < 4; i++)
16
10.9k
    code=(code << 8) | GetChar();
17
2.74k
}
18
19
20
// (int) cast before "low" added only to suppress compiler warnings.
21
44.2M
#define ARI_DEC_NORMALIZE(code,low,range,read)                           \
22
44.2M
{                                                                        \
23
47.0M
  while ((low^(low+range))<TOP || range<BOT && ((range=-(int)low&(BOT-1)),1)) \
24
44.2M
  {                                                                      \
25
2.79M
    code=(code << 8) | read->GetChar();                                  \
26
2.79M
    range <<= 8;                                                         \
27
2.79M
    low <<= 8;                                                           \
28
2.79M
  }                                                                      \
29
44.2M
}
30
31
32
inline int RangeCoder::GetCurrentCount() 
33
8.11M
{
34
8.11M
  return (code-low)/(range /= SubRange.scale);
35
8.11M
}
36
37
38
inline uint RangeCoder::GetCurrentShiftCount(uint SHIFT) 
39
36.1M
{
40
36.1M
  return (code-low)/(range >>= SHIFT);
41
36.1M
}
42
43
44
inline void RangeCoder::Decode()
45
44.2M
{
46
44.2M
  low += range*SubRange.LowCount;
47
44.2M
  range *= SubRange.HighCount-SubRange.LowCount;
48
44.2M
}