Skip to content

Commit

Permalink
decompiler: Cleanup duplication in extractor/decompiler and make it e…
Browse files Browse the repository at this point in the history
…asier 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)
  • Loading branch information
xTVaser authored Jun 29, 2024
1 parent a485c23 commit b4113dd
Show file tree
Hide file tree
Showing 16 changed files with 355 additions and 394 deletions.
25 changes: 17 additions & 8 deletions common/util/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@
#include "common/common_types.h"
#include "common/log/log.h"

#ifdef __linux__

#ifdef _WIN32
// clang-format off
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <psapi.h>
// clang-format on
size_t get_peak_rss() {
HANDLE hProcess = GetCurrentProcess();
PROCESS_MEMORY_COUNTERS pmc;
if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) {
return pmc.PeakWorkingSetSize;
} else {
return 0;
}
}
#else
#include <sys/resource.h>

size_t get_peak_rss() {
rusage x;
getrusage(RUSAGE_SELF, &x);
return x.ru_maxrss * 1024;
}

#else
size_t get_peak_rss() {
return 0;
}
#endif

#ifdef _WIN32
Expand Down
1 change: 0 additions & 1 deletion common/util/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <cstddef>
#include <string>

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

Expand Down
3 changes: 2 additions & 1 deletion decompiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ add_library(
VuDisasm/VuDisassembler.cpp
VuDisasm/VuInstruction.cpp

config.cpp)
config.cpp
decompilation_process.cpp)

target_link_libraries(decomp
lzokay
Expand Down
4 changes: 3 additions & 1 deletion decompiler/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ Config make_config_via_json(nlohmann::json& json) {
inputs_json.at("str_art_file_names").get<std::vector<std::string>>();
}

config.audio_dir_file_name = inputs_json.at("audio_dir_file_name").get<std::string>();
config.streamed_audio_file_names =
inputs_json.at("streamed_audio_file_names").get<std::vector<std::string>>();

Expand Down Expand Up @@ -321,6 +320,9 @@ Config make_config_via_json(nlohmann::json& json) {
if (json.contains("save_texture_pngs")) {
config.save_texture_pngs = json.at("save_texture_pngs").get<bool>();
}
if (json.contains("rip_streamed_audio")) {
config.rip_streamed_audio = json.at("rip_streamed_audio").get<bool>();
}

if (inputs_json.contains("animated_textures")) {
config.animated_textures =
Expand Down
3 changes: 1 addition & 2 deletions decompiler/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ struct Config {
std::vector<std::string> str_file_names;
std::vector<std::string> str_texture_file_names;
std::vector<std::string> str_art_file_names;

std::string audio_dir_file_name;
std::vector<std::string> streamed_audio_file_names;

std::string obj_file_name_map_file;
Expand Down Expand Up @@ -175,6 +173,7 @@ struct Config {
std::vector<std::string> levels_to_extract;
bool levels_extract;
bool save_texture_pngs = false;
bool rip_streamed_audio = false;

DecompileHacks hacks;

Expand Down
3 changes: 3 additions & 0 deletions decompiler/config/jak1/jak1_config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
// save game textures as .png files to decompiler_out/<game>/textures
"save_texture_pngs": false,

// whether or not to dump out streamed audio files to decompiler_out/<game>/audio
"rip_streamed_audio": false,

////////////////////////////
// PATCHING OPTIONS
////////////////////////////
Expand Down
4 changes: 0 additions & 4 deletions decompiler/config/jak1/ntsc_v1/inputs.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,6 @@
"TEXT/6COMMON.TXT"
],

// uncomment the next line to extract audio to wave files.
//"audio_dir_file_name": "jak1/VAG",
"audio_dir_file_name": "",

"streamed_audio_file_names": [
"VAGWAD.ENG",
"VAGWAD.FRE",
Expand Down
4 changes: 0 additions & 4 deletions decompiler/config/jak1_demo/default/inputs.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,5 @@
"TEXT/6COMMON.TXT"
],

// uncomment the next line to extract audio to wave files.
//"audio_dir_file_name": "jak1/VAG",
"audio_dir_file_name": "",

"streamed_audio_file_names": ["VAGWAD.ENG", "VAGWAD.JAP"]
}
3 changes: 3 additions & 0 deletions decompiler/config/jak2/jak2_config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
"rip_collision": false,
// save game textures as .png files to decompiler_out/<game>/textures
"save_texture_pngs": false,

// whether or not to dump out streamed audio files to decompiler_out/<game>/audio
"rip_streamed_audio": false,

////////////////////////////
// PATCHING OPTIONS
Expand Down
4 changes: 0 additions & 4 deletions decompiler/config/jak2/ntsc_v1/inputs.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,6 @@
"TEXT/7COMMON.TXT"
],

// uncomment the next line to extract audio to wave files.
// "audio_dir_file_name": "jak2/VAG",
"audio_dir_file_name": "",

"streamed_audio_file_names": [
"VAGWAD.ENG",
"VAGWAD.FRE",
Expand Down
3 changes: 3 additions & 0 deletions decompiler/config/jak3/jak3_config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
// save game textures as .png files to decompiler_out/<game>/textures
"save_texture_pngs": false,

// whether or not to dump out streamed audio files to decompiler_out/<game>/audio
"rip_streamed_audio": false,

////////////////////////////
// PATCHING OPTIONS
////////////////////////////
Expand Down
4 changes: 0 additions & 4 deletions decompiler/config/jak3/ntsc_v1/inputs.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,6 @@
"TEXT/11COMMON.TXT"
],

// uncomment the next line to extract audio to wave files.
// "audio_dir_file_name": "jak3/VAG",
"audio_dir_file_name": "",

"streamed_audio_file_names": [
"VAGWAD.ENG",
"VAGWAD.FRE",
Expand Down
Loading

0 comments on commit b4113dd

Please sign in to comment.