diff options
author | wm4 <wm4@nowhere> | 2016-11-09 16:34:45 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-11-09 16:44:06 +0100 |
commit | a55e8ff31cc974843e28282ccbdc46dd3e70a5af (patch) | |
tree | 5a31cf271ac92129da6daff35302ac93746f4890 | |
parent | b787a4121ad50f0e069863b96fda7d950175114e (diff) | |
download | mpv-a55e8ff31cc974843e28282ccbdc46dd3e70a5af.tar.bz2 mpv-a55e8ff31cc974843e28282ccbdc46dd3e70a5af.tar.xz |
dec_sub: avoid full reinit on switches to the same segment
The previous commit means subtitles were reinitialized on every seek
(even within a segment). This commit restores the old behavior.
To check whether the segment changed at all, we don't reset the current
start/end values. This assumes the decoder wrapper is always fed by a
stream which doesn't mix segment and non-segment packets, which is
currently always true.
-rw-r--r-- | sub/dec_sub.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sub/dec_sub.c b/sub/dec_sub.c index 39eb032982..b9f04b3123 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -198,6 +198,12 @@ void sub_preload(struct dec_sub *sub) pthread_mutex_unlock(&sub->lock); } +static bool is_new_segment(struct dec_sub *sub, struct demux_packet *p) +{ + return p->new_segment && + (p->start != sub->start || p->end != sub->end || p->codec != sub->codec); +} + // Read packets from the demuxer stream passed to sub_create(). Return true if // enough packets were read, false if the player should wait until the demuxer // signals new packets available (and then should retry). @@ -236,7 +242,7 @@ bool sub_read_packets(struct dec_sub *sub, double video_pts) sub->last_pkt_pts = pkt->pts; - if (pkt->new_segment) { + if (is_new_segment(sub, pkt)) { sub->new_segment = pkt; // Note that this can be delayed to a much later point in time. update_segment(sub); @@ -294,7 +300,6 @@ void sub_reset(struct dec_sub *sub) if (sub->sd->driver->reset) sub->sd->driver->reset(sub->sd); sub->last_pkt_pts = MP_NOPTS_VALUE; - sub->start = sub->end = MP_NOPTS_VALUE; sub->last_vo_pts = MP_NOPTS_VALUE; talloc_free(sub->new_segment); sub->new_segment = NULL; |