diff options
Diffstat (limited to 'src/common/zstd_compression.h')
| -rw-r--r-- | src/common/zstd_compression.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/common/zstd_compression.h b/src/common/zstd_compression.h new file mode 100644 index 000000000..c011ac34b --- /dev/null +++ b/src/common/zstd_compression.h | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | namespace Common::Compression { | ||
| 10 | |||
| 11 | /** | ||
| 12 | * Compresses a source memory region with Zstandard and returns the compressed data in a vector. | ||
| 13 | * | ||
| 14 | * @param source the uncompressed source memory region. | ||
| 15 | * @param source_size the size in bytes of the uncompressed source memory region. | ||
| 16 | * @param compression_level the used compression level. Should be between 1 and 22. | ||
| 17 | * | ||
| 18 | * @return the compressed data. | ||
| 19 | */ | ||
| 20 | std::vector<u8> CompressDataZSTD(const u8* source, std::size_t source_size, s32 compression_level); | ||
| 21 | |||
| 22 | /** | ||
| 23 | * Compresses a source memory region with Zstandard with the default compression level and returns | ||
| 24 | * the compressed data in a vector. | ||
| 25 | * | ||
| 26 | * @param source the uncompressed source memory region. | ||
| 27 | * @param source_size the size in bytes of the uncompressed source memory region. | ||
| 28 | * | ||
| 29 | * @return the compressed data. | ||
| 30 | */ | ||
| 31 | std::vector<u8> CompressDataZSTDDefault(const u8* source, std::size_t source_size); | ||
| 32 | |||
| 33 | /** | ||
| 34 | * Decompresses a source memory region with Zstandard and returns the uncompressed data in a vector. | ||
| 35 | * | ||
| 36 | * @param compressed the compressed source memory region. | ||
| 37 | * @param uncompressed_size the size in bytes of the uncompressed data. | ||
| 38 | * | ||
| 39 | * @return the decompressed data. | ||
| 40 | */ | ||
| 41 | std::vector<u8> DecompressDataZSTD(const std::vector<u8>& compressed, | ||
| 42 | std::size_t uncompressed_size); | ||
| 43 | |||
| 44 | } // namespace Common::Compression \ No newline at end of file | ||