public class ByteArrayBitInputStream extends java.lang.Object implements BitInputStream
BitInputStream
interface,
using a byte array as data source.BIG_ENDIAN, LITTLE_ENDIAN
Constructor and Description |
---|
ByteArrayBitInputStream(byte[] source) |
ByteArrayBitInputStream(byte[] source,
int endian) |
Modifier and Type | Method and Description |
---|---|
void |
align()
causes the read pointer to be moved to the beginning
of the next byte, remaining bits in the current byte
are discarded
|
boolean |
getBit()
reads one bit (as a boolean) from the input stream
|
int |
getInt(HuffmanNode root)
reads a huffman codeword based on the
root
parameter and returns the decoded value |
int |
getInt(int bits)
reads
bits number of bits from the input
stream |
long |
getLong(int bits)
reads
bits number of bits from the input
stream |
int |
getSignedInt(int bits)
reads
bits number of bits from the input
stream |
byte[] |
getSource() |
int |
readSignedRice(int order)
reads an integer encoded as "signed rice" as described in
the FLAC audio format specification
|
void |
readSignedRice(int order,
int[] buffer,
int off,
int len)
fills the array from
offset with len
integers encoded as "signed rice" as described in
the FLAC audio format specification |
void |
setEndian(int endian)
changes the endian mode used when reading bit-wise from
the stream, changing the mode mid-stream will cause the
read cursor to move to the beginning of the next byte
(as if calling the
allign method |
public ByteArrayBitInputStream(byte[] source)
public ByteArrayBitInputStream(byte[] source, int endian)
public boolean getBit() throws java.io.IOException
BitInputStream
getBit
in interface BitInputStream
true
if the next bit is 1,
false
otherwisejava.io.IOException
- if an I/O error occurspublic int getInt(int bits) throws java.io.IOException
BitInputStream
bits
number of bits from the input
streamgetInt
in interface BitInputStream
java.io.IOException
- if an I/O error occurspublic int getSignedInt(int bits) throws java.io.IOException
BitInputStream
bits
number of bits from the input
streamgetSignedInt
in interface BitInputStream
java.io.IOException
- if an I/O error occurspublic int getInt(HuffmanNode root) throws java.io.IOException
BitInputStream
root
parameter and returns the decoded valuegetInt
in interface BitInputStream
root
- the root of the Huffman tree used to decode the codewordjava.io.IOException
- if an I/O error occurspublic long getLong(int bits) throws java.io.IOException
BitInputStream
bits
number of bits from the input
streamgetLong
in interface BitInputStream
java.io.IOException
- if an I/O error occurspublic int readSignedRice(int order) throws java.io.IOException
reads an integer encoded as "signed rice" as described in the FLAC audio format specification
not supported for little endian
readSignedRice
in interface BitInputStream
order
- java.io.IOException
- if an I/O error occursjava.lang.UnsupportedOperationException
- if the method is not supported by the implementationpublic void readSignedRice(int order, int[] buffer, int off, int len) throws java.io.IOException
fills the array from offset
with len
integers encoded as "signed rice" as described in
the FLAC audio format specification
not supported for little endian
readSignedRice
in interface BitInputStream
order
- buffer
- offset
- len
- java.io.IOException
- if an I/O error occursjava.lang.UnsupportedOperationException
- if the method is not supported by the implementationpublic void align()
BitInputStream
align
in interface BitInputStream
public void setEndian(int endian)
BitInputStream
allign
methodsetEndian
in interface BitInputStream
BitInputStream.align()
public byte[] getSource()
Copyright © 2016 Tor-Einar Jarnbjo. All Rights Reserved.