summaryrefslogtreecommitdiffstats
path: root/video/mp_image.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-10-30 21:07:38 +0100
committerwm4 <wm4@nowhere>2017-10-30 21:07:48 +0100
commita18a7cd4f568aa934be30b2cdf813a0879b8db19 (patch)
tree1f859ec4ba2f2fa8dcabcd443591b29134053d74 /video/mp_image.c
parenta7f4ecb01299835a1afe5cc051be1e9bb5d4f15d (diff)
downloadmpv-a18a7cd4f568aa934be30b2cdf813a0879b8db19.tar.bz2
mpv-a18a7cd4f568aa934be30b2cdf813a0879b8db19.tar.xz
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.
Diffstat (limited to 'video/mp_image.c')
-rw-r--r--video/mp_image.c19
1 files changed, 19 insertions, 0 deletions
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 <libavutil/rational.h>
#include <libavcodec/avcodec.h>
+#if LIBAVUTIL_VERSION_MICRO >= 100
+#include <libavutil/mastering_display_metadata.h>
+#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) {