From 8909e4487069dd546fd2475f7100dcce1cc4806f Mon Sep 17 00:00:00 2001 From: jpark37 Date: Sat, 14 May 2022 00:05:01 -0700 Subject: [PATCH] libobs: Cap HLG video at 1000 nits --- libobs/obs-source.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libobs/obs-source.c b/libobs/obs-source.c index da97e653e..8fc9c11cb 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -2258,17 +2258,18 @@ static bool update_async_texrender(struct obs_source *source, set_eparam(conv, "height_d2", (float)cy * 0.5f); set_eparam(conv, "width_x2_i", 0.5f / (float)cx); - const float hdr_nominal_peak_level = - obs->video.hdr_nominal_peak_level; + /* BT.2408 says higher than 1000 isn't comfortable */ + float hlg_peak_level = obs->video.hdr_nominal_peak_level; + if (hlg_peak_level > 1000.f) + hlg_peak_level = 1000.f; + const float maximum_nits = (frame->trc == VIDEO_TRC_HLG) - ? hdr_nominal_peak_level + ? hlg_peak_level : 10000.f; set_eparam(conv, "maximum_over_sdr_white_nits", maximum_nits / obs_get_video_sdr_white_level()); - const float hlg_gamma = - 1.2f + - (0.42f * log10f(hdr_nominal_peak_level / 1000.f)); - const float hlg_exponent = hlg_gamma - 1.f; + const float hlg_exponent = + 0.2f + (0.42f * log10f(hlg_peak_level / 1000.f)); set_eparam(conv, "hlg_exponent", hlg_exponent); struct vec4 vec0, vec1, vec2;