浏览代码

libobs: Cap HLG video at 1000 nits

jpark37 3 年之前
父节点
当前提交
8909e44870
共有 1 个文件被更改,包括 8 次插入7 次删除
  1. 8 7
      libobs/obs-source.c

+ 8 - 7
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, "height_d2", (float)cy * 0.5f);
 		set_eparam(conv, "width_x2_i", 0.5f / (float)cx);
 		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)
 		const float maximum_nits = (frame->trc == VIDEO_TRC_HLG)
-						   ? hdr_nominal_peak_level
+						   ? hlg_peak_level
 						   : 10000.f;
 						   : 10000.f;
 		set_eparam(conv, "maximum_over_sdr_white_nits",
 		set_eparam(conv, "maximum_over_sdr_white_nits",
 			   maximum_nits / obs_get_video_sdr_white_level());
 			   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);
 		set_eparam(conv, "hlg_exponent", hlg_exponent);
 
 
 		struct vec4 vec0, vec1, vec2;
 		struct vec4 vec0, vec1, vec2;