[vlc-commits] direct3d11: do the inverse HLG conversion in one pass

Steve Lhomme git at videolan.org
Wed May 29 13:23:07 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed May 29 12:45:05 2019 +0200| [0ffc36df50e152cb97c468e5c86e570c1db4af13] | committer: Steve Lhomme

direct3d11: do the inverse HLG conversion in one pass

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

 modules/video_output/win32/d3d11_shaders.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/modules/video_output/win32/d3d11_shaders.c b/modules/video_output/win32/d3d11_shaders.c
index 6eb8467e19..7a8c380b21 100644
--- a/modules/video_output/win32/d3d11_shaders.c
+++ b/modules/video_output/win32/d3d11_shaders.c
@@ -81,12 +81,12 @@ static const char* globPixelShaderDefault = "\
   }\n\
   \n\
   /* https://en.wikipedia.org/wiki/Hybrid_Log-Gamma#Technical_details */\n\
-  inline float inverse_HLG(float x){\n\
+  inline float4 inverse_HLG(float4 x, float lumi){\n\
       const float B67_a = 0.17883277;\n\
       const float B67_b = 0.28466892;\n\
       const float B67_c = 0.55991073;\n\
       const float B67_inv_r2 = 4.0; /* 1/0.5² */\n\
-      if (x <= 0.5)\n\
+      if (lumi <= 0.5)\n\
           x = x * x * B67_inv_r2;\n\
       else\n\
           x = exp((x - B67_c) / B67_a) + B67_b;\n\
@@ -440,12 +440,10 @@ HRESULT D3D11_CompilePixelShader(vlc_object_t *o, d3d11_handle_t *hd3d, bool leg
                 break;
             case TRANSFER_FUNC_HLG:
                 psz_src_transform = "const float alpha_gain = 2000; /* depends on the display output */\n"
-                                    "/* TODO: in one call */\n"
-                                    "rgb.r = inverse_HLG(rgb.r);\n"
-                                    "rgb.g = inverse_HLG(rgb.g);\n"
-                                    "rgb.b = inverse_HLG(rgb.b);\n"
-                                    "float3 ootf_2020 = float3(0.2627, 0.6780, 0.0593);\n"
-                                    "float ootf_ys = alpha_gain * dot(ootf_2020, rgb);\n"
+                                    "const float3 ootf_2020 = float3(0.2627, 0.6780, 0.0593);\n"
+                                    "float lumi = dot(ootf_2020, rgb);\n"
+                                    "rgb = inverse_HLG(rgb, lumi);\n"
+                                    "float ootf_ys = alpha_gain * lumi;\n"
                                     "return rgb * pow(ootf_ys, 0.200)";
                 src_transfer = TRANSFER_FUNC_LINEAR;
                 break;



More information about the vlc-commits mailing list