From a18a7cd4f568aa934be30b2cdf813a0879b8db19 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 30 Oct 2017 21:07:38 +0100 Subject: vd_lavc: move display mastering data stuff to mp_image This is where it should be. It only wasn't because of an old libavcodec bug, that returned the side data only on every IDR. This required some sort of caching, which is now dropped. (mp_image wouldn't have been able to do this kind of caching, because this code is stateless.) We don't support these old libavcodec versions anymore, which is why this is not needed anymore. Also move initialization of rotation/stereo stuff to dec_video.c. --- video/mp_image.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'video/mp_image.c') diff --git a/video/mp_image.c b/video/mp_image.c index 47ea115a90..6934ff4c58 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -26,6 +26,10 @@ #include #include +#if LIBAVUTIL_VERSION_MICRO >= 100 +#include +#endif + #include "mpv_talloc.h" #include "config.h" @@ -872,6 +876,21 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src) sd = av_frame_get_side_data(src, AV_FRAME_DATA_ICC_PROFILE); if (sd) dst->icc_profile = av_buffer_ref(sd->buf); + + // Get the content light metadata if available + sd = av_frame_get_side_data(src, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + if (sd) { + AVContentLightMetadata *clm = (AVContentLightMetadata *)sd->data; + dst->params.color.sig_peak = clm->MaxCLL / MP_REF_WHITE; + } + + // Otherwise, try getting the mastering metadata if available + sd = av_frame_get_side_data(src, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + if (!dst->params.color.sig_peak && sd) { + AVMasteringDisplayMetadata *mdm = (AVMasteringDisplayMetadata *)sd->data; + if (mdm->has_luminance) + dst->params.color.sig_peak = av_q2d(mdm->max_luminance) / MP_REF_WHITE; + } #endif if (dst->hwctx) { -- cgit v1.2.3