RangeCoderOpt.h 953 B

12345678910111213141516171819202122232425262728293031
  1. // Compress/RangeCoder/RangeCoderOpt.h
  2. #ifndef __COMPRESS_RANGECODER_OPT_H
  3. #define __COMPRESS_RANGECODER_OPT_H
  4. #define RC_INIT_VAR \
  5. UInt32 range = rangeDecoder->Range; \
  6. UInt32 code = rangeDecoder->Code;
  7. #define RC_FLUSH_VAR \
  8. rangeDecoder->Range = range; \
  9. rangeDecoder->Code = code;
  10. #define RC_NORMALIZE \
  11. if (range < NCompress::NRangeCoder::kTopValue) \
  12. { code = (code << 8) | rangeDecoder->Stream.ReadByte(); range <<= 8; }
  13. #define RC_GETBIT2(numMoveBits, prob, mi, A0, A1) \
  14. { UInt32 bound = (range >> NCompress::NRangeCoder::kNumBitModelTotalBits) * prob; \
  15. if (code < bound) \
  16. { A0; range = bound; \
  17. prob += (NCompress::NRangeCoder::kBitModelTotal - prob) >> numMoveBits; \
  18. mi <<= 1; } \
  19. else \
  20. { A1; range -= bound; code -= bound; prob -= (prob) >> numMoveBits; \
  21. mi = (mi + mi) + 1; }} \
  22. RC_NORMALIZE
  23. #define RC_GETBIT(numMoveBits, prob, mi) RC_GETBIT2(numMoveBits, prob, mi, ; , ;)
  24. #endif