Class SoDataCompressor
- Direct Known Subclasses:
SoGzipDataCompressor
,SoJpegDataCompressor
By implementing each virtual method of this class, it is possible to create a new compression algorithm. As with a custom node, the initClass of the custom compressor must be called before creating and instantiating an instance of the custom class. After you call initClass, the compression algorithm will be available in the '-c' option of SoConverter
.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
Field Summary
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
Method Summary
Modifier and TypeMethodDescriptionallocateCompressedBuffer
(long size) Allocates the internal buffer to hold the compressed data.static long
crc32
(ByteBuffer buf, long len) Utility function to get the CRC32 of a buffer.static SoDataCompressor
Create and return an instance of a compressor of the given type.Returns the compressed data.Returns the name of the compression algorithm used by this class.long
Returns the compression level.boolean
Returns true if the compression algorithm is lossless.void
setCompressionLevel
(long level) Sets the compression level.Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
Method Details
-
getCompressionFormatName
Returns the name of the compression algorithm used by this class. This is the name the user will pass to the "-c" option of the converter, so it should be something simple and clear.- Returns:
- A String containing the name of the compression.
-
crc32
Utility function to get the CRC32 of a buffer.- Parameters:
buf
- a pointer to the data.len
- the size of the buffer.- Returns:
- The CRC32 of the data.
-
allocateCompressedBuffer
Allocates the internal buffer to hold the compressed data.- Parameters:
size
- is the size to allocate in bytes.
-
setCompressionLevel
public void setCompressionLevel(long level) Sets the compression level.- Parameters:
level
- the level of the compression used. Valid compression levels are specific to the compression algorithm.
-
isLossless
public boolean isLossless()Returns true if the compression algorithm is lossless.Warning It allows the converter to know if it must do CRC32 on original data or decompressed data when the '-C' option is enabled. Computing CRC32 on lossy compression is more costly than on lossless compression because data must be uncompressed before applying the CRC32 in order to have the real data stored in the file. Setting the environment variable LDM_COMPRESS_CHECK_CRC32 to 1 will force the LDM reader to check data integrity.
- Returns:
- True if the compression is lossless.
-
getCompressionLevel
public long getCompressionLevel()Returns the compression level.- Returns:
- The level of compression. See
setCompressionLevel
.
-
getAppropriateCompressor
Create and return an instance of a compressor of the given type.- Parameters:
name
- The name of the compressor.- Returns:
- A pointer to the newly created compressor. If this compressor is not available, returns NULL.
-
getCompressedBuffer
Returns the compressed data. This pointer must not be deleted.- Returns:
- A pointer to the compressed data.
-