From f3a01efbe4518168db210fbd3ff9feba32ceb832 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 22 Mar 2007 09:06:14 +0000 Subject: [PATCH] When splitting video and linking is not active then don't use the first I frame\s timecode as the offset for the next file but the highest timecode + duration written to the previous file. Reason: For AVC/h.264 the timecode of the following P frames may be smaller than the first I frame's timecode. --- ChangeLog | 5 +++++ src/merge/cluster_helper.cpp | 10 +++++++++- src/merge/cluster_helper.h | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3ebfc099b..6774200c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-03-22 Moritz Bunkus + + * mkvmerge: bug fix: Fixed an issue with negative/huge timecodes + after splitting AVC/h.264 video. + 2007-03-16 Moritz Bunkus * mkvmerge: enhancement: The SRT reader allows "." as the decimal diff --git a/src/merge/cluster_helper.cpp b/src/merge/cluster_helper.cpp index debb9346e..41ce74b95 100644 --- a/src/merge/cluster_helper.cpp +++ b/src/merge/cluster_helper.cpp @@ -36,6 +36,7 @@ cluster_helper_c::cluster_helper_c(): cluster(NULL), + max_video_timecode_rendered(0), min_timecode_in_cluster(-1), max_timecode_in_cluster(-1), current_split_point(split_points.begin()) { @@ -167,7 +168,8 @@ cluster_helper_c::add_packet(packet_cptr packet) { first_timecode_in_file = -1; if (no_linking) - timecode_offset = packet->assigned_timecode; + timecode_offset = video_packetizer ? max_video_timecode_rendered : + packet->assigned_timecode; if (current_split_point->m_use_once) ++current_split_point; @@ -472,6 +474,12 @@ cluster_helper_c::render() { pack->group = new_block_group; last_block_group = new_block_group; + if (video_packetizer && (video_packetizer == source) && + ((pack->assigned_timecode + pack->duration) > + max_video_timecode_rendered)) + max_video_timecode_rendered = pack->assigned_timecode + + pack->duration; + } if (elements_in_cluster > 0) { diff --git a/src/merge/cluster_helper.h b/src/merge/cluster_helper.h index 62321979f..f683e0da6 100644 --- a/src/merge/cluster_helper.h +++ b/src/merge/cluster_helper.h @@ -61,7 +61,7 @@ private: kax_cluster_c *cluster; vector packets; int cluster_content_size; - int64_t max_timecode_and_duration; + int64_t max_timecode_and_duration, max_video_timecode_rendered; int64_t last_cluster_tc, num_cue_elements, header_overhead; int64_t packet_num, timecode_offset, *last_packets; int64_t bytes_in_file, first_timecode_in_file;