From e199b01d2c043f0c2649d6932f9c7eb0b6df4342 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 26 Oct 2003 17:49:29 +0000 Subject: [PATCH] Automatically add missing/defaulted mandatory elements to the XML output when extracting chapters. --- ChangeLog | 10 ++++++++++ src/chapter_writer.cpp | 19 ++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a3e4f7c3..47b070378 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-10-26 Moritz Bunkus + + * mkvextract: bug fix: Add all the mandatory elements when + extracting chapters so that the resulting XML can always be used + directly with mkvmerge again without having to manually add + e.g. ChapterLanguage. + + * mkvmerge: bug fix; Handle audio tracks from Matroska files with + the CodecID A_MS/ACM correctly. + 2003-10-25 Moritz Bunkus * mkvmerge: Changes to use libmatroska's new lacing code. diff --git a/src/chapter_writer.cpp b/src/chapter_writer.cpp index c2510d1d7..24a13b25a 100644 --- a/src/chapter_writer.cpp +++ b/src/chapter_writer.cpp @@ -196,9 +196,6 @@ void write_chapters_simple(int &chapter_num, KaxChapters *chapters, // {{{ XML chapter output -#define is_id(ref) (e->Generic().GlobalId == ref::ClassInfos.GlobalId) -#define is_id2(e, ref) (e->Generic().GlobalId == ref::ClassInfos.GlobalId) - static FILE *o; static void pt(int level, const char *tag) { @@ -215,9 +212,12 @@ static void write_chapter_display_xml(KaxChapterDisplay *display, int level) { int i; EbmlElement *e; char *s; + bool string_found, language_found; pt(level, "\n"); + language_found = false; + string_found = false; for (i = 0; i < display->ListSize(); i++) { e = (*display)[i]; if (is_id(KaxChapterString)) { @@ -226,11 +226,13 @@ static void write_chapter_display_xml(KaxChapterDisplay *display, int level) { (e)).c_str()); mxprint(o, "%s\n", s); safefree(s); + string_found = true; } else if (is_id(KaxChapterLanguage)) { pt(level + 1, ""); mxprint(o, "%s\n", string(*static_cast (e)).c_str()); + language_found = true; } else if (is_id(KaxChapterCountry)) { @@ -244,6 +246,11 @@ static void write_chapter_display_xml(KaxChapterDisplay *display, int level) { } + if (!string_found) + pt(level + 1, "\n"); + if (!language_found) + pt(level + 1, "eng\n"); + pt(level, "\n"); } @@ -272,9 +279,11 @@ static void write_chapter_atom_xml(KaxChapterAtom *atom, int level) { int i; EbmlElement *e; uint64_t v; + bool start_time_found; pt(level, "\n"); + start_time_found = false; for (i = 0; i < atom->ListSize(); i++) { e = (*atom)[i]; if (is_id(KaxChapterUID)) { @@ -288,6 +297,7 @@ static void write_chapter_atom_xml(KaxChapterAtom *atom, int level) { mxprint(o, "%02llu:%02llu:%02llu.%03llu\n", v / 1000 / 60 / 60, (v / 1000 / 60) % 60, (v / 1000) % 60, v % 1000); + start_time_found = true; } else if (is_id(KaxChapterTimeEnd)) { pt(level + 1, ""); @@ -307,6 +317,9 @@ static void write_chapter_atom_xml(KaxChapterAtom *atom, int level) { } + if (!start_time_found) + pt(level + 1, "00:00:00.000\n"); + pt(level, "\n"); }