summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libhb/decsrtsub.c13
-rw-r--r--libhb/sync.c10
2 files changed, 21 insertions, 2 deletions
diff --git a/libhb/decsrtsub.c b/libhb/decsrtsub.c
index e59808a70..202254661 100644
--- a/libhb/decsrtsub.c
+++ b/libhb/decsrtsub.c
@@ -493,7 +493,10 @@ static hb_buffer_t *srt_read( hb_work_private_t *pv )
uint64_t stop_time = ( pv->current_entry.stop +
pv->subtitle->config.offset ) * 90;
- if( !( start_time >= pv->start_time && stop_time < pv->stop_time ) )
+ // Drop subtitles that end before the start time
+ // or start after the stop time
+ if (stop_time <= pv->start_time ||
+ start_time >= pv->stop_time)
{
hb_deep_log( 3, "Discarding SRT at time start %"PRId64", stop %"PRId64, start_time, stop_time);
memset( &pv->current_entry, 0, sizeof( srt_entry_t ) );
@@ -501,6 +504,14 @@ static hb_buffer_t *srt_read( hb_work_private_t *pv )
pv->current_state = k_state_timecode;
continue;
}
+ if (start_time < pv->start_time)
+ {
+ start_time = pv->start_time;
+ }
+ if (stop_time > pv->stop_time)
+ {
+ stop_time = pv->stop_time;
+ }
for (q = p = pv->current_entry.text; *p != '\0'; p++)
{
diff --git a/libhb/sync.c b/libhb/sync.c
index 201bca65b..20663da1d 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -1605,7 +1605,14 @@ static void OutputBuffer( sync_common_t * common )
out_stream->frame_count);
out_stream->frame_count++;
}
- if (buf->s.start < common->start_pts)
+ if (out_stream->type == SYNC_TYPE_SUBTITLE &&
+ buf->s.stop > common->start_pts)
+ {
+ // Subtitle ends after start time, keep sub and
+ // adjust it's start time
+ buf->s.start = common->start_pts;
+ }
+ else if (buf->s.start < common->start_pts)
{
out_stream->next_pts = buf->s.start + buf->s.duration;
hb_list_rem(out_stream->in_queue, buf);
@@ -2133,6 +2140,7 @@ static void QueueBuffer( sync_stream_t * stream, hb_buffer_t * buf )
hb_job_t * job = stream->common->job;
if (job->pts_to_start > 0)
{
+ stream->common->start_pts =
stream->common->pts_to_start =
MAX(0, job->pts_to_start - job->reader_pts_offset);
}