mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
GE Debugger: Use zstd for save states.
This commit is contained in:
parent
7a719dc245
commit
a97030068c
@ -21,6 +21,7 @@
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <snappy-c.h>
|
||||
#include <zstd.h>
|
||||
#include "Common/Profiler/Profiler.h"
|
||||
#include "Common/Common.h"
|
||||
#include "Common/Log.h"
|
||||
@ -637,7 +638,7 @@ bool DumpExecute::Run() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ReadCompressed(u32 fp, void *dest, size_t sz) {
|
||||
static bool ReadCompressed(u32 fp, void *dest, size_t sz, uint32_t version) {
|
||||
u32 compressed_size = 0;
|
||||
if (pspFileSystem.ReadFile(fp, (u8 *)&compressed_size, sizeof(compressed_size)) != sizeof(compressed_size)) {
|
||||
return false;
|
||||
@ -650,7 +651,10 @@ static bool ReadCompressed(u32 fp, void *dest, size_t sz) {
|
||||
}
|
||||
|
||||
size_t real_size = sz;
|
||||
snappy_uncompress((const char *)compressed, compressed_size, (char *)dest, &real_size);
|
||||
if (version < 5)
|
||||
snappy_uncompress((const char *)compressed, compressed_size, (char *)dest, &real_size);
|
||||
else
|
||||
real_size = ZSTD_decompress(dest, real_size, compressed, compressed_size);
|
||||
delete[] compressed;
|
||||
|
||||
return real_size == sz;
|
||||
@ -699,8 +703,8 @@ bool RunMountedReplay(const std::string &filename) {
|
||||
lastExecPushbuf.resize(bufsz);
|
||||
|
||||
bool truncated = false;
|
||||
truncated = truncated || !ReadCompressed(fp, lastExecCommands.data(), sizeof(Command) * sz);
|
||||
truncated = truncated || !ReadCompressed(fp, lastExecPushbuf.data(), bufsz);
|
||||
truncated = truncated || !ReadCompressed(fp, lastExecCommands.data(), sizeof(Command) * sz, header.version);
|
||||
truncated = truncated || !ReadCompressed(fp, lastExecPushbuf.data(), bufsz, header.version);
|
||||
|
||||
pspFileSystem.CloseFile(fp);
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <functional>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <snappy-c.h>
|
||||
#include <zstd.h>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
@ -98,9 +98,9 @@ static void BeginRecording() {
|
||||
}
|
||||
|
||||
static void WriteCompressed(FILE *fp, const void *p, size_t sz) {
|
||||
size_t compressed_size = snappy_max_compressed_length(sz);
|
||||
size_t compressed_size = ZSTD_compressBound(sz);
|
||||
u8 *compressed = new u8[compressed_size];
|
||||
snappy_compress((const char *)p, sz, (char *)compressed, &compressed_size);
|
||||
compressed_size = ZSTD_compress(compressed, compressed_size, p, sz, 6);
|
||||
|
||||
u32 write_size = (u32)compressed_size;
|
||||
fwrite(&write_size, sizeof(write_size), 1, fp);
|
||||
|
@ -33,7 +33,8 @@ static const char *HEADER_MAGIC = "PPSSPPGE";
|
||||
// Version 2: Uses snappy
|
||||
// Version 3: Adds FRAMEBUF0-FRAMEBUF9
|
||||
// Version 4: Expanded header with game ID
|
||||
static const int VERSION = 4;
|
||||
// Version 5: Uses zstd
|
||||
static const int VERSION = 5;
|
||||
static const int MIN_VERSION = 2;
|
||||
|
||||
enum class CommandType : u8 {
|
||||
|
Loading…
Reference in New Issue
Block a user