zstd_compression.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2019 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <vector>
  5. #include "common/common_types.h"
  6. namespace Common::Compression {
  7. /**
  8. * Compresses a source memory region with Zstandard and returns the compressed data in a vector.
  9. *
  10. * @param source the uncompressed source memory region.
  11. * @param source_size the size in bytes of the uncompressed source memory region.
  12. * @param compression_level the used compression level. Should be between 1 and 22.
  13. *
  14. * @return the compressed data.
  15. */
  16. std::vector<u8> CompressDataZSTD(const u8* source, std::size_t source_size, s32 compression_level);
  17. /**
  18. * Compresses a source memory region with Zstandard with the default compression level and returns
  19. * the compressed data in a vector.
  20. *
  21. * @param source the uncompressed source memory region.
  22. * @param source_size the size in bytes of the uncompressed source memory region.
  23. *
  24. * @return the compressed data.
  25. */
  26. std::vector<u8> CompressDataZSTDDefault(const u8* source, std::size_t source_size);
  27. /**
  28. * Decompresses a source memory region with Zstandard and returns the uncompressed data in a vector.
  29. *
  30. * @param compressed the compressed source memory region.
  31. * @param uncompressed_size the size in bytes of the uncompressed data.
  32. *
  33. * @return the decompressed data.
  34. */
  35. std::vector<u8> DecompressDataZSTD(const std::vector<u8>& compressed,
  36. std::size_t uncompressed_size);
  37. } // namespace Common::Compression