summaryrefslogtreecommitdiff
path: root/src/common/zstd_compression.h
diff options
context:
space:
mode:
authorGravatar unknown2019-02-08 23:11:00 +0100
committerGravatar FreddyFunk2019-03-29 18:22:08 +0100
commit72477731ed20c56a4d6f18a22f43224fab667cef (patch)
treeb42e73051351850148cbffe65c528c0adfff62af /src/common/zstd_compression.h
parentcommon: Link libzstd_static (diff)
downloadyuzu-72477731ed20c56a4d6f18a22f43224fab667cef.tar.gz
yuzu-72477731ed20c56a4d6f18a22f43224fab667cef.tar.xz
yuzu-72477731ed20c56a4d6f18a22f43224fab667cef.zip
common/zstd_compression: Add Zstandard wrapper
Diffstat (limited to 'src/common/zstd_compression.h')
-rw-r--r--src/common/zstd_compression.h44
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
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 * @param uncompressed_size the size in bytes of the uncompressed data.
38 *
39 * @return the decompressed data.
40 */
41std::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