From 65d36013dde548e0349ba79ef017cdb2fa8e87a3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 10 Nov 2017 11:06:07 +0100 Subject: demux: fix failure to join ranges with subtitles in some cases Subtitle streams are sparse, and no overlap is required to correctly join two cached ranges. This was not correctly handled iff the two ranges had different subtitle packets close to the join point. --- demux/demux.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'demux/demux.c') diff --git a/demux/demux.c b/demux/demux.c index 32cf09c667..a25bb69b1c 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -905,10 +905,8 @@ static void attempt_range_joining(struct demux_internal *in) goto failed; } - // (Check for ">" too, to avoid incorrect joining in weird - // corner cases, where the next range misses the end packet.) - if ((ds->global_correct_dts && dp->dts >= end->dts) || - (ds->global_correct_pos && dp->pos >= end->pos)) + if ((ds->global_correct_dts && dp->dts == end->dts) || + (ds->global_correct_pos && dp->pos == end->pos)) { // Do some additional checks as a (imperfect) sanity check // in case pos/dts are not "correct" across the ranges (we @@ -925,6 +923,16 @@ static void attempt_range_joining(struct demux_internal *in) break; } + // This happens if the next range misses the end packet. For + // normal streams (ds->eager==true), this is a failure to find + // an overlap. For subtitles, this can mean the current_range + // has a subtitle somewhere before the end of its range, and + // next has another subtitle somewhere after the start of its + // range. + if ((ds->global_correct_dts && dp->dts > end->dts) || + (ds->global_correct_pos && dp->pos > end->pos)) + break; + remove_packet(q2, NULL, dp); } } -- cgit v1.2.3