/*** Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: Compression.hpp Date: 2021-6-17 Author: Reece ***/ #pragma once namespace Aurora::Compression { static const AuUInt64 kChunkSize = 4096; /// * compression type + bits -> internal zlib windowBits static bool CompressionLevelFromExternalApi(const DecompressInfo &info, AuInt8 &out) { out = 0; if (info.hasWindowbits) { if (info.windowBits < 0) { return {}; } if (info.windowBits > 15) { return {}; } } if (info.alg == ECompresionType::eGZip) { if (!info.hasWindowbits) { return {}; } out = info.windowBits | 16; } else if (info.alg == ECompresionType::eDeflate) { if (!info.hasWindowbits) { return {}; } out = 0 - info.windowBits; } else { out = info.windowBits; } return true; } /// * compression type + bits -> internal zlib windowBits static bool CompressionLevelFromExternalApi(const CompressionInfo &info, AuInt8 &out) { out = 0; if (info.windowBits < 0) { return {}; } if (info.windowBits > 15) { return {}; } if (info.type == ECompresionType::eGZip) { out = info.windowBits | 16; } else if (info.type == ECompresionType::eDeflate) { out = 0 - info.windowBits; } else { out = info.windowBits; } return true; } }