From 618dcf1ff2eeef89ace9794b1c6bb8ee74db61bb Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 21 Sep 2022 15:59:59 +0200 Subject: [PATCH] merge: add option --list-stereo-modes for listing available stereo modes --- src/common/stereo_mode.cpp | 13 +++++++++++++ src/common/stereo_mode.h | 1 + src/merge/mkvmerge.cpp | 8 +++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/common/stereo_mode.cpp b/src/common/stereo_mode.cpp index 8463f80f8..f61ca9f63 100644 --- a/src/common/stereo_mode.cpp +++ b/src/common/stereo_mode.cpp @@ -14,6 +14,7 @@ #include "common/common_pch.h" #include "common/stereo_mode.h" +#include "common/strings/table_formatter.h" #include #include @@ -94,3 +95,15 @@ bool stereo_mode_c::valid_index(int idx) { return (0 <= idx) && (static_cast(s_modes.size()) > idx); } + +void +stereo_mode_c::list() { + auto formatter = mtx::string::table_formatter_c{} + .set_header({ Y("Index"), Y("Symbolic name"), Y("Description") }) + .set_alignment({ mtx::string::table_formatter_c::align_right }); + + for (auto idx = 0u; idx < s_modes.size(); ++idx) + formatter.add_row({ fmt::format("{}", idx), s_modes[idx], translate(idx) }); + + mxinfo(formatter.format()); +} diff --git a/src/common/stereo_mode.h b/src/common/stereo_mode.h index abe27641d..582bfb842 100644 --- a/src/common/stereo_mode.h +++ b/src/common/stereo_mode.h @@ -52,4 +52,5 @@ public: static unsigned int max_index() { return 14; }; + static void list(); }; diff --git a/src/merge/mkvmerge.cpp b/src/merge/mkvmerge.cpp index 2967f1240..308dbf172 100644 --- a/src/merge/mkvmerge.cpp +++ b/src/merge/mkvmerge.cpp @@ -309,7 +309,7 @@ set_usage() { usage_text += Y(" --stereo-mode \n" " Sets the stereo mode parameter. It can\n" " either be a number 0 - 14 or a keyword\n" - " (see documentation for the full list).\n"); + " (use '--list-stereo-modes' to see the full list).\n"); usage_text += Y(" --color-matrix-coefficients \n" " Sets the matrix coefficients of the video used\n" " to derive luma and chroma values from red, green\n" @@ -388,6 +388,8 @@ set_usage() { usage_text += Y(" -l, --list-types Lists supported source file types.\n"); usage_text += Y(" --list-languages Lists all ISO 639 languages and their\n" " ISO 639-2 codes.\n"); + usage_text += Y(" --list-stereo-modes Lists all supported values for the '--stereo-mode'\n" + " parameter and their meaning.\n"); usage_text += Y(" --capabilities Lists optional features mkvmerge was compiled with.\n"); usage_text += Y(" --priority Set the priority mkvmerge runs with.\n"); usage_text += Y(" --ui-language Force the translations for 'code' to be used.\n"); @@ -2194,6 +2196,10 @@ parse_args(std::vector args) { mtx::iso639::list_languages(); mxexit(); + } else if (this_arg == "--list-stereo-modes") { + stereo_mode_c::list(); + mxexit(); + } else if (mtx::included_in(this_arg, "-i", "--identify", "-J")) mxerror(fmt::format(Y("'{0}' can only be used with a file name. No further options are allowed if this option is used.\n"), this_arg));