52 #ifndef __PCL_Compression_h
53 #define __PCL_Compression_h
58 #include <pcl/Diagnostics.h>
104 float sizeReduction = 0;
105 double throughput = 0;
106 int numberOfThreads = 0;
187 return m_compressionLevel;
201 m_compressionLevel =
Range( level, 0, MaxCompressionLevel() );
214 SetCompressionLevel( 0 );
225 return m_byteShuffle;
243 m_byteShuffle = enable;
253 EnableByteShuffling( !disable );
286 return m_subblockSize;
331 m_checksums = enable;
341 EnableChecksums( !disable );
394 return Compress( data.Begin(), data.Size(), perf );
450 for (
const Subblock& subblock : subblocks )
451 uncompressedSize += subblock.uncompressedSize;
453 (void)Uncompress( data.
Begin(), uncompressedSize, subblocks, perf );
475 int m_compressionLevel = 0;
478 bool m_byteShuffle =
true;
479 bool m_checksums =
true;
510 const void* inputData,
size_type inputSize,
int level )
const = 0;
520 const void* inputData,
size_type inputSize )
const = 0;
530 if ( size > 0 && data !=
nullptr )
532 size_type numberOfItems = size / itemSize;
534 for (
size_type j = 0; j < itemSize; ++j )
537 for (
size_type i = 0; i < numberOfItems; ++i, ++s, u += itemSize )
540 ::memcpy( s, data + numberOfItems*itemSize, size % itemSize );
553 if ( size > 0 && data !=
nullptr )
555 size_type numberOfItems = size / itemSize;
557 for (
size_type j = 0; j < itemSize; ++j )
560 for (
size_type i = 0; i < numberOfItems; ++i, ++s, u += itemSize )
563 ::memcpy( unshuffled.
At( numberOfItems*itemSize ), s, size % itemSize );
575 if ( size > 0 && data !=
nullptr )
577 const ByteArray shuffled( data, data+size );
578 size_type numberOfItems = size / itemSize;
580 for (
size_type j = 0; j < itemSize; ++j )
583 for (
size_type i = 0; i < numberOfItems; ++i, ++s, u += itemSize )
595 friend class PCL_CompressionEngine;
596 friend class PCL_DecompressionEngine;
662 const void* inputData,
size_type inputSize,
int level )
const override;
667 const void* inputData,
size_type inputSize )
const override;
732 const void* inputData,
size_type inputSize,
int level )
const override;
737 const void* inputData,
size_type inputSize )
const override;
803 const void* inputData,
size_type inputSize,
int level )
const override;
808 const void* inputData,
size_type inputSize )
const override;
880 const void* inputData,
size_type inputSize,
int level )
const override;
885 const void* inputData,
size_type inputSize )
const override;
const uint8 * const_iterator
Abstract base class of data compression algorithm implementations.
virtual size_type MaxBlockSize() const =0
virtual size_type CompressBlock(void *outputData, size_type outputSize, const void *inputData, size_type inputSize, int level) const =0
size_type SubblockSize() const
void SetCompressionLevel(int level)
static ByteArray Unshuffle(const uint8 *data, size_type size, size_type itemSize)
void SetSubblockSize(size_type size)
bool ByteShufflingEnabled() const
void EnableChecksums(bool enable=true)
virtual size_type MinBlockSize() const =0
static ByteArray Shuffle(const uint8 *data, size_type size, size_type itemSize)
void SetDefaultCompressionLevel()
Compression(const Compression &)=default
virtual int MaxCompressionLevel() const =0
ByteArray Uncompress(const ByteArray &compressedData, size_type uncompressedSize, Performance *perf=nullptr) const
void EnableByteShuffling(bool enable=true)
virtual size_type UncompressBlock(void *outputData, size_type outputSize, const void *inputData, size_type inputSize) const =0
void Throw(const String &errorMessage) const
bool ChecksumsEnabled() const
void SetItemSize(size_type itemSize)
virtual int DefaultCompressionLevel() const =0
static void InPlaceUnshuffle(uint8 *data, size_type size, size_type itemSize)
subblock_list Compress(const void *data, size_type size, Performance *perf=nullptr) const
virtual size_type MaxCompressedBlockSize(size_type size) const =0
size_type ItemSize() const
size_type Uncompress(void *data, size_type maxSize, const subblock_list &subblocks, Performance *perf=nullptr) const
virtual String AlgorithmName() const =0
ByteArray Uncompress(const subblock_list &subblocks, Performance *perf=nullptr) const
virtual int MinCompressionLevel() const
int CompressionLevel() const
subblock_list Compress(const C &data, Performance *perf=nullptr) const
void DisableChecksums(bool disable=true)
void DisableByteShuffling(bool disable=true)
Implementation of the LZ4 compression algorithm.
int DefaultCompressionLevel() const override
String AlgorithmName() const override
int MaxCompressionLevel() const override
Implementation of the LZ4-HC compression algorithm.
int MaxCompressionLevel() const override
String AlgorithmName() const override
int DefaultCompressionLevel() const override
A process using multiple concurrent execution threads.
Implementation of the ZLib/Deflate compression algorithm.
int MaxCompressionLevel() const override
int DefaultCompressionLevel() const override
String AlgorithmName() const override
Implementation of the Zstandard compression algorithm.
int MinCompressionLevel() const override
String AlgorithmName() const override
int DefaultCompressionLevel() const override
int MaxCompressionLevel() const override
unsigned long long uint64
constexpr const T & Range(const T &x, const T &a, const T &b) noexcept
constexpr const T & Max(const T &a, const T &b) noexcept
Compression subblock data.
ByteArray compressedData
Sub-block compressed data.
size_type uncompressedSize
size in bytes of the uncompressed subblock.