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.
This commit is contained in:
wm4 2017-11-10 11:06:07 +01:00
parent 4681b4b28b
commit 65d36013dd
1 changed files with 12 additions and 4 deletions

View File

@ -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);
}
}