private void readValues(bool ignoreEof) { int control = input.ReadByte(); if (control == -1) { if (!ignoreEof) { throw new EndOfStreamException("Read past end of RLE integer from " + input); } used = numLiterals = 0; return; } else if (control < 0x80) { numLiterals = control + RunLengthIntegerWriter.MIN_REPEAT_SIZE; used = 0; repeat = true; delta = input.ReadByte(); if (delta == -1) { throw new EndOfStreamException("End of stream in RLE Integer from " + input); } // convert from 0 to 255 to -128 to 127 by converting to a signed byte delta = unchecked ((sbyte)(byte)delta); if (signed) { literals[0] = utils.readVslong(input); } else { literals[0] = (long)utils.readVulong(input); } } else { repeat = false; numLiterals = 0x100 - control; used = 0; for (int i = 0; i < numLiterals; ++i) { if (signed) { literals[i] = utils.readVslong(input); } else { literals[i] = (long)utils.readVulong(input); } } } }
private void readValues(bool ignoreEof) { int control = input.ReadByte(); used = 0; if (control == -1) { if (!ignoreEof) { throw new EndOfStreamException("Read past end of buffer RLE byte from " + input); } used = numLiterals = 0; return; } else if (control < 0x80) { repeat = true; numLiterals = control + RunLengthByteWriter.MIN_REPEAT_SIZE; int val = input.ReadByte(); if (val == -1) { throw new EndOfStreamException("Reading RLE byte got EOF"); } literals[0] = (byte)val; } else { repeat = false; numLiterals = 0x100 - control; int bytes = 0; while (bytes < numLiterals) { int result = input.Read(literals, bytes, numLiterals - bytes); if (result == -1) { throw new EndOfStreamException("Reading RLE byte literal got EOF in " + this); } bytes += result; } } }
private void readValues(bool ignoreEof) { // read the first 2 bits and determine the encoding type isRepeating = false; int firstByte = input.ReadByte(); if (firstByte < 0) { if (!ignoreEof) { throw new EndOfStreamException("Read past end of RLE integer from " + input); } used = numLiterals = 0; return; } currentEncoding = encodings[(firstByte >> 6) & 0x03]; switch (currentEncoding) { case RunLengthIntegerWriterV2.EncodingType.SHORT_REPEAT: readShortRepeatValues(firstByte); break; case RunLengthIntegerWriterV2.EncodingType.DIRECT: readDirectValues(firstByte); break; case RunLengthIntegerWriterV2.EncodingType.PATCHED_BASE: readPatchedBaseValues(firstByte); break; case RunLengthIntegerWriterV2.EncodingType.DELTA: readDeltaValues(firstByte); break; default: throw new IOException("Unknown encoding " + currentEncoding); } }