summaryrefslogtreecommitdiffstats
path: root/player
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 /player
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 'player')
-rw-r--r--player/core.h2
-rw-r--r--player/video.c26
2 files changed, 23 insertions, 5 deletions
diff --git a/player/core.h b/player/core.h
index d8640d9ef0..d7510a79fe 100644
--- a/player/core.h
+++ b/player/core.h
@@ -178,6 +178,8 @@ struct vo_chain {
// - video consists of a single picture, which should be shown only once
// - do not sync audio to video in any way
bool is_coverart;
+ // Just to avoid decoding the coverart picture again after a seek.
+ struct mp_image *cached_coverart;
};
// Like vo_chain, for audio.
diff --git a/player/video.c b/player/video.c
index 4621d19cb4..78d10fd107 100644
--- a/player/video.c
+++ b/player/video.c
@@ -328,6 +328,10 @@ static void vo_chain_reset_state(struct vo_chain *vo_c)
if (vo_c->video_src)
video_reset(vo_c->video_src);
+
+ // Prepare for continued playback after a seek.
+ if (!vo_c->input_mpi && vo_c->cached_coverart)
+ vo_c->input_mpi = mp_image_new_ref(vo_c->cached_coverart);
}
void reset_video_state(struct MPContext *mpctx)
@@ -381,6 +385,7 @@ static void vo_chain_uninit(struct vo_chain *vo_c)
lavfi_set_connected(vo_c->filter_src, false);
mp_image_unrefp(&vo_c->input_mpi);
+ mp_image_unrefp(&vo_c->cached_coverart);
vf_destroy(vo_c->vf);
talloc_free(vo_c);
// this does not free the VO
@@ -682,14 +687,25 @@ static int video_decode_and_filter(struct MPContext *mpctx)
return r;
if (!vo_c->input_mpi) {
- // Decode a new image, or at least feed the decoder a packet.
- r = decode_image(mpctx);
- if (r == VD_WAIT)
- return r;
+ if (vo_c->cached_coverart) {
+ // Don't ever decode it twice, not even after seek resets.
+ // (On seek resets, input_mpi is set to the cached image.)
+ r = VD_EOF;
+ } else {
+ // Decode a new image, or at least feed the decoder a packet.
+ r = decode_image(mpctx);
+ if (r == VD_WAIT)
+ return r;
+ }
}
- if (vo_c->input_mpi)
+
+ if (vo_c->input_mpi) {
vo_c->input_format = vo_c->input_mpi->params;
+ if (vo_c->is_coverart && !vo_c->cached_coverart)
+ vo_c->cached_coverart = mp_image_new_ref(vo_c->input_mpi);
+ }
+
bool eof = !vo_c->input_mpi && (r == VD_EOF || r < 0);
r = video_filter(mpctx, eof);
if (r == VD_RECONFIG) // retry feeding decoded image