Package ome.codecs
Class BaseCodec
java.lang.Object
ome.codecs.BaseCodec
- All Implemented Interfaces:
Codec
- Direct Known Subclasses:
Base64Codec,HuffmanCodec,JPEG2000Codec,JPEGCodec,LosslessJPEGCodec,LZ4Codec,LZOCodec,LZWCodec,MJPBCodec,MSRLECodec,MSVideoCodec,PackbitsCodec,PassthroughCodec,QTRLECodec,RPZACodec,ZlibCodec,ZstdCodec
BaseCodec contains default implementation and testing for classes
implementing the Codec interface, and acts as a base class for any
of the compression classes.
Base 1D compression and decompression methods are not implemented here, and
are left as abstract. 2D methods do simple concatenation and call to the 1D
methods
- Author:
- Eric Kjellman egkjellman at wisc.edu
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]compress(byte[][] data, CodecOptions options) 2D data block encoding default implementation.compress(ByteBuffer target, byte[] data, CodecOptions options) Compress using ByteBuffers.byte[]decompress(byte[] data) Decompresses a block of data.byte[]decompress(byte[][] data) Decompresses a block of data.byte[]decompress(byte[][] data, CodecOptions options) 2D data block decoding default implementation.byte[]decompress(byte[] data, CodecOptions options) Decompresses a block of data.abstract byte[]decompress(loci.common.RandomAccessInputStream in, CodecOptions options) Decompresses data from the given RandomAccessInputStream.voidtest()Main testing method default implementation.
-
Field Details
-
LOGGER
protected static final org.slf4j.Logger LOGGER
-
-
Constructor Details
-
BaseCodec
public BaseCodec()
-
-
Method Details
-
test
Main testing method default implementation. This method tests whether the data is the same after compressing and decompressing, as well as doing a basic test of the 2D methods.- Throws:
CodecException- Can only occur if there is a bug in the compress method.
-
compress
2D data block encoding default implementation. This method simply concatenates data[0] + data[1] + ... + data[i] into a 1D block of data, then calls the 1D version of compress.- Specified by:
compressin interfaceCodec- Parameters:
data- The data to be compressed.options- Options to be used during compression, if appropriate.- Returns:
- The compressed data.
- Throws:
CodecException- If input is not a compressed data block of the appropriate type.
-
compress
public ByteBuffer compress(ByteBuffer target, byte[] data, CodecOptions options) throws CodecException Compress using ByteBuffers. This implementation just calls the byte array based compression method and wraps the result properly.- Specified by:
compressin interfaceCodec- Parameters:
target- A preallocated ByteBuffer that may be used for the compressed data. This may benullto force the compressor to allocate a fresh buffer.data- The data to be compressed.options- Options to be used during compression, if appropriate.- Returns:
- The ByteBuffer holding the compressed data.
- Throws:
CodecException- If input cannot be processed.- See Also:
-
decompress
Description copied from interface:CodecDecompresses a block of data.- Specified by:
decompressin interfaceCodec- Parameters:
data- the data to be decompressed.- Returns:
- The decompressed data.
- Throws:
CodecException- If data is not valid compressed data for this decompressor.
-
decompress
Description copied from interface:CodecDecompresses a block of data.- Specified by:
decompressin interfaceCodec- Parameters:
data- The data to be decompressed.- Returns:
- The decompressed data.
- Throws:
CodecException- If data is not valid compressed data for this decompressor.
-
decompress
Description copied from interface:CodecDecompresses a block of data.- Specified by:
decompressin interfaceCodec- Parameters:
data- the data to be decompressedoptions- Options to be used during decompression.- Returns:
- the decompressed data.
- Throws:
CodecException- If data is not valid.
-
decompress
public abstract byte[] decompress(loci.common.RandomAccessInputStream in, CodecOptions options) throws CodecException, IOException Description copied from interface:CodecDecompresses data from the given RandomAccessInputStream.- Specified by:
decompressin interfaceCodec- Parameters:
in- The stream from which to read compressed data.options- Options to be used during decompression.- Returns:
- The decompressed data.
- Throws:
CodecException- If data is not valid compressed data for this decompressor.IOException
-
decompress
2D data block decoding default implementation. This method simply concatenates data[0] + data[1] + ... + data[i] into a 1D block of data, then calls the 1D version of decompress.- Specified by:
decompressin interfaceCodec- Parameters:
data- The data to be decompressed.options- Options to be used during decompression.- Returns:
- The decompressed data.
- Throws:
CodecException- If input is not a compressed data block of the appropriate type.
-