summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2023-02-11 18:11:32 +0100
committerNiklas Haas <github-daiK1o@haasn.dev>2023-02-13 17:52:35 +0100
commit79b093f2108d3098ee68e62299c9a9436596f2ee (patch)
tree76fc489abccdfc3cffff9817e85d814476015d31 /video/out
parenta40958cdf87ba593015a9198e28d4805aca23929 (diff)
downloadmpv-79b093f2108d3098ee68e62299c9a9436596f2ee.tar.bz2
mpv-79b093f2108d3098ee68e62299c9a9436596f2ee.tar.xz
vo_gpu_next: support mapping HDR10+ dynamic metadata
Based on the new upstream helper function `pl_map_hdr_metadata` and the existing AV_FRAME_DATA_DYNAMIC_HDR_PLUS. This allows us to use SMPTE 2094-40 dynamic HDR tonemapping in mpv, albeit with the limitation of requiring `--tone-mapping=auto` in order to pick this curve upstream.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/vo_gpu_next.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c
index bca48824fa..d4c0e76ef0 100644
--- a/video/out/vo_gpu_next.c
+++ b/video/out/vo_gpu_next.c
@@ -422,6 +422,17 @@ static int plane_data_from_imgfmt(struct pl_plane_data out_data[4],
return desc.num_planes;
}
+static inline void *get_side_data(const struct mp_image *mpi,
+ enum AVFrameSideDataType type)
+{
+ for (int i = 0; i <mpi->num_ff_side_data; i++) {
+ if (mpi->ff_side_data[i].type == type)
+ return (void *) mpi->ff_side_data[i].buf->data;
+ }
+
+ return NULL;
+}
+
static struct pl_color_space get_mpi_csp(struct vo *vo, struct mp_image *mpi)
{
struct pl_color_space csp = {
@@ -430,6 +441,13 @@ static struct pl_color_space get_mpi_csp(struct vo *vo, struct mp_image *mpi)
.hdr.max_luma = mpi->params.color.sig_peak * MP_REF_WHITE,
};
+#ifdef PL_HAVE_LAV_HDR
+ pl_map_hdr_metadata(&csp.hdr, &(struct pl_av_hdr_metadata) {
+ .mdm = get_side_data(mpi, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA),
+ .clm = get_side_data(mpi, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL),
+ .dhp = get_side_data(mpi, AV_FRAME_DATA_DYNAMIC_HDR_PLUS),
+ });
+#else // back-compat fallback for older libplacebo
for (int i = 0; i < mpi->num_ff_side_data; i++) {
void *data = mpi->ff_side_data[i].buf->data;
switch (mpi->ff_side_data[i].type) {
@@ -461,6 +479,7 @@ static struct pl_color_space get_mpi_csp(struct vo *vo, struct mp_image *mpi)
default: break;
}
}
+#endif // PL_HAVE_LAV_HDR
return csp;
}