AuroraRuntime/Include/Aurora/Compression/CompressionInfo.hpp

135 lines
3.0 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 uLz4BlockSize {};
bool bHasWindowbits {true};
/**
* @brief DEFLATE related variabl
*
* Deflate: 0 <= x >= 15,
* recommended: 15
* Zip: 0 <= x >= 15,
* recommended: 15
* GZip: 0 <= x >= 15,
* recommended: 15
*/
AuUInt8 uWindowBits {15};
/**
* @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
*/
bool bHasWindowbits { true };
/**
* @brief Flag for headerless decompression streams
*/
AuInt8 uWindowBits { 15 };
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)
{
}
};
}