other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderOpt.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:c568e458cbdc
1 // Compress/RangeCoder/RangeCoderOpt.h
2
3 #ifndef __COMPRESS_RANGECODER_OPT_H
4 #define __COMPRESS_RANGECODER_OPT_H
5
6 #define RC_INIT_VAR \
7 UInt32 range = rangeDecoder->Range; \
8 UInt32 code = rangeDecoder->Code;
9
10 #define RC_FLUSH_VAR \
11 rangeDecoder->Range = range; \
12 rangeDecoder->Code = code;
13
14 #define RC_NORMALIZE \
15 if (range < NCompress::NRangeCoder::kTopValue) \
16 { code = (code << 8) | rangeDecoder->Stream.ReadByte(); range <<= 8; }
17
18 #define RC_GETBIT2(numMoveBits, prob, mi, A0, A1) \
19 { UInt32 bound = (range >> NCompress::NRangeCoder::kNumBitModelTotalBits) * prob; \
20 if (code < bound) \
21 { A0; range = bound; \
22 prob += (NCompress::NRangeCoder::kBitModelTotal - prob) >> numMoveBits; \
23 mi <<= 1; } \
24 else \
25 { A1; range -= bound; code -= bound; prob -= (prob) >> numMoveBits; \
26 mi = (mi + mi) + 1; }} \
27 RC_NORMALIZE
28
29 #define RC_GETBIT(numMoveBits, prob, mi) RC_GETBIT2(numMoveBits, prob, mi, ; , ;)
30
31 #endif

mercurial