[vlc-commits] direct3d11: do not allow screen modes where we can't tone map

Steve Lhomme git at videolan.org
Fri Apr 6 08:58:16 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Apr  6 08:35:16 2018 +0200| [3d14c31f374288a63fc3a9f0f4f375bebe374013] | committer: Steve Lhomme

direct3d11: do not allow screen modes where we can't tone map

Fixes #20234

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

 modules/video_output/win32/direct3d11.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index a7a0ae7796..0e465638d1 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1372,6 +1372,19 @@ static const dxgi_color_space color_spaces[] = {
 #undef DXGIMAP
 };
 
+#ifdef HAVE_DXGI1_6_H
+static bool canHandleConversion(const dxgi_color_space *src, const dxgi_color_space *dst)
+{
+    if (src == dst)
+        return true;
+    if (src->primaries == COLOR_PRIMARIES_BT2020)
+        return true; /* we can convert BT2020 to 2020 or 709 */
+    if (dst->transfer == TRANSFER_FUNC_BT709)
+        return true; /* we can handle anything to 709 */
+    return false; /* let Windows do the rest */
+}
+#endif
+
 static void D3D11SetColorSpace(vout_display_t *vd)
 {
     vout_display_sys_t *sys = vd->sys;
@@ -1440,8 +1453,13 @@ static void D3D11SetColorSpace(vout_display_t *vd)
                 {
                     if (color_spaces[i].dxgi == desc1.ColorSpace)
                     {
-                        best = i;
-                        csp = &color_spaces[i];
+                        if (!canHandleConversion(&color_spaces[best], &color_spaces[i]))
+                            msg_Warn(vd, "Can't handle conversion to screen format %s", color_spaces[i].name);
+                        else
+                        {
+                            best = i;
+                            csp = &color_spaces[i];
+                        }
                         break;
                     }
                 }



More information about the vlc-commits mailing list