diff options
Diffstat (limited to 'src/common/lz4_compression.h')
| -rw-r--r-- | src/common/lz4_compression.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/common/lz4_compression.h b/src/common/lz4_compression.h new file mode 100644 index 000000000..4c16f6e03 --- /dev/null +++ b/src/common/lz4_compression.h | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <vector> | ||
| 8 | |||
| 9 | #include "common/common_types.h" | ||
| 10 | |||
| 11 | namespace Common::Compression { | ||
| 12 | |||
| 13 | /** | ||
| 14 | * Compresses a source memory region with LZ4 and returns the compressed data in a vector. | ||
| 15 | * | ||
| 16 | * @param source the uncompressed source memory region. | ||
| 17 | * @param source_size the size in bytes of the uncompressed source memory region. | ||
| 18 | * | ||
| 19 | * @return the compressed data. | ||
| 20 | */ | ||
| 21 | std::vector<u8> CompressDataLZ4(const u8* source, std::size_t source_size); | ||
| 22 | |||
| 23 | /** | ||
| 24 | * Utilizes the LZ4 subalgorithm LZ4HC with the specified compression level. Higher compression | ||
| 25 | * levels result in a smaller compressed size, but require more CPU time for compression. The | ||
| 26 | * compression level has almost no impact on decompression speed. Data compressed with LZ4HC can | ||
| 27 | * also be decompressed with the default LZ4 decompression. | ||
| 28 | * | ||
| 29 | * @param source the uncompressed source memory region. | ||
| 30 | * @param source_size the size in bytes of the uncompressed source memory region. | ||
| 31 | * @param compression_level the used compression level. Should be between 3 and 12. | ||
| 32 | * | ||
| 33 | * @return the compressed data. | ||
| 34 | */ | ||
| 35 | std::vector<u8> CompressDataLZ4HC(const u8* source, std::size_t source_size, s32 compression_level); | ||
| 36 | |||
| 37 | /** | ||
| 38 | * Utilizes the LZ4 subalgorithm LZ4HC with the highest possible compression level. | ||
| 39 | * | ||
| 40 | * @param source the uncompressed source memory region. | ||
| 41 | * @param source_size the size in bytes of the uncompressed source memory region. | ||
| 42 | * | ||
| 43 | * @return the compressed data. | ||
| 44 | */ | ||
| 45 | std::vector<u8> CompressDataLZ4HCMax(const u8* source, std::size_t source_size); | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Decompresses a source memory region with LZ4 and returns the uncompressed data in a vector. | ||
| 49 | * | ||
| 50 | * @param compressed the compressed source memory region. | ||
| 51 | * @param uncompressed_size the size in bytes of the uncompressed data. | ||
| 52 | * | ||
| 53 | * @return the decompressed data. | ||
| 54 | */ | ||
| 55 | std::vector<u8> DecompressDataLZ4(const std::vector<u8>& compressed, std::size_t uncompressed_size); | ||
| 56 | |||
| 57 | } // namespace Common::Compression \ No newline at end of file | ||