mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-10-22 07:21:21 +00:00
chapters: move name generation template from cluster helper to global variable
The cluster helper is only available in mkvmerge, but the template will be required in other tools, too.
This commit is contained in:
parent
5fb54c5710
commit
eef32f6f02
@ -43,6 +43,8 @@ std::string g_default_language;
|
||||
/** The default country for all chapter entries that don't have their own. */
|
||||
std::string g_default_country;
|
||||
|
||||
translatable_string_c g_chapter_generation_name_template{YT("Chapter <NUM:2>")};
|
||||
|
||||
#define SIMCHAP_RE_TIMESTAMP_LINE "^\\s*CHAPTER\\d+\\s*=\\s*(\\d+)\\s*:\\s*(\\d+)\\s*:\\s*(\\d+)\\s*[\\.,]\\s*(\\d+)"
|
||||
#define SIMCHAP_RE_TIMESTAMP "^\\s*CHAPTER\\d+\\s*=(.*)"
|
||||
#define SIMCHAP_RE_NAME_LINE "^\\s*CHAPTER\\d+NAME\\s*=(.*)"
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <ebml/EbmlElement.h>
|
||||
|
||||
#include "common/timestamp.h"
|
||||
#include "common/translation.h"
|
||||
|
||||
namespace libebml {
|
||||
class EbmlMaster;
|
||||
@ -64,6 +65,7 @@ bool probe_simple(mm_text_io_c *in);
|
||||
mtx::chapters::kax_cptr parse_simple(mm_text_io_c *in, int64_t min_ts, int64_t max_ts, int64_t offset, const std::string &language, const std::string &charset);
|
||||
|
||||
extern std::string g_cue_name_format, g_default_language, g_default_country;
|
||||
extern translatable_string_c g_chapter_generation_name_template;
|
||||
|
||||
bool probe_cue(mm_text_io_c *in);
|
||||
mtx::chapters::kax_cptr parse_cue(mm_text_io_c *in, int64_t min_ts, int64_t max_ts, int64_t offset, const std::string &language, const std::string &charset, std::unique_ptr<libmatroska::KaxTags> *tags = nullptr);
|
||||
|
@ -1284,7 +1284,7 @@ reader_c::process_chapter_entries() {
|
||||
std::stable_sort(m_chapter_timestamps.begin(), m_chapter_timestamps.end());
|
||||
|
||||
m_chapters.reset(new libmatroska::KaxChapters);
|
||||
auto name_template = g_cluster_helper->get_chapter_generation_name_template();
|
||||
auto name_template = mtx::chapters::g_chapter_generation_name_template.get_translated();
|
||||
auto chapter_number = 0;
|
||||
auto &edition = GetChild<libmatroska::KaxEditionEntry>(*m_chapters);
|
||||
auto language = !m_ti.m_chapter_language.empty() ? m_ti.m_chapter_language
|
||||
|
@ -729,17 +729,6 @@ cluster_helper_c::set_chapter_generation_interval(timestamp_c const &interval) {
|
||||
m->chapter_generation_interval = interval;
|
||||
}
|
||||
|
||||
void
|
||||
cluster_helper_c::set_chapter_generation_name_template(std::string const &name_template) {
|
||||
m->chapter_generation_name_template.override(name_template);
|
||||
}
|
||||
|
||||
std::string
|
||||
cluster_helper_c::get_chapter_generation_name_template()
|
||||
const {
|
||||
return m->chapter_generation_name_template.get_translated();
|
||||
}
|
||||
|
||||
void
|
||||
cluster_helper_c::verify_and_report_chapter_generation_parameters()
|
||||
const {
|
||||
@ -820,7 +809,7 @@ cluster_helper_c::generate_one_chapter(timestamp_c const ×tamp) {
|
||||
auto appended_file_name = chapter_generation_mode_e::when_appending == m->chapter_generation_mode ? m->chapter_generation_reference_track->m_reader->m_ti.m_fname : std::string{};
|
||||
m->chapter_generation_number += 1;
|
||||
m->chapter_generation_last_generated = timestamp;
|
||||
auto name = mtx::chapters::format_name_template(m->chapter_generation_name_template.get_translated(), m->chapter_generation_number, timestamp, appended_file_name);
|
||||
auto name = mtx::chapters::format_name_template(mtx::chapters::g_chapter_generation_name_template.get_translated(), m->chapter_generation_number, timestamp, appended_file_name);
|
||||
|
||||
add_chapter_atom(timestamp, name, m->chapter_generation_language);
|
||||
}
|
||||
|
@ -81,8 +81,6 @@ public:
|
||||
void enable_chapter_generation(chapter_generation_mode_e mode, std::string const &language = "");
|
||||
chapter_generation_mode_e get_chapter_generation_mode() const;
|
||||
void set_chapter_generation_interval(timestamp_c const &interval);
|
||||
void set_chapter_generation_name_template(std::string const &name_template);
|
||||
std::string get_chapter_generation_name_template() const;
|
||||
void verify_and_report_chapter_generation_parameters() const;
|
||||
|
||||
private:
|
||||
|
@ -2287,6 +2287,13 @@ parse_args(std::vector<std::string> args) {
|
||||
g_outfile = next_arg;
|
||||
sit++;
|
||||
|
||||
} else if (this_arg == "--generate-chapters-name-template") {
|
||||
if (no_next_arg)
|
||||
mxerror(Y("'--generate-chapters-name-template' lacks the name template.\n"));
|
||||
|
||||
mtx::chapters::g_chapter_generation_name_template.override(next_arg);
|
||||
sit++;
|
||||
|
||||
} else if ((this_arg == "-w") || (this_arg == "--webm"))
|
||||
set_output_compatibility(OC_WEBM);
|
||||
}
|
||||
@ -2313,10 +2320,7 @@ parse_args(std::vector<std::string> args) {
|
||||
auto next_arg = !no_next_arg ? *sit_next : "";
|
||||
|
||||
// Ignore the options we took care of in the first step.
|
||||
if ( (this_arg == "-o")
|
||||
|| (this_arg == "--output")
|
||||
|| (this_arg == "--command-line-charset")
|
||||
|| (this_arg == "--engage")) {
|
||||
if (mtx::included_in(this_arg, "-o", "--output", "--command-line-charset", "--engage", "--generate-chapters-name-template")) {
|
||||
sit++;
|
||||
continue;
|
||||
}
|
||||
@ -2507,13 +2511,6 @@ parse_args(std::vector<std::string> args) {
|
||||
parse_arg_generate_chapters(next_arg);
|
||||
sit++;
|
||||
|
||||
} else if (this_arg == "--generate-chapters-name-template") {
|
||||
if (no_next_arg)
|
||||
mxerror(Y("'--generate-chapters-name-template' lacks the name template.\n"));
|
||||
|
||||
g_cluster_helper->set_chapter_generation_name_template(next_arg);
|
||||
sit++;
|
||||
|
||||
} else if (this_arg == "--segmentinfo") {
|
||||
if (no_next_arg)
|
||||
mxerror(Y("'--segmentinfo' lacks the file name.\n"));
|
||||
|
@ -70,7 +70,6 @@ public:
|
||||
bool discarding{}, splitting_and_processed_fully{};
|
||||
|
||||
chapter_generation_mode_e chapter_generation_mode{chapter_generation_mode_e::none};
|
||||
translatable_string_c chapter_generation_name_template{YT("Chapter <NUM:2>")};
|
||||
timestamp_c chapter_generation_interval, chapter_generation_last_generated;
|
||||
generic_packetizer_c *chapter_generation_reference_track{};
|
||||
unsigned int chapter_generation_number{};
|
||||
|
Loading…
Reference in New Issue
Block a user