protected override long decodeConstraintNumber(long min, long max, BitArrayInputStream stream) { long result = 0; long valueRange = max - min; // !!! int narrowedVal = value - min; !!! int maxBitLen = PERCoderUtils.getMaxBitLength(valueRange); if (valueRange == 0) { return max; } //For the UNALIGNED variant the value is always encoded in the minimum // number of bits necessary to represent the range (defined in 10.5.3). int currentBit = maxBitLen; while (currentBit > 7) { currentBit -= 8; result |= stream.ReadByte() << currentBit; } if (currentBit > 0) { result |= stream.readBits(currentBit); } result += min; return result; }
protected internal virtual BitArrayInputStream newStream() { System.IO.MemoryStream btStream = new System.IO.MemoryStream( new byte[] {0xAB,0xCD, 0xEF,0x33, 0xFE, 0xDC, 0xBA }); BitArrayInputStream stream = new BitArrayInputStream(btStream); return stream; }