Drop the HRTF source and cache options

The kernel renders the Rosella .personalized_headphone model or an already
compiled .jochrtf field, and only the first is a user-facing input: the SOFA
reader and its compile cache left the library. joc-hrtf-source, joc-hrtf-cache
and joc-hrtf-cache-dir go with them, and the default file is now
binaural.personalized_headphone only.

The plugin sets personalized_headphone_path directly, and the disk-cache retry
path disappears with the cache itself. The headers in third_party/joc/include
and fork/files/audio/decode follow the new kernel, so the config structs no
longer carry hrtf_sofa_path, hrtf_cache_policy, hrtf_cache_dir or hrtf_radius_m,
and the rosella filterbank no longer needs its SOFA exception.

The example config and the option tables in both READMEs drop the removed keys.
Builds against the kernel with tools/build.ps1 -JocCoreSource.
This commit is contained in:
TheM14 committed 2026-11-01 19:38:41 +08:00
1 parent 0b94c75fd6
commit 19b4a49407
12 files changed
+25 -160

No files matched your search

+4 -49
View File
@@ -55,8 +55,7 @@ bool file_exists(const std::string& path) {
// The default HRTF lives next to the plugin, or one level up when the plugin
// sits in <mpv>\scripts and the data in <mpv> itself.
std::string default_hrtf_file(const joc_mpv::Config& config) {
const char* name = (config.hrtf_source == 0) ? "binaural.sofa"
: "binaural.personalized_headphone";
const char* name = "binaural.personalized_headphone";
const std::string directory = plugin_directory();
const std::string candidates[] = {directory + "\\HRTF\\" + name,
directory + "\\..\\HRTF\\" + name};
@@ -315,16 +314,8 @@ struct Plugin {
settings.output = (config.output == 0) ? joc_decode::Output::kBinaural
: joc_decode::Output::kSpeaker;
settings.speaker_layout = config.layout;
settings.hrtf_source = (config.hrtf_source == 0) ? joc_decode::HrtfSource::kSofa
: joc_decode::HrtfSource::kRosella;
settings.rosella_filterbank =
static_cast<std::uint32_t>(config.rosella_filterbank);
if (config.rosella_filterbank != 0 &&
settings.hrtf_source != joc_decode::HrtfSource::kRosella) {
joc_log::line("config: joc-rosella-filterbank=%d ignored: it applies to "
"joc-hrtf-source=rosella only",
config.rosella_filterbank);
}
settings.hrtf_file = config.hrtf_file;
if (settings.hrtf_file.empty() && settings.output == joc_decode::Output::kBinaural) {
settings.hrtf_file = default_hrtf_file(config);
@@ -337,31 +328,6 @@ struct Plugin {
settings.native_threads = config.native_threads;
settings.ffmpeg_path = config.ffmpeg;
settings.core_path = config.core_dll;
// The compiled SOFA field is the dominant part of the startup cost;
// keeping it on disk makes every later file (and every seek restart-free
// start) skip that work.
if (config.verbose) {
joc_log::line("config: hrtf-cache=%s dir=%s", config.hrtf_cache.c_str(),
config.hrtf_cache_dir.c_str());
}
if (config.hrtf_cache == "none") {
settings.hrtf_cache_policy = 0;
} else if (config.hrtf_cache == "memory") {
settings.hrtf_cache_policy = 1;
} else {
// disk and auto: the config directory is the natural place for a
// cache; without one the renderer compiles in memory as before.
std::string directory = config.hrtf_cache_dir;
if (directory.empty() && !config_dir.empty()) {
directory = config_dir + "\\joc-hrtf-cache";
}
if (!directory.empty()) {
settings.hrtf_cache_policy = 2;
settings.hrtf_cache_dir = directory;
} else {
settings.hrtf_cache_policy = 1;
}
}
settings.pipeline_delay_samples = joc_decode::kJocSeekPipelineDelaySamples;
settings.seek_preroll_frames = joc_decode::kJocSeekPrerollFrames;
@@ -385,20 +351,9 @@ struct Plugin {
auto source = std::make_shared<joc_mpv::Source>();
std::string error;
if (!source->open(path, settings, duration, &error)) {
// A disk cache that cannot be used must not cost playback: retry the
// way this worked before the cache existed.
if (settings.hrtf_cache_policy == 2) {
joc_log::line("prepare: disk HRTF cache unusable (%s); retrying in memory",
error.c_str());
settings.hrtf_cache_policy = 1;
settings.hrtf_cache_dir.clear();
error.clear();
}
if (!source->open(path, settings, duration, &error)) {
joc_log::line("start: renderer failed for %s: %s", path.c_str(), error.c_str());
osd(mpv, "JOC: " + error);
return false;
}
joc_log::line("start: renderer failed for %s: %s", path.c_str(), error.c_str());
osd(mpv, "JOC: " + error);
return false;
}
auto created = std::make_shared<Stream>();
+3 -14
View File
@@ -497,9 +497,7 @@ std::string resolve_hrtf_file(const Settings& settings) {
if (directory.empty()) return {};
// Same convention as the reference CLI next to its executable:
// <base>\HRTF\binaural.sofa or <base>\HRTF\binaural.personalized_headphone.
const char* name = (settings.hrtf_source == HrtfSource::kRosella)
? "binaural.personalized_headphone"
: "binaural.sofa";
const char* name = "binaural.personalized_headphone";
return directory + "\\HRTF\\" + name;
}
@@ -1053,16 +1051,8 @@ bool Engine::start(const std::string& input_path, const Settings& settings, std:
}
return false;
}
if (settings.hrtf_source == HrtfSource::kRosella) {
config.personalized_headphone_path = hrtf_file.c_str();
} else {
config.hrtf_sofa_path = hrtf_file.c_str();
}
config.personalized_headphone_path = hrtf_file.c_str();
}
config.hrtf_cache_policy = settings.hrtf_cache_policy;
config.hrtf_cache_dir =
settings.hrtf_cache_dir.empty() ? nullptr : settings.hrtf_cache_dir.c_str();
config.hrtf_radius_m = settings.hrtf_radius_m;
config.binaural_tail_seconds = settings.tail_seconds;
config.object_delay_samples = settings.object_delay_samples;
config.gain_db = settings.gain_db;
@@ -1089,8 +1079,7 @@ bool Engine::start(const std::string& input_path, const Settings& settings, std:
joc_log::line("core: stream created, %u output channel(s), layout=%s, hrtf=%s", impl.channels,
settings.speaker_layout.c_str(),
hrtf_in_use.empty() ? "(none)" : hrtf_in_use.c_str());
if (settings.output == Output::kBinaural &&
settings.hrtf_source == HrtfSource::kRosella) {
if (settings.output == Output::kBinaural) {
joc_log::line("core: rosella filterbank=%s",
settings.rosella_filterbank == 2u ? "captured" : "public");
}
-11
View File
@@ -44,13 +44,6 @@ enum class Output {
kSpeaker = 1, // N channels, named layout
};
// Which HRTF to render with. Both inputs are user-facing model/data files; how
// the renderer gets from them to its internal filter field is its own business.
enum class HrtfSource {
kSofa = 0,
kRosella = 1,
};
// Where the E-AC-3 syncframes come from. A bare stream is read straight from the
// file; inside a container the track has to be extracted first (ffmpeg, stream copy).
enum class InputKind {
@@ -64,15 +57,11 @@ struct Settings {
// Which of the container's audio tracks holds the E-AC-3 stream, 0-based.
unsigned audio_index = 0;
std::string speaker_layout = "7.1";
HrtfSource hrtf_source = HrtfSource::kSofa;
// Filterbank of the Rosella path: 0 = the renderer's default (public bank),
// 2 = the captured bank. Only the Rosella input reads it.
std::uint32_t rosella_filterbank = 0;
// Empty means the default file in the default folder, see resolve_hrtf_file().
std::string hrtf_file;
std::string hrtf_cache_dir; // SOFA compile cache (disk policy)
unsigned hrtf_cache_policy = 1; // 0 none, 1 memory, 2 disk
double hrtf_radius_m = 1.0; // SOFA measurement-radius shell
std::uint32_t binaural_mode = 3; // JOC_BINAURAL_MID
double gain_db = 0.0;
double tail_seconds = 5.0;
-16
View File
@@ -83,14 +83,6 @@ Config parse_config(const std::string& script_opts, std::string* warnings) {
} else {
unsupported(key + "=" + value);
}
} else if (key == "joc-hrtf-source") {
if (value == "sofa") {
config.hrtf_source = 0;
} else if (value == "rosella" || value == "personalized") {
config.hrtf_source = 1;
} else {
unsupported(key + "=" + value);
}
} else if (key == "joc-rosella-filterbank") {
if (value == "1" || value == "public") {
config.rosella_filterbank = 1;
@@ -133,14 +125,6 @@ Config parse_config(const std::string& script_opts, std::string* warnings) {
config.log_path = value;
} else if (key == "joc-mute-until-ready") {
config.mute_until_ready = truthy(value);
} else if (key == "joc-hrtf-cache") {
if (value == "auto" || value == "memory" || value == "disk" || value == "none") {
config.hrtf_cache = value;
} else {
unsupported(key + "=" + value);
}
} else if (key == "joc-hrtf-cache-dir") {
config.hrtf_cache_dir = value;
} else if (key == "joc-chunk") {
const double seconds = std::atof(value.c_str());
config.chunk_seconds = (seconds >= 0.25 && seconds <= 10.0) ? seconds : 2.0;
-7
View File
@@ -11,10 +11,7 @@ struct Config {
// 0 = binaural (2 channels), 1 = speaker layout (N channels).
int output = 0;
std::string layout = "7.1";
// 0 = SOFA, 1 = Rosella personalized headphone model.
int hrtf_source = 0;
// Rosella filterbank: 0 = the renderer's default (public bank), 2 = captured.
// Only the Rosella input reads it; the SOFA and .jochrtf paths ignore it.
int rosella_filterbank = 0;
std::string hrtf_file; // empty: <plugin dir>\\HRTF\\binaural.<ext>
// 1 = near, 2 = far, 3 = mid (the renderer's own default).
@@ -37,10 +34,6 @@ struct Config {
// the opening moments are not the plain bed. Only candidate inputs are
// muted, and only for as long as the probe takes.
bool mute_until_ready = true;
// SOFA compilation cache: auto (disk under the mpv config directory, memory
// if that is unavailable), memory, disk, none.
std::string hrtf_cache = "auto";
std::string hrtf_cache_dir;
// Log file path; empty means <mpv config dir>\joc_decoder.log.
std::string log_path;
// Samples requested per HTTP response, in seconds of audio. A bounded