Exemplo n.º 1
0
        public byte GetQualByte(long pos)
        {
            int res = 0;

            bits.Read(out res, pos, 8);
            return((byte)res);
        }
Exemplo n.º 2
0
        public bool GetBitsAsInt(ref int res, ref long pos, int count)
        {
            bool hasGotten = bits.Read(out res, pos, count);

            if (hasGotten)
            {
                pos += count;
            }
            return(hasGotten);
        }
Exemplo n.º 3
0
        public bool GetSeqBitsAsInt(ref int res, ref long pos, int count)
        {
            long         wantedByte = pos / UNIT_WINDOW;
            MemoryStream bytes      = new MemoryStream(2);

            if (HasSeqLeft(wantedByte, 1))
            {
                byte b = GetSeqByte(wantedByte++);
                bytes.WriteByte(b);
                //Console.Error.WriteLine("GetBitASInts {0} {1} {2}", pos, count, b);
            }
            else
            {
                return(false);
            }
            int wantedBit = (int)(pos % UNIT_WINDOW);

            if (wantedBit + count >= 8)
            {
                if (HasSeqLeft(wantedByte, 1))
                {
                    byte b = GetSeqByte(wantedByte);
                    bytes.WriteByte(b);
                    //Console.Error.WriteLine("GetBitASInts2 {0} {1} {2}", pos, count, b);
                }
                else
                {
                    return(false);
                }
            }

            ReadBitShepherd bits = new ReadBitShepherd(bytes);
            //Console.Error.WriteLine("Shepherd reading {0} {1}", bytes.Length, pos);
            bool hasGotten = bits.Read(out res, wantedBit, count);

            if (hasGotten)
            {
                pos += count;
            }
            //Console.Error.WriteLine("For seq gotten {0} {1}", res, count);

            //Console.Error.WriteLine("Giving back {0}", res);
            return(hasGotten);
        }