diff --git a/README.en.md b/README.en.md index 07d3f68..a8b46cc 100644 --- a/README.en.md +++ b/README.en.md @@ -66,7 +66,7 @@ then `\\joc_core.dll`, then `\\..\\joc_core.dll`, then ` Add to `mpv.conf`: ```ini -script-opts=joc-output=binaural,joc-hrtf-source=sofa +script-opts=joc-output=binaural ``` Or load it explicitly: @@ -85,8 +85,7 @@ ignored and reported in `joc_decoder.log`. | `joc-enabled` | yes / no | yes | disable the plugin entirely | | `joc-output` | binaural / speaker | binaural | output form | | `joc-layout` | 2.0 3.1 4.0 5.1 7.1 5.1.2 5.1.4 7.1.2 7.1.4 9.1.4 9.1.6 | 7.1 | speaker layout; used only with `speaker` | -| `joc-hrtf-source` | sofa / rosella | sofa | binaural HRTF input | -| `joc-rosella-filterbank` | 1 / 2 (or public / captured) | 1 | Rosella filterbank: 1 = the public 13-tap / 6-slot bank, 2 = the captured 11-tap / 3-slot bank that matches the reference renderer; only read with `joc-hrtf-source=rosella` | +| `joc-rosella-filterbank` | 1 / 2 (or public / captured) | 1 | Rosella filterbank: 1 = the public 13-tap / 6-slot bank, 2 = the captured 11-tap / 3-slot bank that matches the reference renderer | | `joc-hrtf` | path | empty | empty: default name under `\\HRTF\\` or `\\..\\HRTF\\` | | `joc-mode` | near / mid / far | mid | binaural mode | | `joc-gain-db` | float (dB) | 0 | render gain (binaural can exceed full scale) | @@ -100,8 +99,6 @@ ignored and reported in `joc_decoder.log`. | `joc-exclusive` | yes / no | no | sets `audio-exclusive=yes` | | `joc-chunk` | seconds | 2.0 | audio bytes written per HTTP chunk | | `joc-mute-until-ready` | yes / no | yes | silence the file's own track until the rendered one is selected | -| `joc-hrtf-cache` | auto / memory / disk / none | auto | compiled-HRTF cache; auto = `\\joc-hrtf-cache` | -| `joc-hrtf-cache-dir` | path | empty | explicit cache directory | | `joc-attach` | yes / no | yes | no: serve the stream without adding the track (capture/verification) | | `joc-verbose` | yes / no | no | log every HTTP request and reposition | | `joc-log` | path | empty | log file; empty: `\\joc_decoder.log` | diff --git a/README.md b/README.md index 62a339f..85ca322 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ mpv-joc/ 然后编辑 `mpv.conf`(同一目录): ```ini -script-opts=joc-output=binaural,joc-hrtf-source=sofa +script-opts=joc-output=binaural ``` 也可以显式加载: @@ -99,8 +99,7 @@ mpv --script="C:\\path\\to\\joc_mpv.dll" --script-opts=joc-output=speaker,joc-la | `joc-enabled` | yes / no | yes | 关掉后插件完全不介入 | | `joc-output` | binaural / speaker | binaural | 输出形式 | | `joc-layout` | 2.0 3.1 4.0 5.1 7.1 5.1.2 5.1.4 7.1.2 7.1.4 9.1.4 9.1.6 | 7.1 | 扬声器布局;仅 `speaker` 使用 | -| `joc-hrtf-source` | sofa / rosella | sofa | 双耳用哪种 HRTF 输入 | -| `joc-rosella-filterbank` | 1 / 2(或 public / captured) | 1 | Rosella 滤波器组:1=13 taps/6 slots 的公开版,2=11 taps/3 slots 的捕获版(与参考渲染器一致);仅 `joc-hrtf-source=rosella` 使用 | +| `joc-rosella-filterbank` | 1 / 2(或 public / captured) | 1 | Rosella 滤波器组:1=13 taps/6 slots 的公开版,2=11 taps/3 slots 的捕获版(与参考渲染器一致) | | `joc-hrtf` | 路径 | 空 | 空则用 `<插件目录>\\HRTF\\` 或 `<插件目录>\\..\\HRTF\\` 下的默认文件名 | | `joc-mode` | near / mid / far | mid | 双耳模式 | | `joc-gain-db` | 浮点(dB) | 0 | 渲染增益;双耳可能超过满刻度,需要时在这里衰减 | @@ -114,8 +113,6 @@ mpv --script="C:\\path\\to\\joc_mpv.dll" --script-opts=joc-output=speaker,joc-la | `joc-exclusive` | yes / no | no | 设置 `audio-exclusive=yes`(WASAPI 独占) | | `joc-chunk` | 秒 | 2.0 | 每次写入 mpv 的音频块大小(0.25–10) | | `joc-mute-until-ready` | yes / no | yes | 渲染轨就绪前先把文件自带音轨静音,片头不会先播一遍普通 bed | -| `joc-hrtf-cache` | auto / memory / disk / none | auto | 编译后的 HRTF(`.jochrtf`)缓存位置;auto = `\\joc-hrtf-cache` | -| `joc-hrtf-cache-dir` | 路径 | 空 | 显式指定缓存目录 | | `joc-attach` | yes / no | yes | no = 只提供音频端点、不向播放器加轨(抓取/验证用) | | `joc-verbose` | yes / no | no | 在日志里记录每个 HTTP 请求与跳转 | | `joc-log` | 路径 | 空 | 日志文件;空则写 `\\joc_decoder.log` | diff --git a/config/cplugin-mpv.conf.example b/config/cplugin-mpv.conf.example index 94b7b22..fdb9b8c 100644 --- a/config/cplugin-mpv.conf.example +++ b/config/cplugin-mpv.conf.example @@ -2,9 +2,9 @@ # # 所有键都在 mpv 自己的 --script-opts 命名空间里,前缀 joc-。 # 只有一行也可以: -# script-opts=joc-output=binaural,joc-hrtf-source=sofa +# script-opts=joc-output=binaural # -script-opts=joc-output=binaural,joc-hrtf-source=sofa,joc-mode=mid,joc-gain-db=0 +script-opts=joc-output=binaural,joc-mode=mid,joc-gain-db=0 # 想让插件强制走 WASAPI(默认 auto:不动 mpv 的 ao 选择): # script-opts-append=joc-wasapi=yes @@ -19,7 +19,6 @@ script-opts=joc-output=binaural,joc-hrtf-source=sofa,joc-mode=mid,joc-gain-db=0 # script-opts-append=joc-hrtf=D:/hrtf/MyMeasurements.sofa # # Rosella 模型用捕获版滤波器组(与参考渲染器一致;默认 1 = 公开版): -# script-opts-append=joc-hrtf-source=rosella # script-opts-append=joc-rosella-filterbank=2 # # 交付 24bit 定点: diff --git a/fork/files/audio/decode/joc_core.h b/fork/files/audio/decode/joc_core.h index 1369317..428597b 100644 --- a/fork/files/audio/decode/joc_core.h +++ b/fork/files/audio/decode/joc_core.h @@ -358,14 +358,6 @@ typedef enum joc_clip_action { JOC_CLIP_ABORT = 3 /* fail the task */ } joc_clip_action; -/* Compiled-HRTF cache policy for a SOFA input; the .jochrtf itself is an - * internal artifact of the compile step. */ -typedef enum joc_hrtf_cache_policy { - JOC_HRTF_CACHE_NONE = 0, /* compile and discard */ - JOC_HRTF_CACHE_MEMORY = 1, /* compile and keep in this process (default) */ - JOC_HRTF_CACHE_DISK = 2 /* compile, reuse and write /.jochrtf */ -} joc_hrtf_cache_policy; - /* Which 64-QMF / 77-hybrid filterbank the Rosella .personalized_headphone path * renders through. The two banks differ in coefficients, hybrid tap count, * high-band slot delay and total latency, so they are not interchangeable; the @@ -424,16 +416,11 @@ typedef struct joc_task_config { joc_cancel_token* cancel; /* optional */ - /* Binaural HRTF input (config version 2): when hrtf_sofa_path is set the - * library compiles it with hrtf_cache_policy / hrtf_cache_dir / hrtf_radius_m - * and hrtf_path is unused. hrtf_path stays the advanced override that reads - * a .jochrtf directly. */ - const char* hrtf_sofa_path; /* SOFA SimpleFreeFieldHRIR input */ + /* Binaural input (config version 2): a compiled .jochrtf field (hrtf_path) + * or a Rosella .personalized_headphone model. */ const char* personalized_headphone_path; /* Rosella .personalized_headphone input */ - const char* hrtf_cache_dir; /* disk policy directory */ - uint32_t hrtf_cache_policy; /* joc_hrtf_cache_policy */ uint32_t rosella_filterbank; /* joc_rosella_filterbank; 0 = PUBLIC */ - double hrtf_radius_m; /* SOFA measurement-radius shell */ + uint32_t jochrtf_room; /* non-zero enables the project room */ } joc_task_config; typedef enum joc_task_status { diff --git a/fork/files/audio/decode/joc_stream.h b/fork/files/audio/decode/joc_stream.h index b942f4f..7511483 100644 --- a/fork/files/audio/decode/joc_stream.h +++ b/fork/files/audio/decode/joc_stream.h @@ -64,16 +64,10 @@ typedef struct joc_stream_config { double gain_db; /* default 0 */ uint32_t native_threads; uint32_t rosella_filterbank; /* joc_rosella_filterbank; Rosella input, 0 = PUBLIC */ - /* Binaural HRTF input, the same three shapes joc_task_config accepts: when - * hrtf_sofa_path is set the library compiles it with hrtf_cache_policy / - * hrtf_cache_dir / hrtf_radius_m and hrtf_path is unused; when - * personalized_headphone_path is set the Rosella runtime renders instead. - * hrtf_path stays the fallback/advanced input that reads a .jochrtf directly. */ - const char* hrtf_sofa_path; /* SOFA SimpleFreeFieldHRIR input */ + /* Binaural input, the same shapes joc_task_config accepts: a compiled + * .jochrtf field (hrtf_path) or a Rosella .personalized_headphone model. */ const char* personalized_headphone_path; /* Rosella .personalized_headphone input */ - const char* hrtf_cache_dir; /* disk cache directory for SOFA compilation */ - uint32_t hrtf_cache_policy; /* joc_hrtf_cache_policy: 0 none, 1 memory, 2 disk */ - double hrtf_radius_m; /* SOFA measurement-radius shell, default 1.0 */ + uint32_t jochrtf_room; /* non-zero enables the project room */ } joc_stream_config; typedef struct joc_stream_buffer { diff --git a/src/cplugin_main.cpp b/src/cplugin_main.cpp index 46e55ef..4019f5c 100644 --- a/src/cplugin_main.cpp +++ b/src/cplugin_main.cpp @@ -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 \scripts and the data in 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(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(); 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(); diff --git a/src/joc_decode.cpp b/src/joc_decode.cpp index e93b52f..976e135 100644 --- a/src/joc_decode.cpp +++ b/src/joc_decode.cpp @@ -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: // \HRTF\binaural.sofa or \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"); } diff --git a/src/joc_decode.h b/src/joc_decode.h index 0266b92..3c8218a 100644 --- a/src/joc_decode.h +++ b/src/joc_decode.h @@ -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; diff --git a/src/plugin/config.cpp b/src/plugin/config.cpp index 1edfdf1..02d33e2 100644 --- a/src/plugin/config.cpp +++ b/src/plugin/config.cpp @@ -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; diff --git a/src/plugin/config.h b/src/plugin/config.h index 88327b0..8a71e04 100644 --- a/src/plugin/config.h +++ b/src/plugin/config.h @@ -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: \\HRTF\\binaural. // 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 \joc_decoder.log. std::string log_path; // Samples requested per HTTP response, in seconds of audio. A bounded diff --git a/third_party/joc/include/joc_core.h b/third_party/joc/include/joc_core.h index 1369317..428597b 100644 --- a/third_party/joc/include/joc_core.h +++ b/third_party/joc/include/joc_core.h @@ -358,14 +358,6 @@ typedef enum joc_clip_action { JOC_CLIP_ABORT = 3 /* fail the task */ } joc_clip_action; -/* Compiled-HRTF cache policy for a SOFA input; the .jochrtf itself is an - * internal artifact of the compile step. */ -typedef enum joc_hrtf_cache_policy { - JOC_HRTF_CACHE_NONE = 0, /* compile and discard */ - JOC_HRTF_CACHE_MEMORY = 1, /* compile and keep in this process (default) */ - JOC_HRTF_CACHE_DISK = 2 /* compile, reuse and write /.jochrtf */ -} joc_hrtf_cache_policy; - /* Which 64-QMF / 77-hybrid filterbank the Rosella .personalized_headphone path * renders through. The two banks differ in coefficients, hybrid tap count, * high-band slot delay and total latency, so they are not interchangeable; the @@ -424,16 +416,11 @@ typedef struct joc_task_config { joc_cancel_token* cancel; /* optional */ - /* Binaural HRTF input (config version 2): when hrtf_sofa_path is set the - * library compiles it with hrtf_cache_policy / hrtf_cache_dir / hrtf_radius_m - * and hrtf_path is unused. hrtf_path stays the advanced override that reads - * a .jochrtf directly. */ - const char* hrtf_sofa_path; /* SOFA SimpleFreeFieldHRIR input */ + /* Binaural input (config version 2): a compiled .jochrtf field (hrtf_path) + * or a Rosella .personalized_headphone model. */ const char* personalized_headphone_path; /* Rosella .personalized_headphone input */ - const char* hrtf_cache_dir; /* disk policy directory */ - uint32_t hrtf_cache_policy; /* joc_hrtf_cache_policy */ uint32_t rosella_filterbank; /* joc_rosella_filterbank; 0 = PUBLIC */ - double hrtf_radius_m; /* SOFA measurement-radius shell */ + uint32_t jochrtf_room; /* non-zero enables the project room */ } joc_task_config; typedef enum joc_task_status { diff --git a/third_party/joc/include/joc_stream.h b/third_party/joc/include/joc_stream.h index b942f4f..7511483 100644 --- a/third_party/joc/include/joc_stream.h +++ b/third_party/joc/include/joc_stream.h @@ -64,16 +64,10 @@ typedef struct joc_stream_config { double gain_db; /* default 0 */ uint32_t native_threads; uint32_t rosella_filterbank; /* joc_rosella_filterbank; Rosella input, 0 = PUBLIC */ - /* Binaural HRTF input, the same three shapes joc_task_config accepts: when - * hrtf_sofa_path is set the library compiles it with hrtf_cache_policy / - * hrtf_cache_dir / hrtf_radius_m and hrtf_path is unused; when - * personalized_headphone_path is set the Rosella runtime renders instead. - * hrtf_path stays the fallback/advanced input that reads a .jochrtf directly. */ - const char* hrtf_sofa_path; /* SOFA SimpleFreeFieldHRIR input */ + /* Binaural input, the same shapes joc_task_config accepts: a compiled + * .jochrtf field (hrtf_path) or a Rosella .personalized_headphone model. */ const char* personalized_headphone_path; /* Rosella .personalized_headphone input */ - const char* hrtf_cache_dir; /* disk cache directory for SOFA compilation */ - uint32_t hrtf_cache_policy; /* joc_hrtf_cache_policy: 0 none, 1 memory, 2 disk */ - double hrtf_radius_m; /* SOFA measurement-radius shell, default 1.0 */ + uint32_t jochrtf_room; /* non-zero enables the project room */ } joc_stream_config; typedef struct joc_stream_buffer {