Skip to content

Commit b4113dd

Browse files
authored
decompiler: Cleanup duplication in extractor/decompiler and make it easier to enable streamed audio ripping from CLI (#3560)
This centralizes the code that both `extractor` and the decompiler executes. In the past this code was partially-duplicated, meaning that the `extractor` could only do _some_ operations and not others (ie. could not extract the audio files). I also simplified the process to enable audio streaming in the configuration. This is to support a new feature in the launcher that allows you to enable these options for the decompiler: ![image](https://github.com/open-goal/jak-project/assets/13153231/8e6c20a1-8b5b-46f0-bceb-7644f713989f)
1 parent a485c23 commit b4113dd

File tree

16 files changed

+355
-394
lines changed

16 files changed

+355
-394
lines changed

common/util/os.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,29 @@
33
#include "common/common_types.h"
44
#include "common/log/log.h"
55

6-
#ifdef __linux__
7-
6+
#ifdef _WIN32
7+
// clang-format off
8+
#define NOMINMAX
9+
#define WIN32_LEAN_AND_MEAN
10+
#include <Windows.h>
11+
#include <psapi.h>
12+
// clang-format on
13+
size_t get_peak_rss() {
14+
HANDLE hProcess = GetCurrentProcess();
15+
PROCESS_MEMORY_COUNTERS pmc;
16+
if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) {
17+
return pmc.PeakWorkingSetSize;
18+
} else {
19+
return 0;
20+
}
21+
}
22+
#else
823
#include <sys/resource.h>
9-
1024
size_t get_peak_rss() {
1125
rusage x;
1226
getrusage(RUSAGE_SELF, &x);
1327
return x.ru_maxrss * 1024;
1428
}
15-
16-
#else
17-
size_t get_peak_rss() {
18-
return 0;
19-
}
2029
#endif
2130

2231
#ifdef _WIN32

common/util/os.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <cstddef>
44
#include <string>
55

6-
// Note: these are not implemented on windows and will return zero.
76
size_t get_peak_rss();
87
void setup_cpu_info();
98

decompiler/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ add_library(
8989
VuDisasm/VuDisassembler.cpp
9090
VuDisasm/VuInstruction.cpp
9191

92-
config.cpp)
92+
config.cpp
93+
decompilation_process.cpp)
9394

9495
target_link_libraries(decomp
9596
lzokay

decompiler/config.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Config make_config_via_json(nlohmann::json& json) {
6464
inputs_json.at("str_art_file_names").get<std::vector<std::string>>();
6565
}
6666

67-
config.audio_dir_file_name = inputs_json.at("audio_dir_file_name").get<std::string>();
6867
config.streamed_audio_file_names =
6968
inputs_json.at("streamed_audio_file_names").get<std::vector<std::string>>();
7069

@@ -321,6 +320,9 @@ Config make_config_via_json(nlohmann::json& json) {
321320
if (json.contains("save_texture_pngs")) {
322321
config.save_texture_pngs = json.at("save_texture_pngs").get<bool>();
323322
}
323+
if (json.contains("rip_streamed_audio")) {
324+
config.rip_streamed_audio = json.at("rip_streamed_audio").get<bool>();
325+
}
324326

325327
if (inputs_json.contains("animated_textures")) {
326328
config.animated_textures =

decompiler/config.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ struct Config {
102102
std::vector<std::string> str_file_names;
103103
std::vector<std::string> str_texture_file_names;
104104
std::vector<std::string> str_art_file_names;
105-
106-
std::string audio_dir_file_name;
107105
std::vector<std::string> streamed_audio_file_names;
108106

109107
std::string obj_file_name_map_file;
@@ -175,6 +173,7 @@ struct Config {
175173
std::vector<std::string> levels_to_extract;
176174
bool levels_extract;
177175
bool save_texture_pngs = false;
176+
bool rip_streamed_audio = false;
178177

179178
DecompileHacks hacks;
180179

decompiler/config/jak1/jak1_config.jsonc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@
122122
// save game textures as .png files to decompiler_out/<game>/textures
123123
"save_texture_pngs": false,
124124

125+
// whether or not to dump out streamed audio files to decompiler_out/<game>/audio
126+
"rip_streamed_audio": false,
127+
125128
////////////////////////////
126129
// PATCHING OPTIONS
127130
////////////////////////////

decompiler/config/jak1/ntsc_v1/inputs.jsonc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,6 @@
258258
"TEXT/6COMMON.TXT"
259259
],
260260

261-
// uncomment the next line to extract audio to wave files.
262-
//"audio_dir_file_name": "jak1/VAG",
263-
"audio_dir_file_name": "",
264-
265261
"streamed_audio_file_names": [
266262
"VAGWAD.ENG",
267263
"VAGWAD.FRE",

decompiler/config/jak1_demo/default/inputs.jsonc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,5 @@
228228
"TEXT/6COMMON.TXT"
229229
],
230230

231-
// uncomment the next line to extract audio to wave files.
232-
//"audio_dir_file_name": "jak1/VAG",
233-
"audio_dir_file_name": "",
234-
235231
"streamed_audio_file_names": ["VAGWAD.ENG", "VAGWAD.JAP"]
236232
}

decompiler/config/jak2/jak2_config.jsonc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@
127127
"rip_collision": false,
128128
// save game textures as .png files to decompiler_out/<game>/textures
129129
"save_texture_pngs": false,
130+
131+
// whether or not to dump out streamed audio files to decompiler_out/<game>/audio
132+
"rip_streamed_audio": false,
130133

131134
////////////////////////////
132135
// PATCHING OPTIONS

decompiler/config/jak2/ntsc_v1/inputs.jsonc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,6 @@
441441
"TEXT/7COMMON.TXT"
442442
],
443443

444-
// uncomment the next line to extract audio to wave files.
445-
// "audio_dir_file_name": "jak2/VAG",
446-
"audio_dir_file_name": "",
447-
448444
"streamed_audio_file_names": [
449445
"VAGWAD.ENG",
450446
"VAGWAD.FRE",

0 commit comments

Comments
 (0)