[vlc-devel] [PATCH 3/4] direct3d11: fix HLG displaying on LDR displays

Steve Lhomme robux4 at videolabs.io
Mon Mar 6 17:57:10 CET 2017


--
fix UTF-8 encoding
---
 modules/video_output/win32/direct3d11.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 31cc4e6242..0008c5f65e 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -313,6 +313,18 @@ static const char* globPixelShaderDefault = "\
       return x;\
   }\
   \
+  inline float inverse_HLG(float x){\
+      const float a = 0.17883277;\
+      const float b = 0.28466892;\
+      const float c = 0.55991073;\
+      const float inv_r2 = 4.0; /* 1/0.5² */\
+      if (x <= 0.5)\
+          x = pow(x, 2.0) * inv_r2;\
+      else\
+          x = exp((x - c) / a) + b;\
+      return x;\
+  }\
+  \
   inline float3 sourceToLinear(float3 rgb) {\
       %s;\
   }\
@@ -1620,6 +1632,15 @@ static HRESULT CompilePixelShader(vout_display_t *vd, const d3d_format_t *format
                     return rgb";
             src_transfer = TRANSFER_FUNC_LINEAR;
             break;
+        case TRANSFER_FUNC_HLG:
+            /* HLG to Linear */
+            psz_src_transform =
+                   "rgb.r = inverse_HLG(rgb.r);\
+                    rgb.g = inverse_HLG(rgb.g);\
+                    rgb.b = inverse_HLG(rgb.b);\
+                    return rgb / 6.0";
+            src_transfer = TRANSFER_FUNC_LINEAR;
+            break;
         default:
             src_transfer = transfer;
             break;
-- 
2.11.1



More information about the vlc-devel mailing list