[vlc-commits] direct3d11: rework the luminance scaling

Steve Lhomme git at videolan.org
Mon Feb 12 10:45:56 CET 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Feb 12 10:45:42 2018 +0100| [62b2170649734c50fb030b8d036c401beb65e164] | committer: Steve Lhomme

direct3d11: rework the luminance scaling

Apply the luminance before the tone mapping. It gives more saturated/natural
colours.

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

 modules/video_output/win32/direct3d11.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 653a61d86f..449d776d18 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -365,10 +365,6 @@ static const char* globPixelShaderDefault = "\
       %s;\
   }\
   \
-  inline float3 adjustPeakLuminance(float3 rgb) {\
-      %s;\
-  }\
-  \
   inline float3 adjustRange(float3 rgb) {\
       %s;\
   }\
@@ -392,7 +388,6 @@ static const char* globPixelShaderDefault = "\
     float3 rgb = (float3)rgba;\
     rgb = sourceToLinear(rgb);\
     rgb = toneMapping(rgb);\
-    rgb = adjustPeakLuminance(rgb);\
     rgb = linearToDisplay(rgb);\
     rgb = adjustRange(rgb);\
     return float4(rgb, saturate(opacity));\
@@ -1738,7 +1733,6 @@ static HRESULT CompilePixelShader(vout_display_t *vd, const d3d_format_t *format
     const char *psz_src_transform     = DEFAULT_NOOP;
     const char *psz_display_transform = DEFAULT_NOOP;
     const char *psz_tone_mapping      = DEFAULT_NOOP;
-    const char *psz_peak_luminance    = DEFAULT_NOOP;
     const char *psz_adjust_range      = DEFAULT_NOOP;
     char *psz_range = NULL;
 
@@ -1834,7 +1828,7 @@ static HRESULT CompilePixelShader(vout_display_t *vd, const d3d_format_t *format
                         /* HDR tone mapping */
                         psz_tone_mapping =
                             "static const float3 HABLE_DIV = hable(11.2);\
-                            rgb = hable(rgb) / HABLE_DIV;\
+                            rgb = hable(rgb * LuminanceScale) / HABLE_DIV;\
                             return rgb";
                     }
                 }
@@ -1862,11 +1856,6 @@ static HRESULT CompilePixelShader(vout_display_t *vd, const d3d_format_t *format
         }
     }
 
-    if ( transfer == TRANSFER_FUNC_SMPTE_ST2084 &&
-         sys->display.colorspace->transfer != TRANSFER_FUNC_SMPTE_ST2084 )
-        /* the luminance may be dynamic */
-        psz_peak_luminance = "return rgb * LuminanceScale";
-
     int range_adjust = 0;
     if (sys->display.colorspace->b_full_range) {
         if (!src_full_range)
@@ -1944,7 +1933,7 @@ static HRESULT CompilePixelShader(vout_display_t *vd, const d3d_format_t *format
 
     char *shader = malloc(strlen(globPixelShaderDefault) + 32 + strlen(psz_sampler) +
                           strlen(psz_src_transform) + strlen(psz_display_transform) +
-                          strlen(psz_tone_mapping) + strlen(psz_peak_luminance) + strlen(psz_adjust_range));
+                          strlen(psz_tone_mapping) + strlen(psz_adjust_range));
     if (!shader)
     {
         msg_Err(vd, "no room for the Pixel Shader");
@@ -1952,12 +1941,11 @@ static HRESULT CompilePixelShader(vout_display_t *vd, const d3d_format_t *format
         return E_OUTOFMEMORY;
     }
     sprintf(shader, globPixelShaderDefault, sys->legacy_shader ? "" : "Array", psz_src_transform,
-            psz_display_transform, psz_tone_mapping, psz_peak_luminance, psz_adjust_range, psz_sampler);
+            psz_display_transform, psz_tone_mapping, psz_adjust_range, psz_sampler);
 #ifndef NDEBUG
     if (!IsRGBShader(format)) {
         msg_Dbg(vd,"psz_src_transform %s", psz_src_transform);
         msg_Dbg(vd,"psz_tone_mapping %s", psz_tone_mapping);
-        msg_Dbg(vd,"psz_peak_luminance %s", psz_peak_luminance);
         msg_Dbg(vd,"psz_display_transform %s", psz_display_transform);
         msg_Dbg(vd,"psz_adjust_range %s", psz_adjust_range);
         msg_Dbg(vd,"psz_sampler %s", psz_sampler);



More information about the vlc-commits mailing list