From feb1a3be5407297c3be3c19a62f75170305a32f0 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 9 Sep 2005 08:28:22 +0000 Subject: [PATCH] Some ASS files use a column "Actor" instead of "Name". This should be mapped to "Name" in Matroska as well. --- ChangeLog | 6 ++++++ src/extract/xtr_textsubs.cpp | 4 +++- src/input/r_ssa.cpp | 14 +++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 97a00acc3..1bc57cff2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-09-09 Moritz Bunkus + + * mkvmerge, mkvextract: bug fix: ASS files sometimes use a column + called 'Actor' instead of 'Name', but both should be mapped to the + 'name' column in a Matroska file. + 2005-09-07 Moritz Bunkus * Released v1.5.6. diff --git a/src/extract/xtr_textsubs.cpp b/src/extract/xtr_textsubs.cpp index 0ddb4a279..6ffd552f1 100644 --- a/src/extract/xtr_textsubs.cpp +++ b/src/extract/xtr_textsubs.cpp @@ -235,8 +235,10 @@ xtr_ssa_c::handle_block(KaxBlock &block, line = "Dialogue: "; for (i = 0; i < ssa_format.size(); i++) { - string &format = ssa_format[i]; + string format = ssa_format[i]; + if (downcase(format) == "actor") + format = "name"; if (0 < i) line += ","; if (format == "marked") diff --git a/src/input/r_ssa.cpp b/src/input/r_ssa.cpp index 931d90835..ddad74893 100644 --- a/src/input/r_ssa.cpp +++ b/src/input/r_ssa.cpp @@ -155,9 +155,9 @@ ssa_reader_c::recode_text(vector &fields) { void ssa_reader_c::parse_file(mm_text_io_c *io) { - string line, stime, orig_line, comma; + string line, stime, orig_line, comma, name_field; string attachment_name, attachment_data_uu; - int num; + int num, i; int64_t start, end; vector fields; ssa_section_e section, previous_section; @@ -168,6 +168,7 @@ ssa_reader_c::parse_file(mm_text_io_c *io) { section = SSA_SECTION_NONE; previous_section = SSA_SECTION_NONE; ti.id = 0; // ID for this track. + name_field = "Name"; while (!io->eof()) { if (!io->getline2(line)) break; @@ -205,6 +206,13 @@ ssa_reader_c::parse_file(mm_text_io_c *io) { m_format = split(&line.c_str()[strlen("Format: ")]); strip(m_format); + // Let's see if "Actor" is used in the format instead of "Name". + for (i = 0; m_format.size() > i; ++i) + if (downcase(m_format[i]) == "actor") { + name_field = "Actor"; + break; + } + } else if (starts_with_case(line, "Dialogue: ")) { if (m_format.size() == 0) throw error_c("ssa_reader: Invalid format. Could not find the " @@ -245,7 +253,7 @@ ssa_reader_c::parse_file(mm_text_io_c *io) { comma = ","; line = to_string(num) + comma + get_element("Layer", fields) + comma + get_element("Style", fields) + comma + - get_element("Name", fields) + comma + + get_element(name_field.c_str(), fields) + comma + get_element("MarginL", fields) + comma + get_element("MarginR", fields) + comma + get_element("MarginV", fields) + comma +