diff options
author | wm4 <wm4@nowhere> | 2019-06-16 16:13:23 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-09-19 20:37:05 +0200 |
commit | 2f64c84b446c389ce3c1afe210dd7b0df388f5ff (patch) | |
tree | 3b0739512ccbe850c647fbae837ef0c0274534f0 /demux/demux.c | |
parent | c13bfd271c416d1c1fd8991f7058c289a40a4ea3 (diff) | |
download | mpv-2f64c84b446c389ce3c1afe210dd7b0df388f5ff.tar.bz2 mpv-2f64c84b446c389ce3c1afe210dd7b0df388f5ff.tar.xz |
demux: remove some redundancy in backward playback code
This code tries to determine the "current" position, which is used as
base for the seek target when it needs to seek back more (the point is
to prevent seeking back too far). But compute_keyframe_times() almost
computes the same thing, so use that. Unfortunately needs a forward
declaration.
("Almost", because it differs in some details that should not really
matter.)
Diffstat (limited to 'demux/demux.c')
-rw-r--r-- | demux/demux.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/demux/demux.c b/demux/demux.c index e09a4e843c..49e75ef48f 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -416,6 +416,9 @@ static void add_packet_locked(struct sh_stream *stream, demux_packet_t *dp); static struct demux_packet *advance_reader_head(struct demux_stream *ds); static bool queue_seek(struct demux_internal *in, double seek_pts, int flags, bool clear_back_state); +static struct demux_packet *compute_keyframe_times(struct demux_packet *pkt, + double *out_kf_min, + double *out_kf_max); static uint64_t get_foward_buffered_bytes(struct demux_stream *ds) { @@ -1444,12 +1447,8 @@ static void find_backward_restart_pos(struct demux_stream *ds) assert(0); // target must be in list } - double seek_pts = MP_NOPTS_VALUE; - for (struct demux_packet *cur = target; cur; cur = cur->next) { - seek_pts = MP_PTS_MIN(seek_pts, cur->pts); - if (cur->next && cur->next->keyframe) - break; - } + double seek_pts; + compute_keyframe_times(target, &seek_pts, NULL); if (seek_pts != MP_NOPTS_VALUE) ds->back_seek_pos = seek_pts; |