From d29a4552faba5601a3994948b7c1464fa5d836bc Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 28 Sep 2004 18:25:43 +0000 Subject: [PATCH] Merged 2233 --- ChangeLog | 3 ++ src/extract/tracks.cpp | 73 +++++++++++++++++++++++++++++------------- src/input/r_ssa.cpp | 10 ++---- 3 files changed, 56 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 493cc0e9f..a3b48e6ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2004-09-28 Moritz Bunkus + * mkvmerge, mkvextract: bug fix: ASS was handled like SSA which is + not correct in each case, especially when extracting it. + * mkvextract: bug fix: The WAV writer was not endian safe. 2004-09-27 Moritz Bunkus diff --git a/src/extract/tracks.cpp b/src/extract/tracks.cpp index efd6f69e2..67a1a961f 100644 --- a/src/extract/tracks.cpp +++ b/src/extract/tracks.cpp @@ -534,7 +534,7 @@ create_output_files() { tracks[i].out->write_bom(tracks[i].sub_charset); } else if (tracks[i].type == TYPESSA) { - char *s; + char *s, *p1; unsigned char *pd; int bom_len; string sconv; @@ -568,8 +568,19 @@ create_output_files() { sconv = s; safefree(s); tracks[i].out->write_bom(tracks[i].sub_charset); - sconv += "\n[Events]\nFormat: Marked, Start, End, " - "Style, Name, MarginL, MarginR, MarginV, Effect, Text\n"; + + if (((p1 = strstr(sconv.c_str(), "[Events]")) == NULL) || + (strstr(p1, "Format:") == NULL)) { + if (!strcmp(tracks[i].codec_id, MKV_S_TEXTSSA)) + sconv += "\n[Events]\nFormat: Marked, Start, End, " + "Style, Name, MarginL, MarginR, MarginV, Effect, Text\n"; + else + sconv += "\n[Events]\nFormat: Layer, Start, End, " + "Style, Actor, MarginL, MarginR, MarginV, Effect, Text\n"; + } else if ((sconv.length() == 0) || + (sconv[sconv.length()- 1] != '\n')) + sconv += "\n"; + from_utf8(tracks[i].conv_handle, sconv); tracks[i].out->puts_unl(sconv.c_str()); @@ -764,30 +775,46 @@ handle_data(KaxBlock *block, // Reconstruct the 'original' line. It'll look like this for SSA: // Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, // Text + // and for ASS: + // Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, + // Text - line = string("Dialogue: Marked=0,"); + if (!strcmp(track->codec_id, MKV_S_TEXTSSA)) + line = string("Dialogue: Marked=0,") + + // Append the start and end time. + mxsprintf("%lld:%02lld:%02lld.%02lld", + start / 1000 / 60 / 60, (start / 1000 / 60) % 60, + (start / 1000) % 60, (start % 1000) / 10) + comma + + mxsprintf("%lld:%02lld:%02lld.%02lld", + end / 1000 / 60 / 60, (end / 1000 / 60) % 60, + (end / 1000) % 60, (end % 1000) / 10) + comma + + // Append the other fields. + fields[2] + comma + // Style + fields[3] + comma + // Name + fields[4] + comma + // MarginL + fields[5] + comma + // MarginR + fields[6] + comma + // MarginV + fields[7] + comma + // Effect + fields[8] + string("\n"); // Text - // Append the start and end time. - mxprints(buffer, "%lld:%02lld:%02lld.%02lld", - start / 1000 / 60 / 60, (start / 1000 / 60) % 60, - (start / 1000) % 60, (start % 1000) / 10); - line += string(buffer) + comma; - - mxprints(buffer, "%lld:%02lld:%02lld.%02lld", - end / 1000 / 60 / 60, (end / 1000 / 60) % 60, - (end / 1000) % 60, (end % 1000) / 10); - line += string(buffer) + comma; - - // Append the other fields. - line += fields[2] + comma + // Style - fields[3] + comma + // Name - fields[4] + comma + // MarginL - fields[5] + comma + // MarginR - fields[6] + comma + // MarginV - fields[7] + comma; // Effect + else + line = string("Dialogue: ") + + fields[1] + comma + // Layer + mxsprintf("%lld:%02lld:%02lld.%02lld", + start / 1000 / 60 / 60, (start / 1000 / 60) % 60, + (start / 1000) % 60, (start % 1000) / 10) + comma + + mxsprintf("%lld:%02lld:%02lld.%02lld", + end / 1000 / 60 / 60, (end / 1000 / 60) % 60, + (end / 1000) % 60, (end % 1000) / 10) + comma + + fields[2] + comma + // Style + comma + // Actor + fields[4] + comma + // MarginL + fields[5] + comma + // MarginR + fields[6] + comma + // MarginV + fields[7] + comma + // Effect + fields[8] + string("\n"); // Text // Do the charset conversion. - line += fields[8] + "\n"; from_utf8(track->conv_handle, line); // Now store that entry. diff --git a/src/input/r_ssa.cpp b/src/input/r_ssa.cpp index b2786ff90..c51030251 100644 --- a/src/input/r_ssa.cpp +++ b/src/input/r_ssa.cpp @@ -120,12 +120,8 @@ ssa_reader_c::ssa_reader_c(track_info_c *nti) strip(format); } - // Now just append the current line and some DOS style newlines. - // But not if we've already encountered the [Events] section. - if (section != 'e') { - global += "\r\n"; - global += line; - } + global += "\r\n"; + global += line; } if (format.size() == 0) @@ -232,7 +228,7 @@ ssa_reader_c::read(generic_packetizer_c *, vector fields; ssa_line_c cline; - num = 1; + num = 0; do { line = mm_io->getline();