mirror of
https://github.com/open-goal/jak-project
synced 2026-08-21 23:00:45 -04:00
[sparticle] 2d hud particles (#849)
* wip, taking a break to work on asm stuff first * the goal code for sparticle * mips2c the first sparticle asm function * temp * particle processing no longer crashing * temp * working texture cache for vi1 and hud textures * sprites * cleanup 1 * temp * temp * add zstd library * temp * working * tests * include fix * uncomment * better decomp of sparticle stuff, part 1 * update references
This commit is contained in:
@@ -6,12 +6,16 @@
|
||||
#include "common/util/assert.h"
|
||||
|
||||
namespace compression {
|
||||
|
||||
/*!
|
||||
* Compress data with zstd. There is an 8-byte header containing the decompressed data's size.
|
||||
*/
|
||||
std::vector<u8> compress_zstd(const void* data, size_t size) {
|
||||
auto max_compressed = ZSTD_compressBound(size);
|
||||
std::vector<u8> result(sizeof(size_t) + max_compressed);
|
||||
memcpy(result.data(), &size, sizeof(size_t));
|
||||
auto compressed_size = ZSTD_compress(result.data() + sizeof(size_t), max_compressed, data, size,
|
||||
ZSTD_CLEVEL_DEFAULT);
|
||||
auto compressed_size =
|
||||
ZSTD_compress(result.data() + sizeof(size_t), max_compressed, data, size, 1);
|
||||
if (ZSTD_isError(compressed_size)) {
|
||||
printf("ZSTD error: %s\n", ZSTD_getErrorName(compressed_size));
|
||||
assert(false);
|
||||
@@ -20,6 +24,10 @@ std::vector<u8> compress_zstd(const void* data, size_t size) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Decompress data with zstd. The first 8-bytes of the data should be a header containing the
|
||||
* decompressed data's size.
|
||||
*/
|
||||
std::vector<u8> decompress_zstd(const void* data, size_t size) {
|
||||
assert(size >= sizeof(size_t));
|
||||
size_t decompressed_size;
|
||||
@@ -37,4 +45,4 @@ std::vector<u8> decompress_zstd(const void* data, size_t size) {
|
||||
assert(decomp_size == decompressed_size);
|
||||
return result;
|
||||
}
|
||||
} // namespace compression
|
||||
} // namespace compression
|
||||
|
||||
Reference in New Issue
Block a user