1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-01 14:50:07 +00:00
mpv/demux
wm4 ca2b10d18d demux: add shitty start of stream detection
The demuxer cache benefits slightly from knowing where the current file
or stream begins. For example, seeking "left most" when the start is
cached would not trigger a low level seek (which would be followed by
messy range joining when it notices that the newly demuxed packets
overlap with an existing range).

Unfortunately, since multimedia is so crazy (or actually FFmpeg in its
quite imperfect attempt to be able to demux anything), it's hard to tell
where a file starts. There is no feedback whether a specific seek went
to the start of the file. Packets are not tagged with a flag indicating
they were demuxed from the start position. There is no index available
that could be used to cross-check this (even if the file contains a full
and "perfect" index, like mp4). You could go by the timestamps, but who
says streams start at 0? Streams can start somewhere at an extremely
high timestamps (transport streams like to do that), or they could start
at negative times (e.g. files with audio pre-padding will do that), and
maybe some file formats simply allow negative timestamps and could start
at any negative time. Even if the affected file formats don't allow it
in theory, they may in practice. In addition, FFmpeg exports a
start_time field, which may or may not be useful. (mpv's internal mkv
demuxer also exports such a field, but doesn't bother to set it for
efficiency and robustness reasons.)

Anyway, this is all a huge load of crap, so I decided that if the user
performs a seek command to time 0 or earlier, we consider the first
packet demuxed from each stream to be at the start of the file. In
addition, just trust the start_time field. This is the "shitty" part of
this commit.

One common case of negative timestamps is audio pre-padding. Demuxers
normally behave sanely, and will treat 0 as the start of the file, and
the first packets demuxed will have negative timestamps (since they
contain data to discard), which doesn't break our assumptions in this
commit. (Although, unfortunately, do break some other demuxer cache
assumptions, and the first cached range will be shown as starting at a
negative time.)

Implementation-wise, this is quite simple. Just split the existing
initial_state flag into two, since we want to deal with two separate
aspects. In addition, this avoids the refresh seek on track switching
when it happens right after a seek, instead of only after opening the
demuxer.
2019-05-17 23:45:54 +02:00
..
codec_tags.c demux_mkv: simplify avi compat. codec_tags.c GUID lookup 2018-09-14 14:17:32 +02: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 cue: strip quotes and leading whitespace from tags 2018-01-30 14:01:15 +01: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-01-11 15:12:30 +01:00
demux_edl.c demux_edl: fix assertion failure on exit in obscure ytdl cases 2019-01-20 15:46:09 +01:00
demux_lavf.c demux: slightly cleanup network speed reporting 2019-01-05 09:11:18 +01:00
demux_libarchive.c demux: change hack for closing subtitle files early 2018-09-07 23:02:36 +02:00
demux_mf.c demux: return packets directly from demuxer instead of using sh_stream 2018-09-07 15:20:32 +02:00
demux_mkv_timeline.c demux_edl, cue, mkv: slightly nicer file format indication 2019-01-11 15:12:30 +01:00
demux_mkv.c demux_mkv: fix seeking in broken mjpeg files 2019-01-18 01:04:49 +01: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 2018-09-07 23:02:36 +02:00
demux_raw.c demux: return packets directly from demuxer instead of using sh_stream 2018-09-07 15:20:32 +02:00
demux_timeline.c demux_timeline: add heuristic to fix shifted seeks with separate audio 2019-01-11 15:12:30 +01:00
demux.c demux: add shitty start of stream detection 2019-05-17 23:45:54 +02:00
demux.h demux, command: export bof/eof flags 2019-05-17 22:28:12 +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 demux: support for some kinds of timed metadata 2018-04-18 01:17:42 +03:00
packet.h packet: reorder fields 2019-05-16 16:20:45 +02:00
stheader.h demux, player: fix playback of sparse video streams (w/ still images) 2018-05-24 10:26:41 -07:00
timeline.c demux_edl, cue, mkv: slightly nicer file format indication 2019-01-11 15:12:30 +01:00
timeline.h demux_edl, cue, mkv: slightly nicer file format indication 2019-01-11 15:12:30 +01:00