[vlc-commits] direct3d11: fix HLG displaying on LDR displays
Steve Lhomme
git at videolan.org
Fri Mar 10 19:40:44 CET 2017
vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Tue Mar 7 16:39:07 2017 +0100| [130348dea55d5b4c7ee3eead169cf19c947b6282] | committer: Jean-Baptiste Kempf
direct3d11: fix HLG displaying on LDR displays
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=130348dea55d5b4c7ee3eead169cf19c947b6282
---
modules/video_output/win32/direct3d11.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 9fafc53..fb62286 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -313,6 +313,19 @@ static const char* globPixelShaderDefault = "\
return x;\
}\
\
+ /* https://en.wikipedia.org/wiki/Hybrid_Log-Gamma#Technical_details */\
+ inline float inverse_HLG(float x){\
+ const float B67_a = 0.17883277;\
+ const float B67_b = 0.28466892;\
+ const float B67_c = 0.55991073;\
+ const float B67_inv_r2 = 4.0; /* 1/0.5² */\
+ if (x <= 0.5)\
+ x = x * x * B67_inv_r2;\
+ else\
+ x = exp((x - B67_c) / B67_a) + B67_b;\
+ return x;\
+ }\
+ \
inline float3 sourceToLinear(float3 rgb) {\
%s;\
}\
@@ -1621,6 +1634,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;
More information about the vlc-commits
mailing list