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

Decode() public method

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