Package x3

Class X3BitPacker

java.lang.Object
x3.X3BitPacker

public class X3BitPacker
extends java.lang.Object
Bit packer to pack sequential bits of data into byte chunks. Should consider converting this to integers since they will be loads more efficient for bit operations than single bytes.
Author:
Doug Gillespie
  • Constructor Summary

    Constructors 
    Constructor Description
    X3BitPacker​(byte[] bytes)
    Construct a new bit packer.
  • Method Summary

    Modifier and Type Method Description
    void clear()
    Clear an array completely.
    void fixSign​(short[] data, int nBits, int offset, int n, int stride)
    Fix the signs of an array of data read using the nextBits() function
    short fixSign​(short data, int nBits)
    Fix the sign of a single word of data read using the nextBits function
    int getBitPos()  
    int getBytePos()  
    int getUsedBytes()  
    void setBit()
    Set the next bit to 1.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • X3BitPacker

      public X3BitPacker​(byte[] bytes)
      Construct a new bit packer.
      Parameters:
      bytes - data to pack or unpack.
  • Method Details

    • setBit

      public void setBit()
      Set the next bit to 1.
    • fixSign

      public void fixSign​(short[] data, int nBits, int offset, int n, int stride)
      Fix the signs of an array of data read using the nextBits() function
      Parameters:
      data - data to fix
      nBits - number of bits used (including the sign bit)
      offset - offset in the array to start at.
      n - number of words to fix
      stride - step size between words.
    • fixSign

      public short fixSign​(short data, int nBits)
      Fix the sign of a single word of data read using the nextBits function

      Note that the array version of this will be more efficient.

      Parameters:
      data - unsigned data.
      nBits - number of bits (including the sign bit)
      Returns:
      signed data.
    • getBitPos

      public int getBitPos()
      Returns:
      the bitPos
    • getBytePos

      public int getBytePos()
      Returns:
      the bytePos
    • getUsedBytes

      public int getUsedBytes()
      Returns:
      the number of bytes actually used.
    • clear

      public void clear()
      Clear an array completely.