Class HDecompress
java.lang.Object
nom.tam.fits.compression.algorithm.hcompress.HDecompress
The original decompression code was written by R. 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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte
private static final byte
private static final byte
private static final byte
private int
Number of bits still in bufferprivate int
Bits waiting to be inputprivate static final byte[]
private static final int[]
private static final int
these N constants are obscuring the algorithm and should get some explaining javadoc if somebody understands the algorithm.private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private int
private int
private int
private static final byte
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate int
calculateLog2N
(int nmax) log2n is log2 of max(nx,ny) rounded up to next power of 2private void
decode64
(ByteBuffer infile, HDecompress.LongArrayPointer a) char *infile; input file long *a; address of output tiledImageOperation [nx][ny] int *nx,*ny; size of output tiledImageOperation int *scale; scale factor for digitizationvoid
decompress
(ByteBuffer input, boolean smooth, long[] aa) decompress the input byte stream using the H-compress algorithm input - input tiledImageOperation of compressed bytes a - pre-allocated tiledImageOperation to hold the output uncompressed image nx - returned X axis size ny - returned Y axis size NOTE: the nx and ny dimensions as defined within this code are reversed from the usual FITS notation.private int
dodecode64
(ByteBuffer infile, HDecompress.LongArrayPointer a, byte[] nbitplanes) long a[]; int nx,ny; Array dimensions are [nx][ny] unsigned char nbitplanes[3]; Number of bit planes in quadrantsprivate int
hinv64
(HDecompress.LongArrayPointer a, boolean smooth) int smooth; 0 for no smoothing, else smooth during inversion int scale; used if smoothing is specifiedprivate void
hsmooth64
(HDecompress.LongArrayPointer a, int nxtop, int nytop) long a[]; tiledImageOperation of H-transform coefficients int nxtop,nytop; size of coefficient block to use int ny; actual 1st dimension of tiledImageOperation int scale; truncation scale factor that was usedprivate int
inputBit
(ByteBuffer infile) private int
inputHuffman
(ByteBuffer infile) private int
inputNbits
(ByteBuffer infile, int n) private int
inputNnybble
(ByteBuffer infile, int n, byte[] array) private int
inputNybble
(ByteBuffer infile) private void
qtreeBitins64
(byte[] a, int lnx, int lny, HDecompress.LongArrayPointer b, int n, int bit) Copy 4-bit values from a[(nx+1)/2,(ny+1)/2] to b[nx,ny], expanding each value to 2x2 pixels and inserting into bitplane BIT of B.private void
qtreeCopy
(byte[] a, int lnx, int lny, byte[] b, int n) copy 4-bit values from a[(nx+1)/2,(ny+1)/2] to b[nx,ny], expanding each value to 2x2 pixels a,b may be same tiledImageOperationprivate int
qtreeDecode64
(ByteBuffer infile, HDecompress.LongArrayPointer a, int n, int nqx, int nqy, int nbitplanes) char *infile; long a[]; a is 2-D tiledImageOperation with dimensions (n,n) int n; length of full row in a int nqx; partial length of row to decode int nqy; partial length of column (<=n) int nbitplanes; number of bitplanes to decodeprivate void
qtreeExpand
(ByteBuffer infile, byte[] a, int nx2, int ny2, byte[] b) private void
readBdirect64
(ByteBuffer infile, HDecompress.LongArrayPointer a, int n, int nqx, int nqy, byte[] scratch, int bit) private void
private void
private void
unshuffle64
(HDecompress.LongArrayPointer a, int n, int n2, long[] tmp) long a[]; tiledImageOperation to shuffle int n; number of elements to shuffle int n2; second dimension long tmp[]; scratch storage
-
Field Details
-
CODE_MAGIC
private static final byte[] CODE_MAGIC -
MASKS
private static final int[] MASKS -
ZERO
private static final byte ZERO- See Also:
-
BIT_ONE
private static final byte BIT_ONE- See Also:
-
BIT_TWO
private static final byte BIT_TWO- See Also:
-
BIT_THREE
private static final byte BIT_THREE- See Also:
-
BIT_FOUR
private static final byte BIT_FOUR- See Also:
-
N03
private static final int N03these N constants are obscuring the algorithm and should get some explaining javadoc if somebody understands the algorithm.- See Also:
-
N04
private static final int N04- See Also:
-
N05
private static final int N05- See Also:
-
N06
private static final int N06- See Also:
-
N07
private static final int N07- See Also:
-
N08
private static final int N08- See Also:
-
N09
private static final int N09- See Also:
-
N10
private static final int N10- See Also:
-
N11
private static final int N11- See Also:
-
N12
private static final int N12- See Also:
-
N13
private static final int N13- See Also:
-
N14
private static final int N14- See Also:
-
N15
private static final int N15- See Also:
-
N26
private static final int N26- See Also:
-
N27
private static final int N27- See Also:
-
N28
private static final int N28- See Also:
-
N29
private static final int N29- See Also:
-
N30
private static final int N30- See Also:
-
N31
private static final int N31- See Also:
-
N62
private static final int N62- See Also:
-
N63
private static final int N63- See Also:
-
bitsToGo
private int bitsToGoNumber of bits still in buffer -
buffer2
private int buffer2Bits waiting to be input -
nx
private int nx -
ny
private int ny -
scale
private int scale
-
-
Constructor Details
-
HDecompress
public HDecompress()
-
-
Method Details
-
calculateLog2N
private int calculateLog2N(int nmax) log2n is log2 of max(nx,ny) rounded up to next power of 2 -
decode64
char *infile; input file long *a; address of output tiledImageOperation [nx][ny] int *nx,*ny; size of output tiledImageOperation int *scale; scale factor for digitization- Parameters:
infile
-a
-
-
decompress
decompress the input byte stream using the H-compress algorithm input - input tiledImageOperation of compressed bytes a - pre-allocated tiledImageOperation to hold the output uncompressed image nx - returned X axis size ny - returned Y axis size NOTE: the nx and ny dimensions as defined within this code are reversed from the usual FITS notation. ny is the fastest varying dimension, which is usually considered the X axis in the FITS image display- Parameters:
input
- the input buffer to decompresssmooth
- should the image be smoothedaa
- the resulting long tiledImageOperation
-
dodecode64
long a[]; int nx,ny; Array dimensions are [nx][ny] unsigned char nbitplanes[3]; Number of bit planes in quadrants -
hinv64
int smooth; 0 for no smoothing, else smooth during inversion int scale; used if smoothing is specified -
hsmooth64
long a[]; tiledImageOperation of H-transform coefficients int nxtop,nytop; size of coefficient block to use int ny; actual 1st dimension of tiledImageOperation int scale; truncation scale factor that was used -
inputBit
-
inputHuffman
-
inputNbits
-
inputNnybble
-
inputNybble
-
qtreeBitins64
private void qtreeBitins64(byte[] a, int lnx, int lny, HDecompress.LongArrayPointer b, int n, int bit) Copy 4-bit values from a[(nx+1)/2,(ny+1)/2] to b[nx,ny], expanding each value to 2x2 pixels and inserting into bitplane BIT of B. A,B may NOT be same tiledImageOperation (it wouldn't make sense to be inserting bits into the same tiledImageOperation anyway.) -
qtreeCopy
private void qtreeCopy(byte[] a, int lnx, int lny, byte[] b, int n) copy 4-bit values from a[(nx+1)/2,(ny+1)/2] to b[nx,ny], expanding each value to 2x2 pixels a,b may be same tiledImageOperation -
qtreeDecode64
private int qtreeDecode64(ByteBuffer infile, HDecompress.LongArrayPointer a, int n, int nqx, int nqy, int nbitplanes) char *infile; long a[]; a is 2-D tiledImageOperation with dimensions (n,n) int n; length of full row in a int nqx; partial length of row to decode int nqy; partial length of column (<=n) int nbitplanes; number of bitplanes to decode -
qtreeExpand
-
readBdirect64
private void readBdirect64(ByteBuffer infile, HDecompress.LongArrayPointer a, int n, int nqx, int nqy, byte[] scratch, int bit) -
startInputingBits
private void startInputingBits() -
undigitize64
-
unshuffle64
long a[]; tiledImageOperation to shuffle int n; number of elements to shuffle int n2; second dimension long tmp[]; scratch storage
-