Class RiceCompressor<T extends java.nio.Buffer>
- java.lang.Object
-
- nom.tam.fits.compression.algorithm.rice.RiceCompressor<T>
-
- All Implemented Interfaces:
ICompressor<T>
- Direct Known Subclasses:
RiceCompressor.ByteRiceCompressor,RiceCompressor.IntRiceCompressor,RiceCompressor.ShortRiceCompressor
public abstract class RiceCompressor<T extends java.nio.Buffer> extends java.lang.Object implements ICompressor<T>
The original compression was designed by Rice, Yeh, and Miller the code was written by Richard White at STSc 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRiceCompressor.ByteRiceCompressorstatic classRiceCompressor.DoubleRiceCompressorstatic classRiceCompressor.FloatRiceCompressorstatic classRiceCompressor.IntRiceCompressorstatic classRiceCompressor.ShortRiceCompressor
-
Field Summary
Fields Modifier and Type Field Description private intbBitsprivate static intBITS_OF_1_BYTEprivate static intBITS_PER_BYTEprivate intbitsPerPixelprivate intblockSizeprivate static intBYTE_MASKprivate static intFS_BITS_FOR_BYTEprivate static intFS_BITS_FOR_INTprivate static intFS_BITS_FOR_SHORTprivate static intFS_MAX_FOR_BYTEprivate static intFS_MAX_FOR_INTprivate static intFS_MAX_FOR_SHORTprivate intfsBitsprivate intfsMaxprivate static java.util.logging.LoggerLOGlogger to log to.private static int[]NONZERO_COUNTprivate static longUNSIGNED_BYTE_MASKmask to convert a "unsigned" byte to a long.private static longUNSIGNED_INTEGER_MASKmask to convert a "unsigned" int to a long.private static longUNSIGNED_SHORT_MASKmask to convert a "unsigned" short to a long.
-
Constructor Summary
Constructors Modifier Constructor Description privateRiceCompressor(RiceCompressOption option)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcompress(int dataLength, int firstPixel, BitBuffer buffer)compress the integer tiledImageOperation on a rise compressed byte buffer.protected voiddecompressBuffer(java.nio.ByteBuffer readBuffer, int nx)decompress the readbuffer and fill the pixelarray.protected abstract intnextPixel()protected abstract voidnextPixel(int pixel)private longundoMappingAndDifferencing(long lastpix, long diff)undo mapping and differencing Note that some of these operations will overflow the unsigned int arithmetic -- that's OK, it all works out to give the right answers in the output file.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface nom.tam.fits.compression.algorithm.api.ICompressor
compress, decompress
-
-
-
-
Field Detail
-
UNSIGNED_BYTE_MASK
private static final long UNSIGNED_BYTE_MASK
mask to convert a "unsigned" byte to a long.- See Also:
- Constant Field Values
-
UNSIGNED_SHORT_MASK
private static final long UNSIGNED_SHORT_MASK
mask to convert a "unsigned" short to a long.- See Also:
- Constant Field Values
-
UNSIGNED_INTEGER_MASK
private static final long UNSIGNED_INTEGER_MASK
mask to convert a "unsigned" int to a long.- See Also:
- Constant Field Values
-
LOG
private static final java.util.logging.Logger LOG
logger to log to.
-
BITS_OF_1_BYTE
private static final int BITS_OF_1_BYTE
- See Also:
- Constant Field Values
-
BITS_PER_BYTE
private static final int BITS_PER_BYTE
- See Also:
- Constant Field Values
-
BYTE_MASK
private static final int BYTE_MASK
- See Also:
- Constant Field Values
-
FS_BITS_FOR_BYTE
private static final int FS_BITS_FOR_BYTE
- See Also:
- Constant Field Values
-
FS_BITS_FOR_INT
private static final int FS_BITS_FOR_INT
- See Also:
- Constant Field Values
-
FS_BITS_FOR_SHORT
private static final int FS_BITS_FOR_SHORT
- See Also:
- Constant Field Values
-
FS_MAX_FOR_BYTE
private static final int FS_MAX_FOR_BYTE
- See Also:
- Constant Field Values
-
FS_MAX_FOR_INT
private static final int FS_MAX_FOR_INT
- See Also:
- Constant Field Values
-
FS_MAX_FOR_SHORT
private static final int FS_MAX_FOR_SHORT
- See Also:
- Constant Field Values
-
NONZERO_COUNT
private static final int[] NONZERO_COUNT
-
bBits
private final int bBits
-
bitsPerPixel
private final int bitsPerPixel
-
blockSize
private final int blockSize
-
fsBits
private final int fsBits
-
fsMax
private final int fsMax
-
-
Constructor Detail
-
RiceCompressor
private RiceCompressor(RiceCompressOption option)
-
-
Method Detail
-
undoMappingAndDifferencing
private long undoMappingAndDifferencing(long lastpix, long diff)undo mapping and differencing Note that some of these operations will overflow the unsigned int arithmetic -- that's OK, it all works out to give the right answers in the output file.
In java this is more complicated because of the missing unsigned integers. trying to simulate the behavior
- Parameters:
lastpix- the current last pix valuediff- the difference to "add"- Returns:
- return the new lastpiy value
-
compress
protected void compress(int dataLength, int firstPixel, BitBuffer buffer)compress the integer tiledImageOperation on a rise compressed byte buffer.- Parameters:
dataLength- length of the data to compressfirstPixel- the value of the first pixelbuffer- the buffer to write to
-
decompressBuffer
protected void decompressBuffer(java.nio.ByteBuffer readBuffer, int nx)decompress the readbuffer and fill the pixelarray.- Parameters:
readBuffer- input buffernx- the number of pixel to uncompress
-
nextPixel
protected abstract int nextPixel()
-
nextPixel
protected abstract void nextPixel(int pixel)
-
-