diff --git a/ChangeLog b/ChangeLog index 198a459ea..dd5cf4833 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2015-02-02 Moritz Bunkus + * mkvmerge: bug fix: Appending chapters with the same chapter UID + was dropping all sub-chapters from the one of the two merged + chapters. Now the sub-chapters are merged recursively as well. + * mkvmerge: bug fix: The wrong Codec ID was written when reading PCM tracks from Matroska files in Big Endian byte order. Fixes #1113. diff --git a/src/common/chapters/chapters.cpp b/src/common/chapters/chapters.cpp index 3d9c34b12..74a0be08c 100644 --- a/src/common/chapters/chapters.cpp +++ b/src/common/chapters/chapters.cpp @@ -743,6 +743,21 @@ merge_chapter_entries(EbmlMaster &master) { if ((-1 == end_tc) || (merge_end_tc > end_tc)) end_tc = merge_end_tc; + // Move all chapter atoms from the merged entry into the target + // entry so that they will be merged recursively as well. + auto merge_child_idx = 0u; + auto num_children = merge_this->ListSize(); + + while (merge_child_idx < num_children) { + if (Is((*merge_this)[merge_child_idx])) { + atom->PushElement(*(*merge_this)[merge_child_idx]); + merge_this->Remove(merge_child_idx); + --num_children; + + } else + ++merge_child_idx; + } + mxverb(3, boost::format("chapters: merge_entries: found one at %1% with %2%, %3%; merged to %4%, %5%\n") % merge_idx % merge_start_tc % merge_end_tc % start_tc % end_tc); // Finally remove the entry itself. diff --git a/tests/results.txt b/tests/results.txt index a06fafe36..6964004d1 100644 --- a/tests/results.txt +++ b/tests/results.txt @@ -304,3 +304,4 @@ T_455he_aacv2_ps:2fbfac35fa7785f8e500f1708da4ec4f:passed:20150101-152553:0.07596 T_456tta:4b92a305f440778a3128685cefd4bd5d-a3f2a14c15e709027c05445ac91b0659:passed:20150103-140714:0.148697252 T_457mpeg_ts_all_pmts_with_crc_errors:0fefd1b95985d5f5deea17d20e05f6e9:passed:20150104-133628:1.586689715 T_458pcm_big_endian_in_matroska:c83ea37c1a80696b342859467d863f2a:passed:20150202-193826:0.080955865 +T_459append_chapters_same_uid_with_sub_chapters:656362feddd9e89d28df6078361bf9d0:passed:20150202-214722:0.072671062 diff --git a/tests/test-459append_chapters_same_uid_with_sub_chapters.rb b/tests/test-459append_chapters_same_uid_with_sub_chapters.rb new file mode 100755 index 000000000..4a2b243c6 --- /dev/null +++ b/tests/test-459append_chapters_same_uid_with_sub_chapters.rb @@ -0,0 +1,5 @@ +#!/usr/bin/ruby -w + +# T_459append_chapters_same_uid_with_sub_chapters +describe "mkvmerge / append chapters with the same UIDs containing sub-chapters" +test_merge "data/mkv/split-with-sub-chapters-001.mka + data/mkv/split-with-sub-chapters-002.mka"