org.kc7bfi.jflac.io
Class BitOutputStream

java.lang.Object
  extended by org.kc7bfi.jflac.io.BitOutputStream

public class BitOutputStream
extends Object

Bit-wide output stream.

Author:
kc7bfi

Constructor Summary
BitOutputStream()
          The constructor.
BitOutputStream(OutputStream os)
          The constructor.
 
Method Summary
 int bitsLeftForByteAlignment()
          return the number of bits to read to align the byte.
 boolean concatenateAligned(BitOutputStream src)
          Concatinate one InputBitStream to the end of this one.
 void flushByteAligned()
          Flush bit stream after aligning byte boundry.
 int getInputBytesUnconsumed()
          return the number of bytes left to read.
 short getReadCRC16()
          return the read CRC-16 value.
 int getTotalBits()
          Returns the totalBits.
 int getTotalBlurbs()
          Returns the totalBlurbs.
 short getWriteCRC16()
          return the write CRC-16 value.
 byte getWriteCRC8()
          return the write CRC-8 value.
 boolean isByteAligned()
          Test if the Bit Stream is byte aligned.
 boolean isConsumedByteAligned()
          Test if the Bit Stream consumed bits is byte aligned.
 void resetReadCRC16(short seed)
          Reset the read CRC-16 value.
 int riceBits(int val, int parameter)
           
 void writeByteBlock(byte[] vals, int nvals)
           
 void writeRawInt(int val, int bits)
           
 void writeRawUInt(boolean val, int bits)
          Write a true/false integer.
 void writeRawUInt(int val, int bits)
           
 void writeRawUIntLittleEndian(int val)
           
 void writeRawULong(long val, int bits)
           
 void writeRiceSigned(int val, int parameter)
           
 void writeUnaryUnsigned(int val)
           
 void writeUTF8UInt(int val)
           
 void writeUTF8ULong(long val)
           
 void writeZeroes(int bits)
          Write zero bits.
 void zeroPadToByteBoundary()
          Write zero bits to byte boundry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitOutputStream

public BitOutputStream(OutputStream os)
The constructor.

Parameters:
os - The InputStream to read bits from

BitOutputStream

public BitOutputStream()
The constructor.

Method Detail

concatenateAligned

public boolean concatenateAligned(BitOutputStream src)
Concatinate one InputBitStream to the end of this one.

Parameters:
src - The inputBitStream to copy
Returns:
True if copy was successful

resetReadCRC16

public void resetReadCRC16(short seed)
Reset the read CRC-16 value.

Parameters:
seed - The initial CRC-16 value

getReadCRC16

public short getReadCRC16()
return the read CRC-16 value.

Returns:
The read CRC-16 value

getWriteCRC16

public short getWriteCRC16()
return the write CRC-16 value.

Returns:
The write CRC-16 value

getWriteCRC8

public byte getWriteCRC8()
return the write CRC-8 value.

Returns:
The write CRC-8 value

isByteAligned

public boolean isByteAligned()
Test if the Bit Stream is byte aligned.

Returns:
True of bit stream is byte aligned

isConsumedByteAligned

public boolean isConsumedByteAligned()
Test if the Bit Stream consumed bits is byte aligned.

Returns:
True of bit stream consumed bits is byte aligned

bitsLeftForByteAlignment

public int bitsLeftForByteAlignment()
return the number of bits to read to align the byte.

Returns:
The number of bits to align the byte

getInputBytesUnconsumed

public int getInputBytesUnconsumed()
return the number of bytes left to read.

Returns:
The number of bytes left to read

writeZeroes

public void writeZeroes(int bits)
                 throws IOException
Write zero bits.

Parameters:
bits - The number of zero bits to write
Throws:
IOException - On write error

writeRawUInt

public void writeRawUInt(boolean val,
                         int bits)
                  throws IOException
Write a true/false integer.

Parameters:
val - The true/false value
bits - The bit size to write
Throws:
IOException - On write error

writeRawUInt

public void writeRawUInt(int val,
                         int bits)
                  throws IOException
Throws:
IOException

writeRawInt

public void writeRawInt(int val,
                        int bits)
                 throws IOException
Throws:
IOException

writeRawULong

public void writeRawULong(long val,
                          int bits)
                   throws IOException
Throws:
IOException

writeRawUIntLittleEndian

public void writeRawUIntLittleEndian(int val)
                              throws IOException
Throws:
IOException

writeByteBlock

public void writeByteBlock(byte[] vals,
                           int nvals)
                    throws IOException
Throws:
IOException

writeUnaryUnsigned

public void writeUnaryUnsigned(int val)
                        throws IOException
Throws:
IOException

riceBits

public int riceBits(int val,
                    int parameter)

writeRiceSigned

public void writeRiceSigned(int val,
                            int parameter)
                     throws IOException
Throws:
IOException

writeUTF8UInt

public void writeUTF8UInt(int val)
                   throws IOException
Throws:
IOException

writeUTF8ULong

public void writeUTF8ULong(long val)
                    throws IOException
Throws:
IOException

zeroPadToByteBoundary

public void zeroPadToByteBoundary()
                           throws IOException
Write zero bits to byte boundry.

Throws:
IOException - On error writing to bit stream

flushByteAligned

public void flushByteAligned()
                      throws IOException
Flush bit stream after aligning byte boundry.

Throws:
IOException - On error writing.

getTotalBits

public int getTotalBits()
Returns the totalBits.

Returns:
Returns the totalBits.

getTotalBlurbs

public int getTotalBlurbs()
Returns the totalBlurbs.

Returns:
Returns the totalBlurbs.


Copyright © 2004-2011. All Rights Reserved.