diff options
author | John Stebbins <[email protected]> | 2016-02-10 12:02:44 -0700 |
---|---|---|
committer | John Stebbins <[email protected]> | 2016-02-10 12:02:44 -0700 |
commit | c8ed04fe005ac461570a745f69b5be8fd5ebbbd8 (patch) | |
tree | 3157edb9b68613243bf52d3f94a66f0b0c60b03a /libhb/sync.c | |
parent | 0c2c727d6791f4e3ce3190c2e3dae5075a68b5a3 (diff) |
sync: fix subtitle timestamps that go backwards
This should be really difficult to trigger, but someone found a sample
that does.
Diffstat (limited to 'libhb/sync.c')
-rw-r--r-- | libhb/sync.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/libhb/sync.c b/libhb/sync.c index dd8c54adc..282c18bbd 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -736,9 +736,18 @@ static void streamFlush( sync_stream_t * stream ) { buf->s.start = stream->next_pts; buf->s.stop = stream->next_pts + buf->s.duration; + stream->next_pts += buf->s.duration; + } + else + { + // Last ditch effort to prevent timestamps from going backwards + // This can (and should only) affect subtitle streams. + if (buf->s.start < stream->next_pts) + { + buf->s.start = stream->next_pts; + } + stream->next_pts = buf->s.start; } - - stream->next_pts += buf->s.duration; if (buf->s.stop > 0) { @@ -967,9 +976,19 @@ static void OutputBuffer( sync_common_t * common ) { buf->s.start = out_stream->next_pts; buf->s.stop = out_stream->next_pts + buf->s.duration; + out_stream->next_pts += buf->s.duration; + } + else + { + // Last ditch effort to prevent timestamps from going backwards + // This can (and should only) affect subtitle streams. + if (buf->s.start < out_stream->next_pts) + { + buf->s.start = out_stream->next_pts; + } + out_stream->next_pts = buf->s.start; } - out_stream->next_pts += buf->s.duration; if (buf->s.stop > 0) { |