[vlc-commits] direct3d11: add the HLG/BT.2020 OOTF adjustment

Steve Lhomme git at videolan.org
Thu May 23 17:04:31 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu May 23 15:33:46 2019 +0200| [0a0d5cae286ab5b7e09999456d9ac07e1d0a111c] | committer: Steve Lhomme

direct3d11: add the HLG/BT.2020 OOTF adjustment

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

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

diff --git a/modules/video_output/win32/d3d11_shaders.c b/modules/video_output/win32/d3d11_shaders.c
index 5150189602..b1f56303ed 100644
--- a/modules/video_output/win32/d3d11_shaders.c
+++ b/modules/video_output/win32/d3d11_shaders.c
@@ -266,6 +266,7 @@ HRESULT D3D11_CompilePixelShader(vlc_object_t *o, d3d11_handle_t *hd3d, bool leg
     const char *psz_adjust_range      = DEFAULT_NOOP;
     const char *psz_move_planes[2]    = {DEFAULT_NOOP, DEFAULT_NOOP};
     char *psz_range = NULL;
+    char *psz_transform = NULL;
 
     D3D11_SAMPLER_DESC sampDesc;
     memset(&sampDesc, 0, sizeof(sampDesc));
@@ -439,12 +440,16 @@ HRESULT D3D11_CompilePixelShader(vlc_object_t *o, d3d11_handle_t *hd3d, bool leg
                 src_transfer = TRANSFER_FUNC_LINEAR;
                 break;
             case TRANSFER_FUNC_HLG:
-                /* HLG to Linear */
-                psz_src_transform =
-                       "rgb.r = inverse_HLG(rgb.r);\n"
-                       "rgb.g = inverse_HLG(rgb.g);\n"
-                       "rgb.b = inverse_HLG(rgb.b);\n"
-                       "return rgb / 20.0";
+                asprintf(&psz_transform, "const float alpha_gain = 10000.0;\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"
+                                          "rgb *= pow(ootf_ys, 0.200);\n"
+                                          "return rgb / %lld;",
+                         display->transfer == TRANSFER_FUNC_SMPTE_ST2084 ? 1000 : 250);
+                psz_src_transform = psz_transform;
                 src_transfer = TRANSFER_FUNC_LINEAR;
                 break;
             case TRANSFER_FUNC_BT709:
@@ -612,6 +617,7 @@ HRESULT D3D11_CompilePixelShader(vlc_object_t *o, d3d11_handle_t *hd3d, bool leg
                                  psz_display_transform, psz_tone_mapping,
                                  psz_adjust_range, psz_move_planes[1], &quad->d3dpixelShader[1]);
     free(psz_range);
+    free(psz_transform);
 
     return hr;
 }



More information about the vlc-commits mailing list