diff options
author | John Stebbins <[email protected]> | 2016-12-15 15:09:45 -0800 |
---|---|---|
committer | John Stebbins <[email protected]> | 2016-12-15 15:18:55 -0800 |
commit | 7d5ad09f3e9ae0352cb14e35cdbf37c66f9c5e78 (patch) | |
tree | 71e65263d201e350ad3b4d2653db464a2011b7c5 /libhb/sync.c | |
parent | 7e8119993caafec4cfa8aa5805bf5b23c6ce0195 (diff) |
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.
Diffstat (limited to 'libhb/sync.c')
-rw-r--r-- | libhb/sync.c | 14 |
1 files changed, 9 insertions, 5 deletions
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); } |