public byte GetQualByte(long pos) { int res = 0; bits.Read(out res, pos, 8); return((byte)res); }
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); }
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); }