[vlc-devel] [PATCH] d3d11va: don't try to decode 4K H264 on the xbox

Steve Lhomme robux4 at videolabs.io
Tue Jan 3 10:34:56 CET 2017


The hardware cannot handle it.
---
 modules/codec/avcodec/d3d11va.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index b139b8a..168e1ac 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -947,6 +947,35 @@ static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *
     return VLC_EGENERIC;
 }
 
+#if VLC_WINSTORE_APP
+static bool isXboxHardware(directx_sys_t *dx_sys)
+{
+    IDXGIDevice *pDXGIDevice = NULL;
+    HRESULT hr = ID3D11Device_QueryInterface((ID3D11Device*)dx_sys->d3ddev, &IID_IDXGIDevice, (void **)&pDXGIDevice);
+    if (FAILED(hr)) {
+        return false;
+    }
+
+    IDXGIAdapter *p_adapter;
+    hr = IDXGIDevice_GetAdapter(pDXGIDevice, &p_adapter);
+    if (FAILED(hr)) {
+        IDXGIDevice_Release(pDXGIDevice);
+        return false;
+    }
+
+    bool result = false;
+    DXGI_ADAPTER_DESC adapterDesc;
+    if (SUCCEEDED(IDXGIAdapter_GetDesc(p_adapter, &adapterDesc))) {
+        if (!wcscmp(L"ROOT\SraKmd\0000", adapterDesc.Description))
+            result = true;
+    }
+
+    IDXGIAdapter_Release(p_adapter);
+    IDXGIDevice_Release(pDXGIDevice);
+    return result;
+}
+#endif
+
 /**
  * It creates a Direct3D11 decoder using the given video format
  */
@@ -963,6 +992,17 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id, const video_forma
         ID3D10Multithread_Release(pMultithread);
     }
 
+#if VLC_WINSTORE_APP
+    if (codec_id == AV_CODEC_ID_H264 && 
+        (dx_sys->surface_width > 2304 || dx_sys->surface_height > 2304) &&
+        isXboxHardware(dx_sys))
+    {
+        msg_Warn(va, "%dx%d resolution not supported by your hardware", dx_sys->surface_width, dx_sys->surface_height);
+        dx_sys->surface_count = 0;
+        return VLC_EGENERIC;
+    }
+#endif
+
     D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
     ZeroMemory(&viewDesc, sizeof(viewDesc));
     viewDesc.DecodeProfile = dx_sys->input;
-- 
2.10.2



More information about the vlc-devel mailing list