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

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial