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.

     1 // Compress/RangeCoder/RangeCoderOpt.h
     3 #ifndef __COMPRESS_RANGECODER_OPT_H
     4 #define __COMPRESS_RANGECODER_OPT_H
     6 #define RC_INIT_VAR \
     7   UInt32 range = rangeDecoder->Range; \
     8   UInt32 code = rangeDecoder->Code;        
    10 #define RC_FLUSH_VAR \
    11   rangeDecoder->Range = range; \
    12   rangeDecoder->Code = code;
    14 #define RC_NORMALIZE \
    15   if (range < NCompress::NRangeCoder::kTopValue) \
    16     { code = (code << 8) | rangeDecoder->Stream.ReadByte(); range <<= 8; }
    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
    29 #define RC_GETBIT(numMoveBits, prob, mi) RC_GETBIT2(numMoveBits, prob, mi, ; , ;)
    31 #endif

mercurial