[vlc-devel] [PATCH 3/4] direct3d11: fix HLG displaying on LDR displays
Steve Lhomme
robux4 at videolabs.io
Tue Mar 7 16:39:07 CET 2017
--
fix UTF-8 encoding
replaces https://patches.videolan.org/patch/15828/
- rename constants
- turn pow(x,2.0) into x*x
- give a source for the algorithm
---
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 9fafc53e9f..fb622865d6 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;
--
2.11.1
More information about the vlc-devel
mailing list