From 2a76ce4539d32822cf5cb9b7749d047e82658677 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 21 May 2017 18:43:22 +0200 Subject: [PATCH] MPEG TS: make track IDs continuous 0..num_tracks -1 All tracks that weren't probed successfully (and which wouldn't have been reported by the identification) will not be assigned an ID anymore. --- src/input/r_mpeg_ts.cpp | 34 ++++++++++++++++++---------------- tests/results.txt | 4 ++-- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/input/r_mpeg_ts.cpp b/src/input/r_mpeg_ts.cpp index c9dba4b5c..129686688 100644 --- a/src/input/r_mpeg_ts.cpp +++ b/src/input/r_mpeg_ts.cpp @@ -1147,8 +1147,22 @@ reader_c::read_headers() { process_chapter_entries(); + std::vector identified_tracks; + auto track_id = uint64_t{}; for (auto &track : m_tracks) { + // For TrueHD tracks detection for embedded AC-3 frames is + // done. However, "probed_ok" is only set on the TrueHD track if + // both types have been found. If only TrueHD is found then + // "probed_ok" must be set to true after detection has exhausted + // the search space; otherwise a TrueHD-only track would never be + // considered OK. + if (track->codec.is(codec_c::type_e::A_TRUEHD) && track->m_truehd_found_truehd) + track->probed_ok = true; + + if (!track->probed_ok || !track->codec) + continue; + track->clear_pes_payload(); track->processed = false; track->m_id = track_id++; @@ -1158,16 +1172,11 @@ reader_c::read_headers() { if (coupled_track->language.empty()) coupled_track->language = track->language; - // For TrueHD tracks detection for embedded AC-3 frames is - // done. However, "probed_ok" is only set on the TrueHD track if - // both types have been found. If only TrueHD is found then - // "probed_ok" must be set to true after detection has exhausted - // the search space; otherwise a TrueHD-only track would never be - // considered OK. - if (track->codec.is(codec_c::type_e::A_TRUEHD) && track->m_truehd_found_truehd) - track->probed_ok = true; + identified_tracks.push_back(track); } + m_tracks = std::move(identified_tracks); + show_demuxer_info(); } @@ -1280,9 +1289,6 @@ reader_c::identify() { id_result_container(info.get()); for (auto const &track : m_tracks) { - if (!track->probed_ok || !track->codec) - continue; - info = mtx::id::info_c{}; info.add(mtx::id::language, track->language); info.set(mtx::id::ts_pid, track->pid); @@ -2097,11 +2103,7 @@ reader_c::create_packetizers() { void reader_c::add_available_track_ids() { - size_t i; - - for (i = 0; i < m_tracks.size(); i++) - if (m_tracks[i]->probed_ok) - add_available_track_id(i); + add_available_track_id_range(0, m_tracks.size() - 1); } bool diff --git a/tests/results.txt b/tests/results.txt index f37672b03..f2e4a8f6a 100644 --- a/tests/results.txt +++ b/tests/results.txt @@ -144,7 +144,7 @@ T_295vc1_rederiving_frame_types:7d50880b218a57cf07b7ea18939c3a1b-d1531fe33b10d59 T_296video_frames_duration_0:9e7c3434d192c422bd019d4c7d434330:passed:20110709-143914:0.376760947 T_297mpeg_transport_streams:d5c0b1e44d4264a735728989b341766d-df12351168b375975897a0676ea11964:passed:20110913-112636:10.36149529 T_298ts_language:+eng+eng+eng+chi:passed:20110915-221140:0.024501446 -T_299ts_ghost_entries_in_pmt:3_video_MPEG_4p10_AVC_h.264_5500_1440x1080/5_subtitles_SubRip_SRT_eng_5503/6_subtitles_DVBSUB_eng_5504/7_audio_AC_3_E_AC_3_eng_5501_2_48000:passed:20110917-004553:0.032277672 +T_299ts_ghost_entries_in_pmt:0_video_MPEG_4p10_AVC_h.264_5500_1440x1080/1_subtitles_SubRip_SRT_eng_5503/2_subtitles_DVBSUB_eng_5504/3_audio_AC_3_E_AC_3_eng_5501_2_48000:passed:20110917-004553:0.032277672 T_300ts_dts_duplicate_timestamps:ea609b576bd4dc224537572d0c4d9b7c:passed:20110918-154508:1.728558428 T_301ts_pgssub:b68cd888bc9c279fabc9040923feaaae:passed:20110918-154732:1.701870051 T_302pat_pmt_only_once:ebcb0b1f495286585d6217fd5a79bc76:passed:20110927-222121:0.300545156 @@ -343,7 +343,7 @@ T_494dont_abort_with_aac_error_proection_specific_config:4421368e078a52e327fe599 T_495default_durataion_and_sync:66ee6174221a286f9135c3ac03940123-ed8359ff8091f0e2f988a35d413bcb18-f8a8af8f2f72aa8dd939228c15279937:passed:20150417-213623:0.894261521 T_496segment_size_0:9fd6d5e57b47693a483f9aad112a6a15-fb1ff3f0a28e38e500ad86a6f32102f4:passed:20150530-180226:0.051304978 T_497crash_in_base64_decoder:f6526cfaaef01627c52ee2ba25f03255:passed:20150601-192215:0.02848152 -T_498mp2_misidentification:c754793528a9b6fe8562f192c39b86b1-f07114c66f1a298efbfc35b755df721a:passed:20150610-111131:0.763502595 +T_498mp2_misidentification:c754793528a9b6fe8562f192c39b86b1-14c0e2f586a14c4898b36f8c19dad44a:passed:20150610-111131:0.763502595 T_499propedit_tags_and_track_properties:bedbe63bce69a9a25f3fbf559dd6d078:passed:20150621-111029:0.162830224 T_500mp4_eac3_fourcc_ec_3:c8c2e7ac4ec7e97c1c01dcea57741d11:passed:20150621-224248:0.192381554 T_501mpeg_ts_pat_and_pmt_crc_errors:a5160a78ba2706d63ea902307b394576:passed:20150704-110859:0.857051787