From 7d5ad09f3e9ae0352cb14e35cdbf37c66f9c5e78 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Thu, 15 Dec 2016 15:09:45 -0800 Subject: sync: don't delay subtitles when duration is known Delayed subtitles were causing incorrect muxing in mkv. The mkv muxer writes chunks where all samples should be relative to a chunk's base timestamp. When the subtitle is delayed long enough for a new chunk to start before it gets muxed, the calculated offset to the chunk's base time is negative (which is illegal). Note that this is still a possibility with subtitles that must be delayed (e.g. CC and VOBSUB) because the duration is not known until the next subtitle's start time is known. The only fix for this would be to add a special subtitle parsing pass that caches subtitle timestamps before the main encoding pass is performed. --- libhb/sync.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'libhb') diff --git a/libhb/sync.c b/libhb/sync.c index 4d2e88a82..154346f48 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -2587,18 +2587,22 @@ static hb_buffer_t * mergeSubtitles(sync_stream_t * stream) if (!sanitizer->merge) { - int limit = sanitizer->link ? 1 : 0; - // Handle all but the last buffer // The last buffer may not have been "linked" yet - while (hb_buffer_list_count(&sanitizer->list_current) > limit) + while (hb_buffer_list_count(&sanitizer->list_current) > 0) { - buf = hb_buffer_list_rem_head(&sanitizer->list_current); - if (!(buf->s.flags & HB_BUF_FLAG_EOF)) + buf = hb_buffer_list_head(&sanitizer->list_current); + if (!(buf->s.flags & HB_BUF_FLAG_EOF) && + buf->s.stop != AV_NOPTS_VALUE) { + buf = hb_buffer_list_rem_head(&sanitizer->list_current); buf = setSubDuration(stream, buf); hb_buffer_list_append(&list, buf); } + else + { + break; + } } return hb_buffer_list_clear(&list); } -- cgit v1.2.3