From 6ee9d4f1f4b0f5a33741786f5f0b95dbd0464a5b Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 4 Sep 2022 15:36:15 +0200 Subject: [PATCH] Ogg/OGM reader: fix skipping unsupported tracks & those missing header pages Fixes #3394. --- NEWS.md | 9 +++++++++ src/input/r_ogm.cpp | 7 +++++-- tests/results.txt | 1 + ...est-0746ogg_unknown_track_and_kate_missing_headers.rb | 6 ++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100755 tests/test-0746ogg_unknown_track_and_kate_missing_headers.rb diff --git a/NEWS.md b/NEWS.md index 8bb9dab80..7a362e92b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,12 @@ +# Version ? + +## Bug fixes + +* mkvmerge: Ogg/OGM reader: mkvmerge will now correctly skip tracks of + unsupported types as well as tracks for which all track header pages + haven't been found. Fixes #3394. + + # Version 70.0.0 "Caught A Lite Sneeze" 2022-08-14 ## New features and enhancements diff --git a/src/input/r_ogm.cpp b/src/input/r_ogm.cpp index 48b7977db..d7bb5a419 100644 --- a/src/input/r_ogm.cpp +++ b/src/input/r_ogm.cpp @@ -600,10 +600,11 @@ ogm_reader_c::read_headers_internal() { ogg_page og; bool done = false; + while (!done) { // Make sure we have a page that we can work with. if (read_page(&og) == FILE_STATUS_DONE) - return 0; + break; // Is this the first page of a new stream? if (ogg_page_bos(&og)) @@ -629,7 +630,9 @@ ogm_reader_c::read_headers_internal() { ogg_sync_clear(&oy); ogg_sync_init(&oy); - return 1; + sdemuxers.erase(std::remove_if(sdemuxers.begin(), sdemuxers.end(), [](auto const &dmx) { return !dmx->headers_read; }), sdemuxers.end()); + + return bos_pages_read ? 1 : 0; } /* diff --git a/tests/results.txt b/tests/results.txt index 780e340fd..2afce2383 100644 --- a/tests/results.txt +++ b/tests/results.txt @@ -590,3 +590,4 @@ T_0742keep_color_properties:f99978ce621faace934d2eee7c5f847e-ea5af7e794ef2fed2fb T_0743propedit_video_color_attributes_old_names:7041e2720c1c107e8c507b5d647edb4f+66aedfb541c058fffb0403d1681fe1a3+9a6d5a33c6d53e14ad860122a972747c+c9aa4c93f4e6b027970462a9de687c04-4f96c2b3c3aabd53c5c67267abe20deb+82b4ae1a511f00db3ed26f43f1b64858+b5560878b38c77266ceffd0a4f0e6d4d+553b9d004d0ba4838acd5a6cbc883994:passed:20220709-111335:0.656156337 T_0744hevc_first_unspec_nalus_after_one_mb_of_data:90a41a6db1951cf44d540bae5833751d:passed:20220709-115511:0.27140422 T_0745av1_single_frame:d9418a3f3976542657b3fbc6f6ad002e:passed:20220730-122150:0.044258962 +T_0746ogg_unknown_track_and_kate_missing_headers:ce39d6bfa056cae15b82e822bcbf7bbf:passed:20220904-153425:0.031062254 diff --git a/tests/test-0746ogg_unknown_track_and_kate_missing_headers.rb b/tests/test-0746ogg_unknown_track_and_kate_missing_headers.rb new file mode 100755 index 000000000..5f0539d2b --- /dev/null +++ b/tests/test-0746ogg_unknown_track_and_kate_missing_headers.rb @@ -0,0 +1,6 @@ +#!/usr/bin/ruby -w + +# T_746ogg_unknown_track_and_kate_missing_headers +describe "mkvmerge / Ogg: stream of unknown/unsupported type and a Kate stream missing its headers" + +test_merge "data/ogg/unknown_stream_and_kate_without_headers.ogv"