merge: add option --list-stereo-modes for listing available stereo modes

This commit is contained in:
Moritz Bunkus 2022-09-21 15:59:59 +02:00
parent 9b5d05d924
commit 618dcf1ff2
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
3 changed files with 21 additions and 1 deletions

View File

@ -14,6 +14,7 @@
#include "common/common_pch.h"
#include "common/stereo_mode.h"
#include "common/strings/table_formatter.h"
#include <sstream>
#include <string>
@ -94,3 +95,15 @@ bool
stereo_mode_c::valid_index(int idx) {
return (0 <= idx) && (static_cast<int>(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());
}

View File

@ -52,4 +52,5 @@ public:
static unsigned int max_index() {
return 14;
};
static void list();
};

View File

@ -309,7 +309,7 @@ set_usage() {
usage_text += Y(" --stereo-mode <TID:n|keyword>\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 <TID:n>\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 <priority> Set the priority mkvmerge runs with.\n");
usage_text += Y(" --ui-language <code> Force the translations for 'code' to be used.\n");
@ -2194,6 +2196,10 @@ parse_args(std::vector<std::string> 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));