Support the two 4.0 layouts in the plugin and the fork
This commit is contained in:
1 parent
9a9bb7b0c8
commit
7d013fef46
8 files changed
+53
-22
No files matched your search
+2
-2
@@ -7,7 +7,7 @@ the engine and the settings are the same ones the upstream frontends
|
|||||||
the upstream project's command-line frontend uses, so the samples delivered to the player
|
the upstream project's command-line frontend uses, so the samples delivered to the player
|
||||||
are **bit-identical**.
|
are **bit-identical**.
|
||||||
|
|
||||||
* Output: binaural (HRTF) or a 2.0 – 7.1 speaker layout;
|
* Output: binaural (HRTF) or a 2.0 – 9.1.6 speaker layout;
|
||||||
* Output device: mpv's own audio output, i.e. WASAPI on Windows (optionally
|
* Output device: mpv's own audio output, i.e. WASAPI on Windows (optionally
|
||||||
forced, optionally exclusive);
|
forced, optionally exclusive);
|
||||||
* Configuration: mpv's own configuration file, with one `joc-*` option namespace;
|
* Configuration: mpv's own configuration file, with one `joc-*` option namespace;
|
||||||
@@ -84,7 +84,7 @@ ignored and reported in `joc_decoder.log`.
|
|||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| `joc-enabled` | yes / no | yes | disable the plugin entirely |
|
| `joc-enabled` | yes / no | yes | disable the plugin entirely |
|
||||||
| `joc-output` | binaural / speaker | binaural | output form |
|
| `joc-output` | binaural / speaker | binaural | output form |
|
||||||
| `joc-layout` | 2.0 3.1 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 |
|
| `joc-layout` | 2.0 3.1 "4.0 Surround" "4.0 Quad" 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; quote a name that has a space in it, and the old `4.0` still means `4.0 Surround` |
|
||||||
| `joc-hrtf-source` | sofa / rosella | sofa | binaural HRTF input |
|
| `joc-hrtf-source` | sofa / rosella | sofa | binaural HRTF input |
|
||||||
| `joc-hrtf` | path | empty | empty: default name under `<plugin>\\HRTF\\` or `<plugin>\\..\\HRTF\\` |
|
| `joc-hrtf` | path | empty | empty: default name under `<plugin>\\HRTF\\` or `<plugin>\\..\\HRTF\\` |
|
||||||
| `joc-mode` | near / mid / far | mid | binaural mode |
|
| `joc-mode` | near / mid / far | mid | binaural mode |
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mpv C 插件(cplugins)。它把 E-AC-3 JOC 码流里的对象音频交给
|
|||||||
上游项目的命令行前端相同的引擎、相同的设置、相同的 `joc_core.dll`,
|
上游项目的命令行前端相同的引擎、相同的设置、相同的 `joc_core.dll`,
|
||||||
因此同一个文件在两个前端上得到的采样**逐字节一致**。
|
因此同一个文件在两个前端上得到的采样**逐字节一致**。
|
||||||
|
|
||||||
- 输出:双耳(HRTF)或 2.0 – 7.1 的扬声器布局;
|
- 输出:双耳(HRTF)或 2.0 – 9.1.6 的扬声器布局;
|
||||||
- 输出设备:照常走 mpv 的音频输出,Windows 上即 WASAPI(可强制 `ao=wasapi`、可开独占);
|
- 输出设备:照常走 mpv 的音频输出,Windows 上即 WASAPI(可强制 `ao=wasapi`、可开独占);
|
||||||
- 配置:mpv 自己的配置文件,新增 `joc-*` 这一个选项命名空间(见下);
|
- 配置:mpv 自己的配置文件,新增 `joc-*` 这一个选项命名空间(见下);
|
||||||
- 输入:裸流 `.eac3` / `.ec3`,或 MP4 / Matroska 里的 E-AC-3 JOC 轨(有视频也照常播);
|
- 输入:裸流 `.eac3` / `.ec3`,或 MP4 / Matroska 里的 E-AC-3 JOC 轨(有视频也照常播);
|
||||||
@@ -98,7 +98,7 @@ mpv --script="C:\\path\\to\\joc_mpv.dll" --script-opts=joc-output=speaker,joc-la
|
|||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| `joc-enabled` | yes / no | yes | 关掉后插件完全不介入 |
|
| `joc-enabled` | yes / no | yes | 关掉后插件完全不介入 |
|
||||||
| `joc-output` | binaural / speaker | binaural | 输出形式 |
|
| `joc-output` | binaural / speaker | binaural | 输出形式 |
|
||||||
| `joc-layout` | 2.0 3.1 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-layout` | 2.0 3.1 "4.0 Surround" "4.0 Quad" 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` 使用。带空格的布局名整体加引号;旧值 `4.0` 仍按 `4.0 Surround` 处理 |
|
||||||
| `joc-hrtf-source` | sofa / rosella | sofa | 双耳用哪种 HRTF 输入 |
|
| `joc-hrtf-source` | sofa / rosella | sofa | 双耳用哪种 HRTF 输入 |
|
||||||
| `joc-hrtf` | 路径 | 空 | 空则用 `<插件目录>\\HRTF\\` 或 `<插件目录>\\..\\HRTF\\` 下的默认文件名 |
|
| `joc-hrtf` | 路径 | 空 | 空则用 `<插件目录>\\HRTF\\` 或 `<插件目录>\\..\\HRTF\\` 下的默认文件名 |
|
||||||
| `joc-mode` | near / mid / far | mid | 双耳模式 |
|
| `joc-mode` | near / mid / far | mid | 双耳模式 |
|
||||||
|
|||||||
+1
-1
@@ -136,7 +136,7 @@ ad-joc-gain-db = 0
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `--ad-joc-binaural` | yes / no | yes |
|
| `--ad-joc-binaural` | yes / no | yes |
|
||||||
| `--ad-joc-hrtf` | SOFA / Rosella / `.jochrtf` 路径 | 空(自动搜索) |
|
| `--ad-joc-hrtf` | SOFA / Rosella / `.jochrtf` 路径 | 空(自动搜索) |
|
||||||
| `--ad-joc-layout` | `2.0` `3.0` `3.1` `4.0` `5.0` `5.1` `5.1.2` `5.1.4` `6.1` `7.0` `7.1` `7.1.2` `7.1.4` `9.1.4` `9.1.6` | 7.1 |
|
| `--ad-joc-layout` | `2.0` `3.1` `4.0 Surround` `4.0 Quad` `5.1` `7.1` `5.1.2` `5.1.4` `7.1.2` `7.1.4` `9.1.4` `9.1.6`(旧值 `4.0` 仍按 `4.0 Surround`) | 7.1 |
|
||||||
| `--ad-joc-mode` | near / far / mid | mid |
|
| `--ad-joc-mode` | near / far / mid | mid |
|
||||||
| `--ad-joc-gain-db` | -60 … 12 | 0 |
|
| `--ad-joc-gain-db` | -60 … 12 | 0 |
|
||||||
| `--ad-joc-int24` | yes / no | no |
|
| `--ad-joc-int24` | yes / no | no |
|
||||||
|
|||||||
@@ -551,7 +551,11 @@ static const struct mp_filter_info ad_joc_filter = {
|
|||||||
|
|
||||||
/* mpv names layouts up to 7.1 itself; the renderer goes further (it is a Dolby
|
/* mpv names layouts up to 7.1 itself; the renderer goes further (it is a Dolby
|
||||||
* Atmos renderer, so 5.1.2 … 9.1.6 follow the usual speaker order). Spell the
|
* Atmos renderer, so 5.1.2 … 9.1.6 follow the usual speaker order). Spell the
|
||||||
* wider ones out as speaker lists so mpv knows which channel is which. */
|
* wider ones out as speaker lists so mpv knows which channel is which.
|
||||||
|
*
|
||||||
|
* The two 4.0 layouts are different speaker sets: Surround is a front trio plus a
|
||||||
|
* back-centre speaker, Quad is a front and a back pair. "4.0" is the name the
|
||||||
|
* option used before they were told apart and still means the Surround layout. */
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *speakers;
|
const char *speakers;
|
||||||
@@ -560,6 +564,8 @@ static const struct {
|
|||||||
{"3.0", "fl-fr-fc"},
|
{"3.0", "fl-fr-fc"},
|
||||||
{"3.1", "fl-fr-fc-lfe"},
|
{"3.1", "fl-fr-fc-lfe"},
|
||||||
{"4.0", "fl-fr-fc-bc"},
|
{"4.0", "fl-fr-fc-bc"},
|
||||||
|
{"4.0 Surround", "fl-fr-fc-bc"},
|
||||||
|
{"4.0 Quad", "fl-fr-bl-br"},
|
||||||
{"5.0", "fl-fr-fc-bl-br"},
|
{"5.0", "fl-fr-fc-bl-br"},
|
||||||
{"5.1", "fl-fr-fc-lfe-bl-br"},
|
{"5.1", "fl-fr-fc-lfe-bl-br"},
|
||||||
{"5.1.2", "fl-fr-fc-lfe-bl-br-tfl-tfr"},
|
{"5.1.2", "fl-fr-fc-lfe-bl-br-tfl-tfr"},
|
||||||
|
|||||||
+8
-4
@@ -354,10 +354,14 @@ private:
|
|||||||
HANDLE handle_ = INVALID_HANDLE_VALUE;
|
HANDLE handle_ = INVALID_HANDLE_VALUE;
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* const kLayouts[] = {"2.0", "3.0", "3.1", "4.0", "5.0", "5.1", "5.1.2",
|
// The layouts the core accepts, with their channel counts. "4.0" is the old
|
||||||
"5.1.4", "6.1", "7.0", "7.1", "7.1.2", "7.1.4", "9.1.4",
|
// spelling of 4.0 Surround and is resolved to it before the core is asked, but the
|
||||||
"9.1.6"};
|
// count table keeps it too so an old configuration still logs its real width.
|
||||||
const unsigned kLayoutChannels[] = {2, 3, 4, 4, 5, 6, 8, 10, 7, 7, 8, 10, 12, 14, 16};
|
const char* const kLayouts[] = {"2.0", "3.1",
|
||||||
|
"4.0 Surround", "4.0 Quad", "4.0",
|
||||||
|
"5.1", "7.1", "5.1.2", "5.1.4",
|
||||||
|
"7.1.2", "7.1.4", "9.1.4", "9.1.6"};
|
||||||
|
const unsigned kLayoutChannels[] = {2, 4, 4, 4, 4, 6, 8, 8, 10, 10, 12, 14, 16};
|
||||||
|
|
||||||
// Every ffmpeg child writes its diagnostics next to the component rather than into
|
// Every ffmpeg child writes its diagnostics next to the component rather than into
|
||||||
// whatever working directory the host process happens to have; separate files so
|
// whatever working directory the host process happens to have; separate files so
|
||||||
|
|||||||
+13
-5
@@ -29,20 +29,28 @@ bool truthy(const std::string& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The layout names the renderer accepts, in the order its reference lists them.
|
// The layout names the renderer accepts, in the order its reference lists them.
|
||||||
const char* const kLayouts[] = {"2.0", "3.1", "5.1", "7.1", "5.1.2",
|
const char* const kLayouts[] = {"2.0", "3.1", "4.0 Surround", "4.0 Quad",
|
||||||
"5.1.4", "7.1.2", "7.1.4", "9.1.4", "9.1.6"};
|
"5.1", "7.1", "5.1.2", "5.1.4",
|
||||||
|
"7.1.2", "7.1.4", "9.1.4", "9.1.6"};
|
||||||
|
|
||||||
|
// "4.0" is the spelling the option had before the two 4.0 layouts were told
|
||||||
|
// apart; it has always meant the layout now called 4.0 Surround.
|
||||||
|
std::string canonical_layout(const std::string& layout) {
|
||||||
|
return layout == "4.0" ? "4.0 Surround" : layout;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
const char* layout_list() {
|
const char* layout_list() {
|
||||||
return "2.0, 3.1, 5.1, 7.1, 5.1.2, 5.1.4, 7.1.2, 7.1.4, 9.1.4, 9.1.6";
|
return "2.0, 3.1, 4.0 Surround, 4.0 Quad, 5.1, 7.1, 5.1.2, 5.1.4, 7.1.2, 7.1.4, "
|
||||||
|
"9.1.4, 9.1.6";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool valid_layout(const std::string& layout) {
|
bool valid_layout(const std::string& layout) {
|
||||||
for (const char* name : kLayouts) {
|
for (const char* name : kLayouts) {
|
||||||
if (layout == name) return true;
|
if (layout == name) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return layout == "4.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
Config parse_config(const std::string& script_opts, std::string* warnings) {
|
Config parse_config(const std::string& script_opts, std::string* warnings) {
|
||||||
@@ -83,7 +91,7 @@ Config parse_config(const std::string& script_opts, std::string* warnings) {
|
|||||||
}
|
}
|
||||||
} else if (key == "joc-layout") {
|
} else if (key == "joc-layout") {
|
||||||
if (valid_layout(value)) {
|
if (valid_layout(value)) {
|
||||||
config.layout = value;
|
config.layout = canonical_layout(value);
|
||||||
} else {
|
} else {
|
||||||
unsupported(key + "=" + value);
|
unsupported(key + "=" + value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ constexpr std::uint32_t kFc = 0x00000004u;
|
|||||||
constexpr std::uint32_t kLfe = 0x00000008u;
|
constexpr std::uint32_t kLfe = 0x00000008u;
|
||||||
constexpr std::uint32_t kBl = 0x00000010u;
|
constexpr std::uint32_t kBl = 0x00000010u;
|
||||||
constexpr std::uint32_t kBr = 0x00000020u;
|
constexpr std::uint32_t kBr = 0x00000020u;
|
||||||
|
constexpr std::uint32_t kBc = 0x00000100u;
|
||||||
constexpr std::uint32_t kSl = 0x00000200u;
|
constexpr std::uint32_t kSl = 0x00000200u;
|
||||||
constexpr std::uint32_t kSr = 0x00000400u;
|
constexpr std::uint32_t kSr = 0x00000400u;
|
||||||
constexpr std::uint32_t kTfl = 0x00001000u;
|
constexpr std::uint32_t kTfl = 0x00001000u;
|
||||||
@@ -67,6 +68,11 @@ void put_fmt(std::string* out, unsigned channels, unsigned bits, std::uint32_t m
|
|||||||
std::uint32_t channel_mask(const std::string& layout, unsigned channels) {
|
std::uint32_t channel_mask(const std::string& layout, unsigned channels) {
|
||||||
if (layout == "2.0") return kFl | kFr;
|
if (layout == "2.0") return kFl | kFr;
|
||||||
if (layout == "3.1") return kFl | kFr | kFc | kLfe;
|
if (layout == "3.1") return kFl | kFr | kFc | kLfe;
|
||||||
|
// The two 4.0 layouts differ in their speaker set, not only in their name:
|
||||||
|
// Surround has a front trio and one back-centre speaker, Quad has a front and
|
||||||
|
// a back pair and neither centre nor LFE. "4.0" is the old name of the former.
|
||||||
|
if (layout == "4.0 Surround" || layout == "4.0") return kFl | kFr | kFc | kBc;
|
||||||
|
if (layout == "4.0 Quad") return kFl | kFr | kBl | kBr;
|
||||||
if (layout == "5.1") return kFl | kFr | kFc | kLfe | kBl | kBr;
|
if (layout == "5.1") return kFl | kFr | kFc | kLfe | kBl | kBr;
|
||||||
if (layout == "7.1") return kFl | kFr | kFc | kLfe | kBl | kBr | kSl | kSr;
|
if (layout == "7.1") return kFl | kFr | kFc | kLfe | kBl | kBr | kSl | kSr;
|
||||||
if (layout == "5.1.2") return kFl | kFr | kFc | kLfe | kBl | kBr | kTfl | kTfr;
|
if (layout == "5.1.2") return kFl | kFr | kFc | kLfe | kBl | kBr | kTfl | kTfr;
|
||||||
|
|||||||
+14
-7
@@ -18,9 +18,13 @@ $log = Join-Path (Split-Path $Plugin) "joc_decoder.log"
|
|||||||
|
|
||||||
function Invoke-Capture([string]$options, [string]$output) {
|
function Invoke-Capture([string]$options, [string]$output) {
|
||||||
Remove-Item -Force $log -ErrorAction SilentlyContinue
|
Remove-Item -Force $log -ErrorAction SilentlyContinue
|
||||||
|
# Start-Process joins the array with spaces and quotes nothing, so an option
|
||||||
|
# value with a space in it (a layout name such as "4.0 Surround") has to be
|
||||||
|
# quoted here or mpv would receive it as two arguments.
|
||||||
|
$script_opts = "joc-verbose=yes,joc-attach=no,joc-log=$log,$options"
|
||||||
$arguments = @("--no-config", "--ao=null", "--vo=null", "--pause=yes",
|
$arguments = @("--no-config", "--ao=null", "--vo=null", "--pause=yes",
|
||||||
"--script=$Plugin", "--script-opts=joc-verbose=yes,joc-attach=no,joc-log=$log,$options",
|
"--script=$Plugin", "--script-opts=`"$script_opts`"",
|
||||||
"--msg-level=all=info", $Media)
|
"--msg-level=all=info", "`"$Media`"")
|
||||||
Start-Process -FilePath $mpv -ArgumentList $arguments -PassThru -WindowStyle Hidden | Out-Null
|
Start-Process -FilePath $mpv -ArgumentList $arguments -PassThru -WindowStyle Hidden | Out-Null
|
||||||
$url = $null
|
$url = $null
|
||||||
for ($i = 0; $i -lt 120; $i++) {
|
for ($i = 0; $i -lt 120; $i++) {
|
||||||
@@ -58,13 +62,16 @@ if ($Rosella -ne "") {
|
|||||||
& $Python (Join-Path $PSScriptRoot "compare_wav.py") $actual $reference
|
& $Python (Join-Path $PSScriptRoot "compare_wav.py") $actual $reference
|
||||||
if ($LASTEXITCODE -ne 0) { $failures++ }
|
if ($LASTEXITCODE -ne 0) { $failures++ }
|
||||||
}
|
}
|
||||||
Write-Output "=== speaker 7.1 float32 ==="
|
foreach ($layout in @("7.1", "4.0 Surround", "4.0 Quad")) {
|
||||||
$reference = Join-Path $WorkDir "reference.7.1.f32.wav"
|
Write-Output "=== speaker $layout float32 ==="
|
||||||
$actual = Join-Path $WorkDir "plugin.7.1.f32.wav"
|
$tag = $layout -replace " ", "_"
|
||||||
& $JocCli $Media --speaker-layout 7.1 --speaker-format float32 --speaker-output $reference | Out-Null
|
$reference = Join-Path $WorkDir "reference.$tag.f32.wav"
|
||||||
Invoke-Capture "joc-output=speaker,joc-layout=7.1" $actual
|
$actual = Join-Path $WorkDir "plugin.$tag.f32.wav"
|
||||||
|
& $JocCli $Media --speaker-layout $layout --speaker-format float32 --speaker-output $reference | Out-Null
|
||||||
|
Invoke-Capture "joc-output=speaker,joc-layout=$layout" $actual
|
||||||
& $Python (Join-Path $PSScriptRoot "compare_wav.py") $actual $reference
|
& $Python (Join-Path $PSScriptRoot "compare_wav.py") $actual $reference
|
||||||
if ($LASTEXITCODE -ne 0) { $failures++ }
|
if ($LASTEXITCODE -ne 0) { $failures++ }
|
||||||
|
}
|
||||||
|
|
||||||
if ($failures -ne 0) { throw "$failures comparison(s) failed" }
|
if ($failures -ne 0) { throw "$failures comparison(s) failed" }
|
||||||
Write-Output "all comparisons passed"
|
Write-Output "all comparisons passed"
|
||||||
Reference in new issue
Block a user