Merge pull request #4324 from FernetMenta/wasapi
[vuplus_xbmc] / lib / UnrarXLib / coder.cpp
1
2
3 inline unsigned int RangeCoder::GetChar()
4 {
5   return(UnpackRead->GetChar());
6 }
7
8
9 void RangeCoder::InitDecoder(Unpack *UnpackRead)
10 {
11   RangeCoder::UnpackRead=UnpackRead;
12
13   low=code=0;
14   range=uint(-1);
15   for (int i=0;i < 4;i++)
16     code=(code << 8) | GetChar();
17 }
18
19
20 #define ARI_DEC_NORMALIZE(code,low,range,read)                             \
21 {                                                                          \
22   while ((low^(low+range))<TOP || (range<BOT && ((range=-low&(BOT-1)),1))) \
23   {                                                                        \
24     code=(code << 8) | read->GetChar();                                    \
25     range <<= 8;                                                           \
26     low <<= 8;                                                             \
27   }                                                                        \
28 }
29
30
31 inline int RangeCoder::GetCurrentCount() 
32 {
33   return (code-low)/(range /= SubRange.scale);
34 }
35
36
37 inline uint RangeCoder::GetCurrentShiftCount(uint SHIFT) 
38 {
39   return (code-low)/(range >>= SHIFT);
40 }
41
42
43 inline void RangeCoder::Decode()
44 {
45   low += range*SubRange.LowCount;
46   range *= SubRange.HighCount-SubRange.LowCount;
47 }