[vlc-commits] direct3d11: pass the Whitepoint shifts as a Matrix

Steve Lhomme git at videolan.org
Fri Mar 10 19:40:46 CET 2017


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Tue Mar  7 16:39:39 2017 +0100| [9e0ce0f0d887f10c2ce66b0d92601d932643ea8b] | committer: Jean-Baptiste Kempf

direct3d11: pass the Whitepoint shifts as a Matrix

This way we get the RGB from the sampled pixel using 2 matrix multiplications.
It may be more efficient than adding values separately

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/video_output/win32/direct3d11.c | 40 ++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 9482816..781103d 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -172,8 +172,7 @@ typedef struct {
 } PS_CONSTANT_BUFFER;
 
 typedef struct {
-    FLOAT WhitePoint[3];
-    FLOAT whitePadding;
+    FLOAT WhitePoint[4*4];
     FLOAT Colorspace[4*4];
 } PS_COLOR_TRANSFORM;
 
@@ -286,10 +285,7 @@ static const char* globPixelShaderDefault = "\
   };\
   cbuffer PS_COLOR_TRANSFORM : register(b1)\
   {\
-    float WhitePointX;\
-    float WhitePointY;\
-    float WhitePointZ;\
-    float whitePadding;\
+    float4x4 WhitePoint;\
     float4x4 Colorspace;\
   };\
   Texture2D%s shaderTexture[" STRINGIZE(D3D11_MAX_SHADER_VIEW) "];\
@@ -344,12 +340,7 @@ static const char* globPixelShaderDefault = "\
     float4 sample;\
     \
     %s /* sampling routine in sample */\
-    float4 rgba;\
-    rgba.x = sample.x + WhitePointX;\
-    rgba.y = sample.y + WhitePointY;\
-    rgba.z = sample.z + WhitePointZ;\
-    rgba.a = sample.a * Opacity;\
-    rgba = mul(rgba, Colorspace);\
+    float4 rgba = mul(mul(sample, WhitePoint), Colorspace);\
     float opacity = rgba.a * Opacity;\
     float3 rgb = (float3)rgba;\
     rgb = sourceToLinear(rgb);\
@@ -2220,10 +2211,6 @@ static int SetupQuad(vout_display_t *vd, const video_format_t *fmt, d3d_quad_t *
         }
     }
 
-    FLOAT WHITE_POINT_D65_TO_FULL[4] = { -itu_black_level, -itu_achromacy, -itu_achromacy, 1.f };
-    if (RGB_shader)
-        WHITE_POINT_D65_TO_FULL[0] = WHITE_POINT_D65_TO_FULL[1] = WHITE_POINT_D65_TO_FULL[2] = 0.f;
-
     static const FLOAT COLORSPACE_RGB_FULL[4 * 4] = {
         1.f, 0.f, 0.f, 0.f,
         0.f, 1.f, 0.f, 0.f,
@@ -2279,14 +2266,25 @@ static int SetupQuad(vout_display_t *vd, const video_format_t *fmt, d3d_quad_t *
     }
 
     memcpy(colorspace.Colorspace, ppColorspace, sizeof(colorspace.Colorspace));
-    memcpy(colorspace.WhitePoint, WHITE_POINT_D65_TO_FULL, sizeof(colorspace.WhitePoint));
+    memcpy(colorspace.WhitePoint, COLORSPACE_RGB_FULL, sizeof(colorspace.WhitePoint));
+
+    if (!RGB_shader)
+    {
+        colorspace.WhitePoint[0*4 + 3] = -itu_black_level;
+        colorspace.WhitePoint[1*4 + 3] = -itu_achromacy;
+        colorspace.WhitePoint[2*4 + 3] = -itu_achromacy;
+    }
 
     if (sys->display_is_limited_range) {
-        /* limit to 16-235 range as it's expanded again by the hardware */
-        WHITE_POINT_D65_TO_FULL[0] += itu_black_level;
+        /* get to the limited/studio range */
+        colorspace.WhitePoint[0*4 + 3] += itu_black_level;
+        if (RGB_shader)
+        {
+            colorspace.WhitePoint[1*4 + 3] += itu_black_level;
+            colorspace.WhitePoint[2*4 + 3] += itu_black_level;
+        }
+
         if (RGB_shader) {
-            WHITE_POINT_D65_TO_FULL[1] += itu_black_level;
-            WHITE_POINT_D65_TO_FULL[2] += itu_black_level;
             /* expand each color's range */
             colorspace.Colorspace[0 * 5] *= itu_range_factor;
             colorspace.Colorspace[1 * 5] *= itu_range_factor;



More information about the vlc-commits mailing list