summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--player/video.c21
-rw-r--r--video/decode/dec_video.c1
-rw-r--r--video/decode/dec_video.h2
3 files changed, 21 insertions, 3 deletions
diff --git a/player/video.c b/player/video.c
index 73891890d0..e1aa19bd00 100644
--- a/player/video.c
+++ b/player/video.c
@@ -76,6 +76,8 @@ static const char av_desync_help_text[] =
" with --no-video, --no-audio, or --no-sub.\n"
"If none of this helps you, file a bug report.\n\n";
+static bool decode_coverart(struct dec_video *d_video);
+
static void set_allowed_vo_formats(struct vf_chain *c, struct vo *vo)
{
vo_query_formats(vo, c->allowed_output_formats);
@@ -301,6 +303,9 @@ int reinit_video_chain(struct MPContext *mpctx)
if (!video_init_best_codec(d_video, opts->video_decoders))
goto err_out;
+ if (!decode_coverart(d_video))
+ goto err_out;
+
bool saver_state = opts->pause || !opts->stop_screensaver;
vo_control(mpctx->video_out, saver_state ? VOCTRL_RESTORE_SCREENSAVER
: VOCTRL_KILL_SCREENSAVER, NULL);
@@ -362,6 +367,17 @@ static int check_framedrop(struct MPContext *mpctx)
return 0;
}
+static bool decode_coverart(struct dec_video *d_video)
+{
+ d_video->cover_art_mpi =
+ video_decode(d_video, d_video->header->attached_picture, 0);
+ // Might need flush.
+ if (!d_video->cover_art_mpi)
+ d_video->cover_art_mpi = video_decode(d_video, NULL, 0);
+
+ return !!d_video->cover_art_mpi;
+}
+
// Read a packet, store decoded image into d_video->waiting_decoded_mpi
// returns VD_* code
static int decode_image(struct MPContext *mpctx)
@@ -369,9 +385,8 @@ static int decode_image(struct MPContext *mpctx)
struct dec_video *d_video = mpctx->d_video;
if (d_video->header->attached_picture) {
- d_video->waiting_decoded_mpi =
- video_decode(d_video, d_video->header->attached_picture, 0);
- return d_video->waiting_decoded_mpi ? VD_EOF : VD_PROGRESS;
+ d_video->waiting_decoded_mpi = mp_image_new_ref(d_video->cover_art_mpi);
+ return VD_EOF;
}
struct demux_packet *pkt;
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c
index 0c733b0aa6..09da72579d 100644
--- a/video/decode/dec_video.c
+++ b/video/decode/dec_video.c
@@ -117,6 +117,7 @@ int video_get_colors(struct dec_video *d_video, const char *item, int *value)
void video_uninit(struct dec_video *d_video)
{
mp_image_unrefp(&d_video->waiting_decoded_mpi);
+ mp_image_unrefp(&d_video->cover_art_mpi);
if (d_video->vd_driver) {
MP_VERBOSE(d_video, "Uninit video.\n");
d_video->vd_driver->uninit(d_video);
diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h
index 5ab7213ee7..69e2a44e40 100644
--- a/video/decode/dec_video.h
+++ b/video/decode/dec_video.h
@@ -43,6 +43,8 @@ struct dec_video {
struct mp_image *waiting_decoded_mpi;
struct mp_image_params decoder_output; // last output of the decoder
+ struct mp_image *cover_art_mpi;
+
void *priv; // for free use by vd_driver
// Last PTS from decoder (set with each vd_driver->decode() call)