summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-01-10 14:03:41 +0100
committerwm4 <wm4@nowhere>2017-01-10 15:43:02 +0100
commit4e25feda0d5e084761a9935de7c1e592e86de94f (patch)
treecacddbd4921351f06810e6182d2c55b3e0545e2c /demux
parent334cad57c63d31a346b1457ae92dbb0b64938016 (diff)
downloadmpv-4e25feda0d5e084761a9935de7c1e592e86de94f.tar.bz2
mpv-4e25feda0d5e084761a9935de7c1e592e86de94f.tar.xz
player: change aspects of cover art handling
Cover art handling is a disgusting hack that causes a mess in all components. And this will stay this way. This is the Xth time I've changed cover art handling, and that will probably also continue. But change the code such that cover art is injected into the demux packet stream, instead of having an explicit special case it in the decoder glue code. (This is somewhat more similar to the cover art hack in libavformat.) To avoid that the over art picture is decoded again on each seek, we need some additional "caching" in player/video.c. Decoding it after each seek would work as well, but since cover art pictures can be pretty huge, it's probably ok to invest some lines of code into caching it. One weird thing is that the cover art packet will remain queued after seeks, but that is probably not an issue. In exchange, we can drop the dec_video.c code, which is pretty convenient for one of the following commits. This code duplicates a bunch of lower-level decode calls and does icky messing with this weird state stuff, so I'm glad it goes away.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/demux/demux.c b/demux/demux.c
index a94d98e10f..2195246ac8 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -205,6 +205,9 @@ struct demux_stream {
struct demux_packet *head;
struct demux_packet *tail;
+ struct demux_packet *attached_picture;
+ bool attached_picture_added;
+
// for closed captions (demuxer_feed_caption)
struct sh_stream *cc;
};
@@ -243,6 +246,7 @@ static void ds_flush(struct demux_stream *ds)
ds->last_pos = -1;
ds->last_dts = MP_NOPTS_VALUE;
ds->correct_dts = ds->correct_pos = true;
+ ds->attached_picture_added = false;
}
void demux_set_ts_offset(struct demuxer *demuxer, double offset)
@@ -291,6 +295,8 @@ void demux_add_sh_stream(struct demuxer *demuxer, struct sh_stream *sh)
if (!sh->codec->codec)
sh->codec->codec = "";
+ sh->ds->attached_picture = sh->attached_picture;
+
sh->index = in->num_streams;
if (sh->ff_index < 0)
sh->ff_index = sh->index;
@@ -755,6 +761,13 @@ static void *demux_thread(void *pctx)
static struct demux_packet *dequeue_packet(struct demux_stream *ds)
{
+ if (ds->attached_picture) {
+ ds->eof = true;
+ if (ds->attached_picture_added)
+ return NULL;
+ ds->attached_picture_added = true;
+ return demux_copy_packet(ds->attached_picture);
+ }
if (!ds->head)
return NULL;
struct demux_packet *pkt = ds->head;
@@ -800,18 +813,21 @@ static struct demux_packet *dequeue_packet(struct demux_stream *ds)
// Whether to avoid actively demuxing new packets to find a new packet on the
// given stream.
+// Attached pictures (cover art) should never actively read.
// Sparse packets (Subtitles) interleaved with other non-sparse packets (video,
// audio) should never be read actively, meaning the demuxer thread does not
// try to exceed default readahead in order to find a new packet.
static bool use_lazy_packet_reading(struct demux_stream *ds)
{
+ if (ds->attached_picture)
+ return true;
if (ds->type != STREAM_SUB)
return false;
// Subtitles are only lazily read if there's at least 1 other actively read
// stream.
for (int n = 0; n < ds->in->num_streams; n++) {
struct demux_stream *s = ds->in->streams[n]->ds;
- if (s->type != STREAM_SUB && s->selected && !s->eof)
+ if (s->type != STREAM_SUB && s->selected && !s->eof && !s->attached_picture)
return true;
}
return false;