[vlc-commits] dxgi_fmt: use a generic way to get the vendor string

Steve Lhomme git at videolan.org
Mon Dec 4 01:17:07 CET 2017


vlc/vlc-3.0 | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Fri Dec  1 09:55:13 2017 +0100| [6e566fd92bba619c747cefb514d4f636113cffd1] | committer: Jean-Baptiste Kempf

dxgi_fmt: use a generic way to get the vendor string

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit eb10517a23e3dd1e885375977577d38bd5118709)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=6e566fd92bba619c747cefb514d4f636113cffd1
---

 modules/codec/Makefile.am       |  2 +-
 modules/codec/avcodec/d3d11va.c | 22 +---------------------
 modules/codec/avcodec/dxva2.c   | 24 ++----------------------
 modules/video_chroma/dxgi_fmt.c | 23 +++++++++++++++++++++++
 modules/video_chroma/dxgi_fmt.h |  1 +
 5 files changed, 28 insertions(+), 44 deletions(-)

diff --git a/modules/codec/Makefile.am b/modules/codec/Makefile.am
index 9f710760d7..6edca6dd26 100644
--- a/modules/codec/Makefile.am
+++ b/modules/codec/Makefile.am
@@ -416,7 +416,7 @@ codec_LTLIBRARIES += libvaapi_plugin.la
 endif
 
 libd3d9_common_la_SOURCES = video_chroma/d3d9_fmt.c video_chroma/d3d9_fmt.h \
-	video_chroma/dxgi_fmt.h
+	video_chroma/dxgi_fmt.c video_chroma/dxgi_fmt.h
 libd3d9_common_la_LDFLAGS = -static
 if HAVE_WIN32_DESKTOP
 noinst_LTLIBRARIES += libd3d9_common.la
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 99305e07aa..333cd641f5 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -447,18 +447,6 @@ static void D3dDestroyDevice(vlc_va_t *va)
  */
 static char *DxDescribe(vlc_va_sys_t *sys)
 {
-    static const struct {
-        unsigned id;
-        char     name[32];
-    } vendors [] = {
-        { GPU_MANUFACTURER_AMD,      "ATI"         },
-        { GPU_MANUFACTURER_NVIDIA,   "NVIDIA"      },
-        { GPU_MANUFACTURER_VIA,      "VIA"         },
-        { GPU_MANUFACTURER_INTEL,    "Intel"       },
-        { GPU_MANUFACTURER_S3,       "S3 Graphics" },
-        { GPU_MANUFACTURER_QUALCOMM, "Qualcomm"    },
-        { 0, "" }
-    };
 
     IDXGIAdapter *p_adapter = D3D11DeviceAdapter(sys->d3d_dev.d3ddevice);
     if (!p_adapter) {
@@ -468,20 +456,12 @@ static char *DxDescribe(vlc_va_sys_t *sys)
     char *description = NULL;
     DXGI_ADAPTER_DESC adapterDesc;
     if (SUCCEEDED(IDXGIAdapter_GetDesc(p_adapter, &adapterDesc))) {
-        const char *vendor = "Unknown";
-        for (int i = 0; vendors[i].id != 0; i++) {
-            if (vendors[i].id == adapterDesc.VendorId) {
-                vendor = vendors[i].name;
-                break;
-            }
-        }
-
         char *utfdesc = FromWide(adapterDesc.Description);
         if (likely(utfdesc!=NULL))
         {
             if (asprintf(&description, "D3D11VA (%s, vendor %u(%s), device %u, revision %u)",
                          utfdesc,
-                         adapterDesc.VendorId, vendor, adapterDesc.DeviceId, adapterDesc.Revision) < 0)
+                         adapterDesc.VendorId, DxgiVendorStr(adapterDesc.VendorId), adapterDesc.DeviceId, adapterDesc.Revision) < 0)
                 description = NULL;
             free(utfdesc);
         }
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index ef6b8a2a7e..b39c47e1cf 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -368,36 +368,16 @@ static void D3dDestroyDevice(vlc_va_t *va)
  */
 static char *DxDescribe(vlc_va_sys_t *sys)
 {
-    static const struct {
-        unsigned id;
-        char     name[32];
-    } vendors [] = {
-        { 0x1002, "ATI" },
-        { 0x10DE, "NVIDIA" },
-        { 0x1106, "VIA" },
-        { 0x8086, "Intel" },
-        { 0x5333, "S3 Graphics" },
-        { 0, "" }
-    };
-
     D3DADAPTER_IDENTIFIER9 d3dai;
     if (FAILED(IDirect3D9_GetAdapterIdentifier(sys->hd3d.obj,
                                                sys->d3d_dev.adapterId, 0, &d3dai))) {
         return NULL;
     }
 
-    const char *vendor = "Unknown";
-    for (int i = 0; vendors[i].id != 0; i++) {
-        if (vendors[i].id == d3dai.VendorId) {
-            vendor = vendors[i].name;
-            break;
-        }
-    }
-
     char *description;
-    if (asprintf(&description, "DXVA2 (%.*s, vendor %lu(%s), device %lu, revision %lu)",
+    if (asprintf(&description, "DXVA2 (%.*s, vendor %s(%lu), device %lu, revision %lu)",
                  (int)sizeof(d3dai.Description), d3dai.Description,
-                 d3dai.VendorId, vendor, d3dai.DeviceId, d3dai.Revision) < 0)
+                 DxgiVendorStr(d3dai.VendorId), d3dai.VendorId, d3dai.DeviceId, d3dai.Revision) < 0)
         return NULL;
     return description;
 }
diff --git a/modules/video_chroma/dxgi_fmt.c b/modules/video_chroma/dxgi_fmt.c
index 9209b1d66d..1a0ba9e044 100644
--- a/modules/video_chroma/dxgi_fmt.c
+++ b/modules/video_chroma/dxgi_fmt.c
@@ -124,3 +124,26 @@ void DxgiFormatMask(DXGI_FORMAT format, video_format_t *fmt)
         fmt->i_bmask = 0xff000000;
     }
 }
+
+const char *DxgiVendorStr(int gpu_vendor)
+{
+    static const struct {
+        unsigned   id;
+        const char name[32];
+    } vendors [] = {
+        { GPU_MANUFACTURER_AMD,      "ATI"         },
+        { GPU_MANUFACTURER_NVIDIA,   "NVIDIA"      },
+        { GPU_MANUFACTURER_VIA,      "VIA"         },
+        { GPU_MANUFACTURER_INTEL,    "Intel"       },
+        { GPU_MANUFACTURER_S3,       "S3 Graphics" },
+        { GPU_MANUFACTURER_QUALCOMM, "Qualcomm"    },
+        { 0,                         "Unknown" }
+    };
+
+    int i = 0;
+    for (i = 0; vendors[i].id != 0; i++) {
+        if (vendors[i].id == gpu_vendor)
+            break;
+    }
+    return vendors[i].name;
+}
diff --git a/modules/video_chroma/dxgi_fmt.h b/modules/video_chroma/dxgi_fmt.h
index 71dd65cdf2..71282655b3 100644
--- a/modules/video_chroma/dxgi_fmt.h
+++ b/modules/video_chroma/dxgi_fmt.h
@@ -53,5 +53,6 @@ const char *DxgiFormatToStr(DXGI_FORMAT format);
 vlc_fourcc_t DxgiFormatFourcc(DXGI_FORMAT format);
 const d3d_format_t *GetRenderFormatList(void);
 void DxgiFormatMask(DXGI_FORMAT format, video_format_t *);
+const char *DxgiVendorStr(int gpu_vendor);
 
 #endif /* include-guard */



More information about the vlc-commits mailing list