public uint PeekInt(int numBits)
        {
            BitStreamUtil.AssertMaxBits(32, numBits);
            Debug.Assert((Offset + numBits) <= (BitsInBuffer + (SLED * 8)), "gg", "This code just fell apart. We're all dead. Offset={0} numBits={1} BitsInBuffer={2}", Offset, numBits, BitsInBuffer);

            return((uint)(((*(ulong *)(PBuffer + ((Offset / 8) & ~3))) << ((8 * 8) - (Offset % (8 * 4)) - numBits)) >> ((8 * 8) - numBits)));
        }
        public int ReadSignedInt(int numBits)
        {
            // Just like PeekInt, but we cast to signed long before the shr because we need to sext
            BitStreamUtil.AssertMaxBits(32, numBits);
            var result = (int)(((long)((*(ulong *)(PBuffer + ((Offset / 8) & ~3))) << ((8 * 8) - (Offset % (8 * 4)) - numBits))) >> ((8 * 8) - numBits));

            Advance(numBits);
            return(result);
        }
        public int ReadSignedInt(int numBits)
        {
            BitStreamUtil.AssertMaxBits(32, numBits);

            // Just like PeekInt, but we cast to signed long before the shr because we need to sext
            var result = (int)(((long)(BitConverter.ToUInt64(Buffer, (Offset / 8) & ~3) << ((8 * 8) - (Offset % (8 * 4)) - numBits))) >> ((8 * 8) - numBits));

            Advance(numBits);
            return(result);
        }
        public uint PeekInt(int numBits)
        {
            BitStreamUtil.AssertMaxBits(32, numBits);
            Debug.Assert((Offset + numBits) <= (BitsInBuffer + (SLED * 8)), "gg", "This code just fell apart. We're all dead. Offset={0} numBits={1} BitsInBuffer={2}", Offset, numBits, BitsInBuffer);


            // _      xxxnno      _
            // _   xxxnno         _
            // _    xxxnno


            return((uint)((BitConverter.ToUInt64(Buffer, (Offset / 8) & ~3) << ((8 * 8) - (Offset % (8 * 4)) - numBits)) >> ((8 * 8) - numBits)));
        }
 public byte ReadByte(int bits)
 {
     BitStreamUtil.AssertMaxBits(8, bits);
     return((byte)ReadInt(bits));
 }