summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-11-10 11:06:07 +0100
committerwm4 <wm4@nowhere>2017-11-10 11:06:07 +0100
commit65d36013dde548e0349ba79ef017cdb2fa8e87a3 (patch)
tree5d5a11e8c03088dafc5ab5c8bc2995f16573e547 /demux
parent4681b4b28b4d0aaab65c203d83fdf23470fd4717 (diff)
downloadmpv-65d36013dde548e0349ba79ef017cdb2fa8e87a3.tar.bz2
mpv-65d36013dde548e0349ba79ef017cdb2fa8e87a3.tar.xz
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.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c16
1 files changed, 12 insertions, 4 deletions
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);
}
}