demux: fight libavformat cover art hack harder

libavformat's cover art hack (aka attached pictures) breaks the ability
of the demuxer cache to keep multiple seek ranges. This happens because
the cover art packet has neither position nor timestamp, and libavformat
gives us the packet even though we intended to drop it.

The cover art hack works by adding the cover art packet to the read
packet stream once when demuxing starts (or after seeks). mpv treats
cover art in a similar way internally, but we have to compensate for
libavformat's shortcomings, and add the cover art packet ourselves when
we need it. So we don't want libavformat to return the packet.

We normally prevent this in demux_lavc.c/select_tracks() and explicitly
disable cover art streams. (We add it in dequeue_packet() instead.) But
libavformat will actually add the cover art packet even if we disable
the cover art stream, because it adds it at initialization time, and
does not bother to check again in av_read_frame() (apparently). The
packet is actually read, and upsets the demuxer cache logic. In
addition, this also means we probably decoded the cover art picture
twice in some situations.

Fix this by explicitly checking/discarding this in yet another place.

(Screw this hack...)
This commit is contained in:
wm4 2018-01-09 21:41:51 +01:00 committed by Kevin Mitchell
parent 4a11c28237
commit c0cc145069
1 changed files with 1 additions and 1 deletions

View File

@ -1164,7 +1164,7 @@ void demux_add_packet(struct sh_stream *stream, demux_packet_t *dp)
struct demux_queue *queue = ds->queue;
bool drop = !ds->selected || in->seeking;
bool drop = !ds->selected || in->seeking || ds->sh->attached_picture;
if (!drop && ds->refreshing) {
// Resume reading once the old position was reached (i.e. we start
// returning packets where we left off before the refresh).