From 5fe2812494f7743f4d662b1f7983d4afa898243f Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 25 Mar 2016 17:40:18 +0100 Subject: sub: force segment switch if video is already ahead In particular, this prevents subtitle packets from building up in the subtitle queue if e.g. --vo=null is used. In this situation, sub_get_bitmaps() is never called, and thus the segment never switched. This also seems to help with flickering at segment switch boundaries (if subs are supposed to be visible at the transition points). In theory, this could trigger a switch too early, but the way VO and subtitle renderer interact wrt. timing is a bit iffy anyway. --- sub/dec_sub.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sub/dec_sub.c') diff --git a/sub/dec_sub.c b/sub/dec_sub.c index b6672348a5..3b1e957038 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -150,6 +150,9 @@ static void update_segment(struct dec_sub *sub) if (sub->new_segment && sub->last_vo_pts != MP_NOPTS_VALUE && sub->last_vo_pts >= sub->new_segment->start) { + MP_VERBOSE(sub, "Switch segment: %f at %f\n", sub->new_segment->start, + sub->last_vo_pts); + sub->codec = sub->new_segment->codec; sub->start = sub->new_segment->start; sub->end = sub->new_segment->end; @@ -210,6 +213,11 @@ bool sub_read_packets(struct dec_sub *sub, double video_pts) if (!read_more) break; + if (sub->new_segment && sub->new_segment->start < video_pts) { + sub->last_vo_pts = video_pts; + update_segment(sub); + } + if (sub->new_segment) break; -- cgit v1.2.3