Support the two 4.0 layouts in the plugin and the fork

This commit is contained in:
TheM14 committed 2026-10-27 23:52:43 +08:00
1 parent 9a9bb7b0c8
commit 7d013fef46
8 files changed
+56 -25

No files matched your search

+8 -4
View File
@@ -354,10 +354,14 @@ private:
HANDLE handle_ = INVALID_HANDLE_VALUE;
};
const char* const kLayouts[] = {"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"};
const unsigned kLayoutChannels[] = {2, 3, 4, 4, 5, 6, 8, 10, 7, 7, 8, 10, 12, 14, 16};
// The layouts the core accepts, with their channel counts. "4.0" is the old
// spelling of 4.0 Surround and is resolved to it before the core is asked, but the
// count table keeps it too so an old configuration still logs its real width.
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
// whatever working directory the host process happens to have; separate files so
+13 -5
View File
@@ -29,20 +29,28 @@ bool truthy(const std::string& value) {
}
// 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",
"5.1.4", "7.1.2", "7.1.4", "9.1.4", "9.1.6"};
const char* const kLayouts[] = {"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" 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
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) {
for (const char* name : kLayouts) {
if (layout == name) return true;
}
return false;
return layout == "4.0";
}
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") {
if (valid_layout(value)) {
config.layout = value;
config.layout = canonical_layout(value);
} else {
unsupported(key + "=" + value);
}
+6
View File
@@ -11,6 +11,7 @@ constexpr std::uint32_t kFc = 0x00000004u;
constexpr std::uint32_t kLfe = 0x00000008u;
constexpr std::uint32_t kBl = 0x00000010u;
constexpr std::uint32_t kBr = 0x00000020u;
constexpr std::uint32_t kBc = 0x00000100u;
constexpr std::uint32_t kSl = 0x00000200u;
constexpr std::uint32_t kSr = 0x00000400u;
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) {
if (layout == "2.0") return kFl | kFr;
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 == "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;