diff options
author | wm4 <wm4@nowhere> | 2019-12-31 00:15:35 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-12-31 00:17:46 +0100 |
commit | 3b6c4e7be1394580472903d8e189aec6de8c03a1 (patch) | |
tree | a614c5040dc54cd8fd1d12def3c47d23929cc45b /video/out/gpu/hwdec.h | |
parent | b721f9d0957c5c30f86ff485240f68881fc329a6 (diff) | |
download | mpv-3b6c4e7be1394580472903d8e189aec6de8c03a1.tar.bz2 mpv-3b6c4e7be1394580472903d8e189aec6de8c03a1.tar.xz |
demux: make track switching instant with certain mpegts files
When switching tracks, the data for the new track is missing by the
amount of data prefetched. This is because all demuxers return
interleaved data, and you can't just seek the switched track alone.
Normally, this would mean that the new track simply gets no data for a
while (e.g. silence if it's an audio track). To avoid this, mpv performs
a special "refresh seek" in the demuxer, which tries to resume demuxing
from an earlier position, in a way that does not disrupt decoding for
the non-changed tracks. (Could write a lot about the reasons for doing
something so relatively complex, and the alternatives and their
weaknesses, but let's not.)
This requires that the demuxer can tell whether a packet after a seek
was before or after a previously demuxed packet, sort of like an unique
ID. The code can use the byte position (pos) and the DTS for this. The
DTS is normally strictly monotonically increasing, the position in most
sane file formats too (notably not mp4, in theory).
The file at hand had DTS==NOPTS packets (which is fine, usually this
happens when PTS can be used instead, but the demux.c code structure
doesn't make it easy to use this), and pos==-1 at the same time. The
latter is what libavformat likes to return when the packet was produced
by a "parser" (or in other words, packets were split or reassembled),
and the packet has no real file position. That means the refresh seek
mechanism has no packet position and can't work.
Fix this by making up a pseudo-position if it's missing. This needs to
set the same value every time, which is why it does not work for
keyframe packets (which, by definition, could be a seek target).
Fixes: #7306 (sort of)
Diffstat (limited to 'video/out/gpu/hwdec.h')
0 files changed, 0 insertions, 0 deletions