libobs: Fix NaNs when using EETF for HLG

This commit is contained in:
jpark37
2022-04-26 10:11:28 -07:00
committed by Jim
parent ed85307f7e
commit a82bbb416f
+3 -4
View File
@@ -97,12 +97,11 @@ float3 maxRGB_eetf(float3 rgb, float Lw, float Lmax)
float maxRGB1_pq = linear_to_st2084_channel(maxRGB_linear);
float maxRGB2_pq = eetf_0_1000(Lw, maxRGB1_pq);
float maxRGB2_linear = st2084_to_linear_channel(maxRGB2_pq);
float scaling_ratio = maxRGB2_linear / maxRGB_linear;
// scaling_ratio could be NaN
scaling_ratio = max(0., scaling_ratio);
// avoid divide-by-zero possibility
maxRGB_linear = max(6.10352e-5, maxRGB_linear);
rgb *= scaling_ratio;
rgb *= maxRGB2_linear / maxRGB_linear;
return rgb;
}