0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
mpv/demux
wm4 4f7684463f demux: redo backstep seek handling slightly again
Backstepping still could get "stuck" if the demuxer didn't seek far back
enough. This commit fixes getting stuck if playing backwards from the
end, and audio has ended much earlier than the video.

In commit "demux: fix initial backward demuxing state in some cases",
I claimed that the backward seek semantics ("snapping" backward in
normal seeking, unrelated to backward playing) would take care of
this. Unfortunately, this is not always quite true.

In theory, a seek to any position (that does not use SEEK_FORWARD, i.e.
backward snapping) should return a packet for every stream. But I have a
mkv sample, where audio ends much earlier than video. Its mkvmerge
created index does not have entries for audio packets, so the video
index is used. This index has its last entry somewhere close after the
end of audio. So no audio packets will be returned. With a "too small"
back_seek_size, the demuxer will retry a seek target that ends up in
this place forever. (This does not happen if you use --index=recreate.
It also doesn't happen with libavformat, which always prefers its own
index, while mpv's internal mkv demuxer strictly prefers the index from
the file if it can be read.)

Fix this by adding the back_seek_size every time we fail to see enough
packets. This way the seek step can add up until it works.

To prevent that back_seek_pos just "runs away" towards negative infinity
by subtracting back_seek_size every time we back step to undo forward
reading (e.g. if --no-cache is used), readjust the back_seek_pos to the
lowest known resume position. (If the cache is active, kf_seek_pts can
be used, but to work in all situations, the code needs to grab the
minimum PTS in the keyframe range.)
2019-09-19 20:37:04 +02:00
..
codec_tags.c codec_tags: fix wrong buffer size 2019-07-03 17:47:24 +03:00
codec_tags.h Relicense some non-MPlayer source files to LGPL 2.1 or later 2016-01-19 18:36:06 +01:00
cue.c demux: support cue sheets longer than 100 minutes 2019-04-01 23:39:08 +02:00
cue.h Relicense some non-MPlayer source files to LGPL 2.1 or later 2016-01-19 18:36:06 +01:00
demux_cue.c demux_edl, cue, mkv: slightly nicer file format indication 2019-09-19 20:37:04 +02:00
demux_edl.c demux_edl: fix assertion failure on exit in obscure ytdl cases 2019-09-19 20:37:04 +02:00
demux_lavf.c demux_lavf: also fix cache seeking with large codec delay 2019-09-19 20:37:04 +02:00
demux_libarchive.c demux: change hack for closing subtitle files early 2019-09-19 20:37:04 +02:00
demux_mf.c demux: return packets directly from demuxer instead of using sh_stream 2019-09-19 20:37:04 +02:00
demux_mkv_timeline.c demux_edl, cue, mkv: slightly nicer file format indication 2019-09-19 20:37:04 +02:00
demux_mkv.c demux, demux_mkv: fix seeking in cache with large codec delay 2019-09-19 20:37:04 +02:00
demux_null.c demux_null: mark as seekable 2018-01-06 14:42:22 -08:00
demux_playlist.c demux: change hack for closing subtitle files early 2019-09-19 20:37:04 +02:00
demux_raw.c demux_raw: fix operation with demuxer cache and backward playback 2019-09-19 20:37:04 +02:00
demux_timeline.c demux_timeline: add heuristic to fix shifted seeks with separate audio 2019-09-19 20:37:04 +02:00
demux.c demux: redo backstep seek handling slightly again 2019-09-19 20:37:04 +02:00
demux.h Implement backwards playback 2019-09-19 20:37:04 +02:00
ebml.c demux_mkv: adjust log verbosity levels 2018-04-29 02:21:32 +03:00
ebml.h demux_mkv: rewrite packet reading to avoid 1 memcpy() 2017-11-05 18:13:34 +01:00
matroska.h ebml, matroska.h: change license to LGPL 2017-04-21 13:34:10 +02:00
packet.c Implement backwards playback 2019-09-19 20:37:04 +02:00
packet.h Implement backwards playback 2019-09-19 20:37:04 +02:00
stheader.h demux, demux_mkv: fix seeking in cache with large codec delay 2019-09-19 20:37:04 +02:00
timeline.c demux_edl, cue, mkv: slightly nicer file format indication 2019-09-19 20:37:04 +02:00
timeline.h demux_edl, cue, mkv: slightly nicer file format indication 2019-09-19 20:37:04 +02:00