136 lines
3.1 KiB
C++
136 lines
3.1 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: CompressInfo.hpp
|
|
Date: 2021-7-14
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
namespace Aurora::Compression
|
|
{
|
|
using CompressionOptions_t = AuList<AuPair<int, int>>;
|
|
|
|
struct CompressInfo
|
|
{
|
|
AU_COPY_MOVE_DEF(CompressInfo);
|
|
|
|
ECompressionType type;
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
* ZSTD: -5 <= level <= 22
|
|
* recommended: ZSTD_CLEVEL_DEFAULT
|
|
* LZMA: 0 <= level <= 9
|
|
* LZ4 : N/A
|
|
* Deflate: 0 <= x >= 9,
|
|
* recommended: 6
|
|
* Zip: 0 <= x <= 9,
|
|
* recommended: 6
|
|
* GZip: 0 <= x <= 9,
|
|
* recommended: 6
|
|
* BZIP: 0 <= x <= 9
|
|
*
|
|
*/
|
|
AuInt8 uCompressionLevel { 6 };
|
|
|
|
/**
|
|
* @brief LZMA: 5 <= fb <= 273, default = 32
|
|
*/
|
|
AuUInt32 uFbWordSize { 32 };
|
|
|
|
/**
|
|
* LZMA only
|
|
* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
|
|
* (1 << 12) <= dictSize <= (3 << 29) for 64-bit version
|
|
* default = (1 << 24)
|
|
*/
|
|
AuUInt32 uDictSize { };
|
|
|
|
/**
|
|
* @brief 64KiB is a recommended "small" block size
|
|
* todo: lzma respects this
|
|
*/
|
|
AuUInt16 uBlockSize {};
|
|
|
|
/**
|
|
* @brief DEFLATE related variabl
|
|
*
|
|
* Deflate: 0 <= x <= 15,
|
|
* recommended: 15
|
|
* Zip: 0 <= x <= 15,
|
|
* recommended: 15
|
|
* GZip: 0 <= x <= 15,
|
|
* recommended: 15
|
|
* Brotli: 16 <= x <= 24
|
|
* recommended:
|
|
*/
|
|
AuOptionalEx<AuUInt8> uOptWindowBits { };
|
|
|
|
/**
|
|
* brotli: 0 <= x <= 11,
|
|
* zstd: 0 <= x <= 9,
|
|
*/
|
|
AuOptionalEx<AuUInt8> uOptQuality { 7 };
|
|
|
|
/**
|
|
* @brief Internal output buffer size.
|
|
*/
|
|
AuUInt32 uInternalStreamSize { 512 * 1024 };
|
|
|
|
AuUInt8 uThreads { 1 };
|
|
|
|
bool bLZ4AutoFlush {false};
|
|
|
|
CompressionOptions_t options;
|
|
|
|
bool bErrorCheck { true };
|
|
|
|
inline CompressInfo(ECompressionType alg) : type(alg)
|
|
{
|
|
|
|
}
|
|
|
|
inline CompressInfo(ECompressionType alg, AuUInt32 bufferSize) : type(alg), uInternalStreamSize(bufferSize)
|
|
{
|
|
|
|
}
|
|
};
|
|
|
|
struct DecompressInfo
|
|
{
|
|
AU_COPY_MOVE(DecompressInfo);
|
|
|
|
/**
|
|
* @brief algorithm
|
|
*/
|
|
ECompressionType alg { ECompressionType::eDeflate };
|
|
|
|
/**
|
|
* @brief Internal output buffer size.
|
|
*/
|
|
AuUInt32 uInternalStreamSize { 512 * 1024 };
|
|
|
|
/**
|
|
* @brief Flag for headerless decompression streams
|
|
*/
|
|
AuOptionalEx<AuInt8> uOptWindowBits { };
|
|
|
|
AuUInt8 uThreads { 1 };
|
|
|
|
CompressionOptions_t options;
|
|
|
|
bool bErrorCheck { true };
|
|
|
|
inline DecompressInfo(ECompressionType alg) : alg(alg)
|
|
{
|
|
|
|
}
|
|
|
|
inline DecompressInfo(ECompressionType alg, AuUInt32 bufferSize) : alg(alg), uInternalStreamSize(bufferSize)
|
|
{
|
|
|
|
}
|
|
};
|
|
} |