public static int readUE(BitReader bits) { int cnt = 0; while (bits.read1Bit() == 0 && cnt < 31) cnt++; int res = 0; if (cnt > 0) { long val = bits.readNBit(cnt); res = (int) ((1 << cnt) - 1 + val); } return res; }
public static int readNBit(BitReader bits, int n, String message) { int val = bits.readNBit(n); trace(message, val); return val; }
public static int readZeroBitCount(BitReader bits, String message) { int count = 0; while (bits.read1Bit() == 0 && count < 32) count++; trace(message, String.valueOf(count)); return count; }
public static boolean readBool(BitReader bits, String message) { boolean res = bits.read1Bit() == 0 ? false : true; trace(message, res ? 1 : 0); return res; }
public static boolean moreRBSPData(BitReader bits) { return !(bits.remaining() < 32 && bits.checkNBit(1) == 1 && (bits.checkNBit(24) << 9) == 0); }
public static int readTE(BitReader bits, int max) { if (max > 1) return readUE(bits); return ~bits.read1Bit() & 0x1; }