| Constructor and Description |
|---|
BitInput(InputStream in)
Constructs a bit input wrapping the specified input stream.
|
| Modifier and Type | Method and Description |
|---|---|
long |
available()
Returns number of bits available for reading without blocking.
|
void |
close()
Closes this input stream and releases associated resources.
|
boolean |
endOfStream()
Returns
true if all of the available bits have
been read or if this stream has been closed. |
long |
readBinary(int numBits)
Reads the next value from the input using a fixed-length binary
code of the specified number of bits.
|
boolean |
readBit()
Reads the next bit from the input stream.
|
long |
readDelta()
Reads the next value from the input using an Elias delta code.
|
long |
readFibonacci()
Reads the next value from the input using a Fibonacci code.
|
long |
readGamma()
Reads the next value from the input using an Elias gamma code.
|
long |
readRice(int numFixedBits)
Reads the next number from the input using a Rice coding with
the specified number of fixed bits for the remainder.
|
int |
readUnary()
Reads the next value from the input using a unary code.
|
long |
skip(long numBits)
Skips and discards the specified number of bits in the input.
|
void |
skipDelta()
Skips over and discards the next value from the input using an
Elias delta code.
|
void |
skipFibonacci()
Skips over and discards the next value from the input using a
Fibonacci code.
|
void |
skipGamma()
Skips over and discards the next value from the input using an
Elias gamma code.
|
void |
skipRice(int numFixedBits)
Skips over and discards the next value from the input using a
Rice code with the specified number of fixed bits.
|
void |
skipUnary()
Skips over and discards the next value from the input using a
unary code.
|
public BitInput(InputStream in) throws IOException
in - Input stream backing this bit input.IOException - If there is an exception reading from the
specified input stream.public long available()
throws IOException
InputStream.available().IOException - If there is an exception while checking
availability in the underlying input stream.public void close()
throws IOException
InputStream.close(). After calls to
this method, available() will return zero and endOfStream() will return true.IOException - If there is an exception closing the
underlying input stream.public boolean endOfStream()
true if all of the available bits have
been read or if this stream has been closed.true if all of the available bits have
been read.public long skip(long numBits)
throws IOException
numBits - Number of bits to skip.IOException - If there is an I/O error skipping on the
underlying input stream.IllegalArgumentException - If the number of bits argument
is less than zero.public boolean readBit()
throws IOException
true for 1
and false for 0.
The return value is undefined if the end of stream has been reached, but this method will not throw an exception.
IOException - If there is an exception reading from the
underlying stream.public int readUnary()
throws IOException
See BitOutput.writeUnary(int) for a description of
unary coding.
IOException - If the remaining bits are all zeros.public void skipUnary()
throws IOException
IOException - If there is a format error in the input stream
or an error reading from the underlying stream.public long readGamma()
throws IOException
See BitOutput.writeGamma(long) for a description of
gamma coding.
IOException - If the prefix of the remaining bits is not
a valid gamma code or if there is an error reading from the
underlying input stream.public void skipGamma()
throws IOException
IOException - If there is a format error in the input stream
or an error reading from the underlying stream.public long readDelta()
throws IOException
See BitOutput.writeDelta(long) for a description of
gamma coding.
IOException - If the prefix of the remaining bits is not
a valid delta code or there is an error reading from the
underlying input stream.public void skipDelta()
throws IOException
IOException - If there is a format error in the input
stream or an error reading from the underlying stream.public long readBinary(int numBits)
throws IOException
To skip over a binary encoding of a specified number of
bits, just call skip(long) on the number of bits.
See BitOutput.writeBinary(long,int) for a definition
of binary encoding and examples.
numBits - Number of bits in encoding.IOException - If there are not enough bits remaining in
the input or there is an error reading from the underlying
input stream.IllegalArgumentException - If the number of bits is less
than 1 or greater than 63.public long readRice(int numFixedBits)
throws IOException
numFixedBits - The number of fixed bits in the Rice code.IOException - If the coding is illegal.IllegalArgumentException - If the number of fixed bits is
less than 1 or greater than 63.public void skipRice(int numFixedBits)
throws IOException
IOException - If there is a format error in the input
stream or an error reading from the underlying stream.public long readFibonacci()
throws IOException
See BitOutput.writeFibonacci(long) for more information
on Fibonacci codes.
IOException - If the remaining bits do not contain
a pair of consecutive 1 bits or there is an exception reading from
the underlying input stream.public void skipFibonacci()
throws IOException
IOException - If there is a format error in the input
stream or an error reading from the underlying stream.Copyright © 2019 Alias-i, Inc.. All rights reserved.