From 04acfff20f4d716ea8f7ab1c4c7db5940c8dc5d3 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 19 Nov 2014 12:13:51 +0100 Subject: [PATCH] mkvinfo: report picture type based on number of references, not on their value --- ChangeLog | 6 ++++++ src/info/mkvinfo.cpp | 24 ++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac840fdca..872c5b852 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-11-19 Moritz Bunkus + + * mkvinfo: bug fix: summary mode: reported frame types in block + groups are now derived from the number of references found and not + by the references' values. + 2014-11-16 Moritz Bunkus * mkvmerge: bug fix: Fixed muxing open GOPs after I frames in diff --git a/src/info/mkvinfo.cpp b/src/info/mkvinfo.cpp index b613475ca..591c2a6fb 100644 --- a/src/info/mkvinfo.cpp +++ b/src/info/mkvinfo.cpp @@ -1148,9 +1148,7 @@ handle_block_group(EbmlStream *&es, std::vector frame_adlers; std::vector frame_hexdumps; - bool bref_found = false; - bool fref_found = false; - + auto num_references = 0u; int64_t lf_timecode = 0; int64_t lf_tnum = 0; int64_t frame_pos = 0; @@ -1199,17 +1197,15 @@ handle_block_group(EbmlStream *&es, show_element(l3, 3, BF_BLOCK_GROUP_DURATION % (duration * s_tc_scale / 1000000) % (duration * s_tc_scale % 1000000)); } else if (Is(l3)) { + ++num_references; + int64_t reference = static_cast(l3)->GetValue() * s_tc_scale; - if (0 >= reference) { - bref_found = true; - reference *= -1; - show_element(l3, 3, BF_BLOCK_GROUP_REFERENCE_1 % (reference / 1000000) % (reference % 1000000)); + if (0 >= reference) + show_element(l3, 3, BF_BLOCK_GROUP_REFERENCE_1 % (std::abs(reference) / 1000000) % (std::abs(reference) % 1000000)); - } else if (0 < reference) { - fref_found = true; + else if (0 < reference) show_element(l3, 3, BF_BLOCK_GROUP_REFERENCE_2 % (reference / 1000000) % (reference % 1000000)); - } } else if (Is(l3)) show_element(l3, 3, BF_BLOCK_GROUP_REFERENCE_PRIORITY % static_cast(l3)->GetValue()); @@ -1294,7 +1290,7 @@ handle_block_group(EbmlStream *&es, if (bduration != -1.0) mxinfo(BF_BLOCK_GROUP_SUMMARY_WITH_DURATION - % (bref_found && fref_found ? 'B' : bref_found ? 'P' : !fref_found ? 'I' : 'P') + % (num_references >= 2 ? 'B' : num_references == 1 ? 'P' : 'I') % lf_tnum % (lf_timecode / 1000000) % format_timecode(lf_timecode, 3) @@ -1305,7 +1301,7 @@ handle_block_group(EbmlStream *&es, % position); else mxinfo(BF_BLOCK_GROUP_SUMMARY_NO_DURATION - % (bref_found && fref_found ? 'B' : bref_found ? 'P' : !fref_found ? 'I' : 'P') + % (num_references >= 2 ? 'B' : num_references == 1 ? 'P' : 'I') % lf_tnum % (lf_timecode / 1000000) % format_timecode(lf_timecode, 3) @@ -1318,14 +1314,14 @@ handle_block_group(EbmlStream *&es, } else if (g_options.m_verbose > 2) show_element(nullptr, 2, BF_BLOCK_GROUP_SUMMARY_V2 - % (bref_found && fref_found ? 'B' : bref_found ? 'P' : !fref_found ? 'I' : 'P') + % (num_references >= 2 ? 'B' : num_references == 1 ? 'P' : 'I') % lf_tnum % (lf_timecode / 1000000)); track_info_t &tinfo = s_track_info[lf_tnum]; tinfo.m_blocks += frame_sizes.size(); - tinfo.m_blocks_by_ref_num[bref_found && fref_found ? 2 : bref_found ? 1 : !fref_found ? 0 : 1] += frame_sizes.size(); + tinfo.m_blocks_by_ref_num[std::min(num_references, 2u)] += frame_sizes.size(); tinfo.m_min_timecode = std::min(tinfo.m_min_timecode, lf_timecode); tinfo.m_size += boost::accumulate(frame_sizes, 0);