michael@0: // Compress/RangeCoder/RangeCoderOpt.h michael@0: michael@0: #ifndef __COMPRESS_RANGECODER_OPT_H michael@0: #define __COMPRESS_RANGECODER_OPT_H michael@0: michael@0: #define RC_INIT_VAR \ michael@0: UInt32 range = rangeDecoder->Range; \ michael@0: UInt32 code = rangeDecoder->Code; michael@0: michael@0: #define RC_FLUSH_VAR \ michael@0: rangeDecoder->Range = range; \ michael@0: rangeDecoder->Code = code; michael@0: michael@0: #define RC_NORMALIZE \ michael@0: if (range < NCompress::NRangeCoder::kTopValue) \ michael@0: { code = (code << 8) | rangeDecoder->Stream.ReadByte(); range <<= 8; } michael@0: michael@0: #define RC_GETBIT2(numMoveBits, prob, mi, A0, A1) \ michael@0: { UInt32 bound = (range >> NCompress::NRangeCoder::kNumBitModelTotalBits) * prob; \ michael@0: if (code < bound) \ michael@0: { A0; range = bound; \ michael@0: prob += (NCompress::NRangeCoder::kBitModelTotal - prob) >> numMoveBits; \ michael@0: mi <<= 1; } \ michael@0: else \ michael@0: { A1; range -= bound; code -= bound; prob -= (prob) >> numMoveBits; \ michael@0: mi = (mi + mi) + 1; }} \ michael@0: RC_NORMALIZE michael@0: michael@0: #define RC_GETBIT(numMoveBits, prob, mi) RC_GETBIT2(numMoveBits, prob, mi, ; , ;) michael@0: michael@0: #endif