From 648739012a1518f41a663c89805ff77829a51e28 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Tue, 18 Jan 2022 21:21:23 +0900 Subject: [PATCH] compositor: Warn when inputs are SDR/HDR mixed Let user know that the result of mixed SDR/HDR is not guaranteed to be a good visual quality. Part-of: --- .../gst/compositor/compositor.c | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/subprojects/gst-plugins-base/gst/compositor/compositor.c b/subprojects/gst-plugins-base/gst/compositor/compositor.c index 87637802af..54a2e9dc58 100644 --- a/subprojects/gst-plugins-base/gst/compositor/compositor.c +++ b/subprojects/gst-plugins-base/gst/compositor/compositor.c @@ -1389,6 +1389,10 @@ _negotiated_caps (GstAggregator * agg, GstCaps * caps) GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (agg); GstVideoInfo v_info; guint n_threads; + GList *iter; + guint n_sdr = 0; + guint n_hlg = 0; + guint n_pq = 0; GST_DEBUG_OBJECT (agg, "Negotiated caps %" GST_PTR_FORMAT, caps); @@ -1400,6 +1404,40 @@ _negotiated_caps (GstAggregator * agg, GstCaps * caps) return FALSE; } + GST_OBJECT_LOCK (vagg); + for (iter = GST_ELEMENT (vagg)->sinkpads; iter; iter = g_list_next (iter)) { + GstVideoAggregatorPad *pad = (GstVideoAggregatorPad *) iter->data; + + if (!pad->info.finfo) + continue; + + switch (pad->info.colorimetry.transfer) { + case GST_VIDEO_TRANSFER_SMPTE2084: + n_pq++; + break; + case GST_VIDEO_TRANSFER_ARIB_STD_B67: + n_hlg++; + break; + default: + n_sdr++; + break; + } + } + GST_OBJECT_UNLOCK (vagg); + + /* TODO: we don't have support for HDR tone-mapping, so mixing HDR/SDR might + * result in somewhat visually bad image. Needs enhancement to the + * video-convert or somewhere */ + if (n_sdr > 0) { + if (n_hlg > 0 || n_pq > 0) { + GST_ELEMENT_WARNING (compositor, STREAM, NOT_IMPLEMENTED, + ("Mixing SDR and HDR contents would result in color loss"), (NULL)); + } + } else if (n_hlg > 0 && n_pq > 0) { + GST_ELEMENT_WARNING (compositor, STREAM, NOT_IMPLEMENTED, + ("Mixing HDR10 and HLG contents would result in color loss"), (NULL)); + } + if (compositor->max_threads == 0) n_threads = g_get_num_processors (); else