Class HCompress
java.lang.Object
nom.tam.fits.compression.algorithm.hcompress.HCompress
The original compression code was written by Richard White at the STScI and
included (ported to c and adapted) in cfitsio by William Pence, NASA/GSFC.
That code was then ported to java by R. van Nieuwenhoven. Later it was
massively refactored to harmonize the different compression algorithms and
reduce the duplicate code pieces without obscuring the algorithm itself as
far as possible. The original site for the algorithm is
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
variables for bit output to buffer when Huffman codingprivate static final int[]
protected static final int
protected static final int
private int
Number of bits free in bufferprivate int
private int
Bits buffered for outputprotected static final int
private static final int[]
private static final byte[]
private static final int
private static final int
to be refactored to a good name.private static final int[]
protected static final int
protected static final double
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate int
b2i
(boolean b) private int
bufcopy
(byte[] a, int n, byte[] buffer, int b, long bmax) protected void
compress
(long[] aa, int ny, int nx, int scale, ByteBuffer output) private LongBuffer
copy
(LongBuffer a, int i) private void
digitize
(LongBuffer a, int aOffset, int nx, int ny, long scale) private void
doEncode
(ByteBuffer compressedBytes, LongBuffer pixels, int nx, int ny, byte[] nbitplanes) encode pixels.private void
doneOutputtingBits
(ByteBuffer outfile) private int
encode
(ByteBuffer compressedBytes, LongBuffer a, int nx, int ny, int scale) private int
htrans
(long[] a, int nx, int ny) private int
log2n
(int nqmax) private void
outputNbits
(ByteBuffer outfile, int bits, int n) private void
outputNnybble
(ByteBuffer outfile, int n, byte[] array) private void
outputNybble
(ByteBuffer outfile, int bits) private int
qtreeEncode
(ByteBuffer outfile, LongBuffer a, int n, int nqx, int nqy, int nbitplanes) macros to write out 4-bit nybble, Huffman code for this valueprivate void
qtreeOnebit
(LongBuffer a, int n, int nx, int ny, byte[] b, int bit) private void
qtreeReduce
(byte[] a, int n, int nx, int ny, byte[] b) private void
shuffle
(long[] a, int aOffset, int n, int n2, long[] tmp) private void
private void
writeBdirect
(ByteBuffer outfile, LongBuffer a, int n, int nqx, int nqy, byte[] scratch, int bit)
-
Field Details
-
HTRANS_START_MASK
private static final int HTRANS_START_MASK- See Also:
-
ROUNDING_HALF
protected static final double ROUNDING_HALF- See Also:
-
BITS_OF_1_BYTE
protected static final int BITS_OF_1_BYTE- See Also:
-
BITS_OF_1_NYBBLE
protected static final int BITS_OF_1_NYBBLE- See Also:
-
BYTE_MASK
protected static final int BYTE_MASK- See Also:
-
NYBBLE_MASK
protected static final int NYBBLE_MASK- See Also:
-
N3
private static final int N3to be refactored to a good name.- See Also:
-
BITS_MASK
private static final int[] BITS_MASK -
CODE
private static final int[] CODE -
CODE_MAGIC
private static final byte[] CODE_MAGIC -
NCODE
private static final int[] NCODE -
bitbuffer
private int bitbuffervariables for bit output to buffer when Huffman coding -
bitsToGo2
private int bitsToGo2Number of bits free in buffer -
bitsToGo3
private int bitsToGo3 -
buffer2
private int buffer2Bits buffered for output
-
-
Constructor Details
-
HCompress
public HCompress()
-
-
Method Details
-
b2i
private int b2i(boolean b) -
bufcopy
private int bufcopy(byte[] a, int n, byte[] buffer, int b, long bmax) -
compress
-
copy
-
digitize
-
doEncode
private void doEncode(ByteBuffer compressedBytes, LongBuffer pixels, int nx, int ny, byte[] nbitplanes) encode pixels.- Parameters:
compressedBytes
- compressed datapixels
- pixels to compressnx
- image width dimensionny
- image height dimensionnbitplanes
- Number of bit planes in quadrants
-
doneOutputtingBits
-
encode
-
htrans
private int htrans(long[] a, int nx, int ny) -
log2n
private int log2n(int nqmax) -
outputNbits
-
outputNnybble
-
outputNybble
-
qtreeEncode
macros to write out 4-bit nybble, Huffman code for this value -
qtreeOnebit
-
qtreeReduce
private void qtreeReduce(byte[] a, int n, int nx, int ny, byte[] b) -
shuffle
private void shuffle(long[] a, int aOffset, int n, int n2, long[] tmp) -
startOutputtingBits
private void startOutputtingBits() -
writeBdirect
private void writeBdirect(ByteBuffer outfile, LongBuffer a, int n, int nqx, int nqy, byte[] scratch, int bit)
-