org.progeeks.util
Class BitInputStream
java.lang.Object
java.io.InputStream
org.progeeks.util.BitInputStream
- All Implemented Interfaces:
- java.io.Closeable
public class BitInputStream
- extends java.io.InputStream
Input stream that can provide adjustable bit rate support.
Useful for reading 8-bit streams as 7-bit, 6-bit as packed
8-bit, etc.. The only limitation is that target data rates
cannot exceed 8 bits due to the InputStream contract.
- Version:
- $Revision$
- Author:
- Paul Speed
Constructor Summary |
BitInputStream(java.io.InputStream source,
int srcBitRate,
int targetBitRate,
boolean interleave)
Creates an input stream that will translate the bit rate of the
underlying stream as specified by the bitrate and interleave parameters. |
Methods inherited from class java.io.InputStream |
available, mark, markSupported, read, read, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BitInputStream
public BitInputStream(java.io.InputStream source,
int srcBitRate,
int targetBitRate,
boolean interleave)
- Creates an input stream that will translate the bit rate of the
underlying stream as specified by the bitrate and interleave parameters.
For example, a stream containing 7-bit elements packed into 8-bit elements
could be read by setting the srcBitRate to 8 bits and the target bitrate
to 7 bits.
The srcBitRate determines how to interpret the 8-bits read from the
underlying stream. It is denoting how many of those bits are significant
to the target operation. For example, reading from a stream that contains
a series of 6-bit values stored in 8-bit entries unpacked (ie: two bits
wasted per entry) would be a srcBitRate of 6 bits.
So for a packing operation the srcBitRate will be smaller than the targetBitRate.
For unpacking operations, the targetBitRate will be smaller than the source.
- Parameters:
source
- The underlying source data stream.srcBitRate
- The bit rate used to read the source data.targetBitRate
- The bit rate used to interpret the data.interlave
- Set to true if the source bit stream should be treated as
if it was read low bit to high for purposes of byte interleaving.
close
public void close()
throws java.io.IOException
- Specified by:
close
in interface java.io.Closeable
- Overrides:
close
in class java.io.InputStream
- Throws:
java.io.IOException
read
public int read()
throws java.io.IOException
- Specified by:
read
in class java.io.InputStream
- Throws:
java.io.IOException
Copyright © 2002-2003 Paul Speed. All Rights Reserved.