[vlc-commits] direct3d11_shaders: fix negative pixel colours artefacts

Steve Lhomme git at videolan.org
Wed Oct 17 16:07:53 CEST 2018


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Oct 15 09:42:25 2018 +0200| [0df522fac5c82f9191c4b9647f1502ecd0281ed8] | committer: Steve Lhomme

direct3d11_shaders: fix negative pixel colours artefacts

It can happens when tone mapping on "LG NASA HDR Demo".

(cherry picked from commit 04d48fefd78e0e170c9937677abc24d7cb43ff33)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=0df522fac5c82f9191c4b9647f1502ecd0281ed8
---

 modules/video_output/win32/d3d11_shaders.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/modules/video_output/win32/d3d11_shaders.c b/modules/video_output/win32/d3d11_shaders.c
index f8df5fb291..ae111d7011 100644
--- a/modules/video_output/win32/d3d11_shaders.c
+++ b/modules/video_output/win32/d3d11_shaders.c
@@ -98,7 +98,6 @@ static const char* globPixelShaderDefault = "\
   }\n\
   \n\
   inline float3 linearToDisplay(float3 rgb) {\n\
-     rgb = clamp(rgb, 0, 1);\n\
       %s;\n\
   }\n\
   \n\
@@ -279,7 +278,7 @@ HRESULT D3D11_CompilePixelShader(vlc_object_t *o, d3d11_handle_t *hd3d, bool leg
                 /* ST2084 to Linear */
                 psz_src_transform =
                        ST2084_PQ_CONSTANTS
-                       "rgb = pow(rgb, 1.0/ST2084_m2);\n"
+                       "rgb = pow(max(rgb, 0), 1.0/ST2084_m2);\n"
                        "rgb = max(rgb - ST2084_c1, 0.0) / (ST2084_c2 - ST2084_c3 * rgb);\n"
                        "rgb = pow(rgb, 1.0/ST2084_m1);\n"
                        "return rgb";
@@ -355,7 +354,7 @@ HRESULT D3D11_CompilePixelShader(vlc_object_t *o, d3d11_handle_t *hd3d, bool leg
     }
 
     if (display->colorspace->primaries != primaries)
-        psz_primaries_transform = "return mul(rgb, Primaries)";
+        psz_primaries_transform = "return max(mul(rgb, Primaries), 0)";
 
     int range_adjust = 0;
     if (display->colorspace->b_full_range) {



More information about the vlc-commits mailing list