/** Default constructor. */ public BitBuffer(byte[] byteBuffer) { buffer = new ome.codecs.BitBuffer(byteBuffer); }
/** * Returns an int value representing the value of the bits read from * the byte array, from the current position. Bits are extracted from the * "left side" or high side of the byte.<p> * The current position is modified by this call.<p> * Bits are pushed into the int from the right, endianness is not * considered by the method on its own. So, if 5 bits were read from the * buffer "10101", the int would be the integer representation of * 000...0010101 on the target machine. <p> * In general, this also means the result will be positive unless a full * 32 bits are read. <p> * Requesting more than 32 bits is allowed, but only up to 32 bits worth of * data will be returned (the last 32 bits read). <p> * * @param bitsToRead the number of bits to read from the bit buffer * @return the value of the bits read */ public int getBits(int bitsToRead) { return this.buffer.getBits(bitsToRead); }
/** Return the backing byte array. */ public byte[] getByteBuffer() { return this.buffer.getByteBuffer(); }
BitBuffer bb = new BitBuffer(bw.toByteArray()); int readint; LOGGER.info("Reading from BitBuffer"); int c = r.nextInt(100); if (c > 50) { readint = bb.getBits(len[i]); if (readint != nums[i]) { LOGGER.info("Error at #{}: {} received, {} expected.", bb.skipBits(len[i]); bb = new BitBuffer(bw.toByteArray()); bb.skipBits(totallen + 8); int read = bb.getBits(1); if (-1 != read) { LOGGER.info("-1 expected at end of buffer, {} received.", read); bb = new BitBuffer(bw.toByteArray()); for (int i = 0; i < trials; i++) { int c = r.nextInt(100); if (c > 50) { if (len[i] > 8) { bb.getBits(8); if (!bb.isBitOnByteBoundary()){ LOGGER.info("Bit on byte boundary expected, but not returned.");
BitBuffer bb = new BitBuffer(out.toByteArray()); for (int i=0; i<values.length; i++) { int value = bb.getBits(bits[i]); if (value != values[i]) { LOGGER.info("Value #{} does not match (got {}; expected {}; {} bits)", out.write(sb.toString()); LOGGER.info("Reading values from byte array"); bb = new BitBuffer(out.toByteArray()); for (int i = 0; i < 5000; i++) { int value = bb.getBits(1); int expected = (sb.charAt(i) == '1') ? 1 : 0; if (value != expected) {
/** * Skips a number of bits in the BitBuffer. * * @param bits Number of bits to skip */ public void skipBits(long bits) { this.buffer.skipBits(bits); }
/** * Checks if the current position is on a byte boundary, that is the next * bit in the byte array is the first bit in a byte. * * @return true if bit is on byte boundary, false otherwise. */ public boolean isBitOnByteBoundary() { return this.buffer.isBitOnByteBoundary(); }
/** * Testing method. * @param args Ignored. */ public static void main(String[] args) { ome.codecs.BitBuffer.main(args); } }
/** * Skips a number of bits in the BitBuffer. * * @param bits Number of bits to skip */ public void skipBits(long bits) { this.buffer.skipBits(bits); }
/** * Checks if the current position is on a byte boundary, that is the next * bit in the byte array is the first bit in a byte. * * @return true if bit is on byte boundary, false otherwise. */ public boolean isBitOnByteBoundary() { return this.buffer.isBitOnByteBoundary(); }
/** * Testing method. * @param args Ignored. */ public static void main(String[] args) { ome.codecs.BitBuffer.main(args); } }
/** Return the backing byte array. */ public byte[] getByteBuffer() { return this.buffer.getByteBuffer(); }
/** Default constructor. */ public BitBuffer(byte[] byteBuffer) { buffer = new ome.codecs.BitBuffer(byteBuffer); }
/** * Returns an int value representing the value of the bits read from * the byte array, from the current position. Bits are extracted from the * "left side" or high side of the byte.<p> * The current position is modified by this call.<p> * Bits are pushed into the int from the right, endianness is not * considered by the method on its own. So, if 5 bits were read from the * buffer "10101", the int would be the integer representation of * 000...0010101 on the target machine. <p> * In general, this also means the result will be positive unless a full * 32 bits are read. <p> * Requesting more than 32 bits is allowed, but only up to 32 bits worth of * data will be returned (the last 32 bits read). <p> * * @param bitsToRead the number of bits to read from the bit buffer * @return the value of the bits read */ public int getBits(int bitsToRead) { return this.buffer.getBits(bitsToRead); }
@Deprecated public int getSample(BitBuffer bb, CodecOptions options) throws CodecException { RandomAccessInputStream s = null; try { try { s = new RandomAccessInputStream(new ByteArrayHandle(bb.getByteBuffer())); return getSample(s, options); } finally { s.close(); } } catch (IOException e) { throw new CodecException(e); } }