summaryrefslogtreecommitdiff
path: root/src/common/zstd_compression.h
diff options
context:
space:
mode:
authorGravatar bunnei2019-04-07 17:48:33 -0400
committerGravatar GitHub2019-04-07 17:48:33 -0400
commit21a4e7deea9638e4841e57d815cf1ecb7543fb34 (patch)
tree97dd726abe476c0a4c03c5da1c39239e93c6ed2a /src/common/zstd_compression.h
parentMerge pull request #2356 from lioncash/pair (diff)
parentgitmodules: Replace taps with spaces (diff)
downloadyuzu-21a4e7deea9638e4841e57d815cf1ecb7543fb34.tar.gz
yuzu-21a4e7deea9638e4841e57d815cf1ecb7543fb34.tar.xz
yuzu-21a4e7deea9638e4841e57d815cf1ecb7543fb34.zip
Merge pull request #2098 from FreddyFunk/disk-cache-zstd
gl_shader_disk_cache: Use Zstandard for compression
Diffstat (limited to 'src/common/zstd_compression.h')
-rw-r--r--src/common/zstd_compression.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/common/zstd_compression.h b/src/common/zstd_compression.h
new file mode 100644
index 000000000..e0a64b035
--- /dev/null
+++ b/src/common/zstd_compression.h
@@ -0,0 +1,42 @@
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
9namespace 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 */
20std::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 */
31std::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 *
38 * @return the decompressed data.
39 */
40std::vector<u8> DecompressDataZSTD(const std::vector<u8>& compressed);
41
42} // namespace Common::Compression \ No newline at end of file