[vlc-devel] [PATCH 1/5] direct3d11: keep the default pixel conversion matrices static

Steve Lhomme robux4 at videolabs.io
Mon Mar 6 17:57:49 CET 2017


---
 modules/video_output/win32/direct3d11.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 1f9fd1fdca..3ffba3d735 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -2187,26 +2187,26 @@ static int SetupQuad(vout_display_t *vd, const video_format_t *fmt, d3d_quad_t *
     if (RGB_shader)
         WHITE_POINT_D65_TO_FULL[0] = WHITE_POINT_D65_TO_FULL[1] = WHITE_POINT_D65_TO_FULL[2] = 0.f;
 
-    FLOAT COLORSPACE_RGB_FULL[4 * 4] = {
+    static const FLOAT COLORSPACE_RGB_FULL[4 * 4] = {
         1.f, 0.f, 0.f, 0.f,
         0.f, 1.f, 0.f, 0.f,
         0.f, 0.f, 1.f, 0.f,
         0.f, 0.f, 0.f, 1.f,
     };
-    FLOAT COLORSPACE_BT601_TO_FULL[4*4] = {
+    static const FLOAT COLORSPACE_BT601_TO_FULL[4*4] = {
         1.164383561643836f,                 0.f,  1.596026785714286f, 0.f,
         1.164383561643836f, -0.391762290094914f, -0.812967647237771f, 0.f,
         1.164383561643836f,  2.017232142857142f,                 0.f, 0.f,
                        0.f,                 0.f,                 0.f, 1.f,
     };
-    FLOAT COLORSPACE_BT709_TO_FULL[4*4] = {
+    static const FLOAT COLORSPACE_BT709_TO_FULL[4*4] = {
         1.164383561643836f,                 0.f,  1.792741071428571f, 0.f,
         1.164383561643836f, -0.213248614273730f, -0.532909328559444f, 0.f,
         1.164383561643836f,  2.112401785714286f,                 0.f, 0.f,
                        0.f,                 0.f,                 0.f, 1.f,
     };
     /* RGB-709 to RGB-2020 based on https://www.researchgate.net/publication/258434326_Beyond_BT709 */
-    FLOAT COLORSPACE_BT2020_TO_FULL[4*4] = {
+    static const FLOAT COLORSPACE_BT2020_TO_FULL[4*4] = {
         1.163746465f, -0.028815145f,  2.823537589f, 0.f,
         1.164383561f, -0.258509894f,  0.379693635f, 0.f,
         1.164383561f,  2.385315708f,  0.021554502f, 0.f,
@@ -2214,7 +2214,7 @@ static int SetupQuad(vout_display_t *vd, const video_format_t *fmt, d3d_quad_t *
     };
 
     PS_COLOR_TRANSFORM colorspace;
-    FLOAT *ppColorspace;
+    const FLOAT *ppColorspace;
     if (RGB_shader)
         ppColorspace = COLORSPACE_RGB_FULL;
     else
@@ -2237,6 +2237,9 @@ static int SetupQuad(vout_display_t *vd, const video_format_t *fmt, d3d_quad_t *
             break;
     }
 
+    memcpy(colorspace.Colorspace, ppColorspace, sizeof(colorspace.Colorspace));
+    memcpy(colorspace.WhitePoint, WHITE_POINT_D65_TO_FULL, sizeof(colorspace.WhitePoint));
+
 #if VLC_WINSTORE_APP
     if (isXboxHardware(sys->d3ddevice)) {
         static const FLOAT FULL_TO_STUDIO_RATIO = (256.f - 16.f - 20.f) / 256.f;
@@ -2245,19 +2248,17 @@ static int SetupQuad(vout_display_t *vd, const video_format_t *fmt, d3d_quad_t *
         if (RGB_shader) {
             WHITE_POINT_D65_TO_FULL[1] += FULL_TO_STUDIO_SHIFT;
             WHITE_POINT_D65_TO_FULL[2] += FULL_TO_STUDIO_SHIFT;
-            ppColorspace[0 * 5] *= FULL_TO_STUDIO_RATIO;
-            ppColorspace[1 * 5] *= FULL_TO_STUDIO_RATIO;
-            ppColorspace[2 * 5] *= FULL_TO_STUDIO_RATIO;
+            colorspace.Colorspace[0 * 5] *= FULL_TO_STUDIO_RATIO;
+            colorspace.Colorspace[1 * 5] *= FULL_TO_STUDIO_RATIO;
+            colorspace.Colorspace[2 * 5] *= FULL_TO_STUDIO_RATIO;
         } else {
-            ppColorspace[0 * 4] *= FULL_TO_STUDIO_RATIO;
-            ppColorspace[1 * 4] *= FULL_TO_STUDIO_RATIO;
-            ppColorspace[2 * 4] *= FULL_TO_STUDIO_RATIO;
+            colorspace.Colorspace[0 * 4] *= FULL_TO_STUDIO_RATIO;
+            colorspace.Colorspace[1 * 4] *= FULL_TO_STUDIO_RATIO;
+            colorspace.Colorspace[2 * 4] *= FULL_TO_STUDIO_RATIO;
         }
     }
 #endif
 
-    memcpy(colorspace.Colorspace, ppColorspace, sizeof(colorspace.Colorspace));
-    memcpy(colorspace.WhitePoint, WHITE_POINT_D65_TO_FULL, sizeof(colorspace.WhitePoint));
     constantInit.pSysMem = &colorspace;
 
     static_assert((sizeof(PS_COLOR_TRANSFORM)%16)==0,"Constant buffers require 16-byte alignment");
-- 
2.11.1



More information about the vlc-devel mailing list