zstd_compression.h 1.4 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. #pragma once
  5. #include <vector>
  6. #include "common/common_types.h"
  7. namespace Common::Compression {
  8. /**
  9. * Compresses a source memory region with Zstandard and returns the compressed data in a vector.
  10. *
  11. * @param source the uncompressed source memory region.
  12. * @param source_size the size in bytes of the uncompressed source memory region.
  13. * @param compression_level the used compression level. Should be between 1 and 22.
  14. *
  15. * @return the compressed data.
  16. */
  17. std::vector<u8> CompressDataZSTD(const u8* source, std::size_t source_size, s32 compression_level);
  18. /**
  19. * Compresses a source memory region with Zstandard with the default compression level and returns
  20. * the compressed data in a vector.
  21. *
  22. * @param source the uncompressed source memory region.
  23. * @param source_size the size in bytes of the uncompressed source memory region.
  24. *
  25. * @return the compressed data.
  26. */
  27. std::vector<u8> CompressDataZSTDDefault(const u8* source, std::size_t source_size);
  28. /**
  29. * Decompresses a source memory region with Zstandard and returns the uncompressed data in a vector.
  30. *
  31. * @param compressed the compressed source memory region.
  32. *
  33. * @return the decompressed data.
  34. */
  35. std::vector<u8> DecompressDataZSTD(const std::vector<u8>& compressed);
  36. } // namespace Common::Compression