natix.CompactDS.DoublingSearchCoding64.Decode C# (CSharp) Method

Decode() public method

public Decode ( BitStream32 stream, BitStreamCtx ctx ) : long
stream BitStream32
ctx BitStreamCtx
return long
        public long Decode(BitStream32 stream, BitStreamCtx ctx)
        {
            long min = 0;
            long check;
            int galloping = 1;
            while (true) {
                check = (1L << galloping) - 1L;
                if (stream.Read (ctx)) {
                    min = check + 1L;
                    ++galloping;
                } else {
                    if (min == 0L) {
                        return this.SecondCoding.Decode (stream, 2, ctx);
                    } else {
                        return min + this.SecondCoding.Decode (stream, min, ctx);
                    }
                }
            }
        }