[vlc-commits] d3d11_quad: simplify the RGB/YUV conversion matrix selection

Steve Lhomme git at videolan.org
Fri Mar 13 10:28:32 CET 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Mar 10 13:35:54 2020 +0100| [686d6a031779502f1c8f1180fd93e61d6d3af1a9] | committer: Steve Lhomme

d3d11_quad: simplify the RGB/YUV conversion matrix selection

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

 modules/video_output/win32/d3d11_quad.c | 69 ++++++++++++++++-----------------
 1 file changed, 34 insertions(+), 35 deletions(-)

diff --git a/modules/video_output/win32/d3d11_quad.c b/modules/video_output/win32/d3d11_quad.c
index ca06da6b45..e62e6e7932 100644
--- a/modules/video_output/win32/d3d11_quad.c
+++ b/modules/video_output/win32/d3d11_quad.c
@@ -906,7 +906,7 @@ int D3D11_SetupQuad(vlc_object_t *o, d3d11_device_t *d3d_dev, const video_format
                     const display_info_t *displayFormat, const RECT *output,
                     video_orientation_t orientation)
 {
-    const bool RGB_shader = IsRGBShader(quad->textureFormat);
+    const bool RGB_src_shader = IsRGBShader(quad->textureFormat);
 
     quad->shaderConstants.LuminanceScale = (float)displayFormat->luminance_peak / GetFormatLuminance(o, fmt);
 
@@ -925,7 +925,7 @@ int D3D11_SetupQuad(vlc_object_t *o, d3d11_device_t *d3d_dev, const video_format
 
     FLOAT itu_black_level = 0.f;
     FLOAT itu_achromacy   = 0.f;
-    if (!RGB_shader)
+    if (!RGB_src_shader)
     {
         switch (quad->textureFormat->bitsPerChannel)
         {
@@ -995,46 +995,45 @@ int D3D11_SetupQuad(vlc_object_t *o, d3d11_device_t *d3d_dev, const video_format
     memcpy(colorspace.WhitePoint, IDENTITY_4X4, sizeof(colorspace.WhitePoint));
 
     const FLOAT *ppColorspace;
-    if (!IsRGBShader(displayFormat->pixelFormat))
+    if (RGB_src_shader == IsRGBShader(displayFormat->pixelFormat))
     {
-        if (!RGB_shader)
-            ppColorspace = IDENTITY_4X4;
-        else
-        {
-            ppColorspace = COLORSPACE_FULL_RGBA_TO_BT601_YUV;
-            colorspace.WhitePoint[0*4 + 3] = -itu_black_level;
-            colorspace.WhitePoint[1*4 + 3] = itu_achromacy;
-            colorspace.WhitePoint[2*4 + 3] = itu_achromacy;
-        }
+        ppColorspace = IDENTITY_4X4;
+    }
+    else if (RGB_src_shader)
+    {
+        ppColorspace = COLORSPACE_FULL_RGBA_TO_BT601_YUV;
+        colorspace.WhitePoint[0*4 + 3] = -itu_black_level;
+        colorspace.WhitePoint[1*4 + 3] = itu_achromacy;
+        colorspace.WhitePoint[2*4 + 3] = itu_achromacy;
     }
     else
     {
-        if (RGB_shader)
-            ppColorspace = IDENTITY_4X4;
-        else {
-            switch (fmt->space){
-                case COLOR_SPACE_BT709:
+        switch (fmt->space){
+            case COLOR_SPACE_BT709:
+                ppColorspace = COLORSPACE_BT709_YUV_TO_FULL_RGBA;
+                break;
+            case COLOR_SPACE_BT2020:
+                ppColorspace = COLORSPACE_BT2020_YUV_TO_FULL_RGBA;
+                break;
+            case COLOR_SPACE_BT601:
+                ppColorspace = COLORSPACE_BT601_YUV_TO_FULL_RGBA;
+                break;
+            default:
+            case COLOR_SPACE_UNDEF:
+                if( fmt->i_height > 576 )
+                {
                     ppColorspace = COLORSPACE_BT709_YUV_TO_FULL_RGBA;
-                    break;
-                case COLOR_SPACE_BT2020:
-                    ppColorspace = COLORSPACE_BT2020_YUV_TO_FULL_RGBA;
-                    break;
-                case COLOR_SPACE_BT601:
+                }
+                else
+                {
                     ppColorspace = COLORSPACE_BT601_YUV_TO_FULL_RGBA;
-                    break;
-                default:
-                case COLOR_SPACE_UNDEF:
-                    if( fmt->i_height > 576 )
-                        ppColorspace = COLORSPACE_BT709_YUV_TO_FULL_RGBA;
-                    else
-                        ppColorspace = COLORSPACE_BT601_YUV_TO_FULL_RGBA;
-                    break;
-            }
-            /* all matrices work in studio range and output in full range */
-            colorspace.WhitePoint[0*4 + 3] = -itu_black_level;
-            colorspace.WhitePoint[1*4 + 3] = -itu_achromacy;
-            colorspace.WhitePoint[2*4 + 3] = -itu_achromacy;
+                }
+                break;
         }
+        /* all matrices work in studio range and output in full range */
+        colorspace.WhitePoint[0*4 + 3] = -itu_black_level;
+        colorspace.WhitePoint[1*4 + 3] = -itu_achromacy;
+        colorspace.WhitePoint[2*4 + 3] = -itu_achromacy;
     }
 
     memcpy(colorspace.Colorspace, ppColorspace, sizeof(colorspace.Colorspace));



More information about the vlc-commits mailing list