浏览代码

Merge pull request #1785 from brittneysclark/fix_qsv_crash

obs-qsv: Fix QSV failing with new DCH drivers
Jim 6 年之前
父节点
当前提交
ce0d3f106e
共有 25 个文件被更改,包括 1396 次插入533 次删除
  1. 27 11
      plugins/obs-qsv11/libmfx/include/mfx_dispatcher.h
  2. 5 2
      plugins/obs-qsv11/libmfx/include/mfx_dispatcher_defs.h
  3. 26 3
      plugins/obs-qsv11/libmfx/include/mfx_dxva2_device.h
  4. 10 1
      plugins/obs-qsv11/libmfx/include/mfx_exposed_functions_list.h
  5. 26 11
      plugins/obs-qsv11/libmfx/include/mfx_library_iterator.h
  6. 4 2
      plugins/obs-qsv11/libmfx/include/mfx_load_plugin.h
  7. 3 12
      plugins/obs-qsv11/libmfx/include/mfx_plugin_hive.h
  8. 28 5
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxcommon.h
  9. 16 2
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxdefs.h
  10. 3 1
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxenc.h
  11. 11 7
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxjpeg.h
  12. 10 4
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxpak.h
  13. 37 24
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxplugin++.h
  14. 40 35
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxplugin.h
  15. 590 99
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxstructures.h
  16. 4 2
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxvideo++.h
  17. 2 4
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxvideo.h
  18. 283 166
      plugins/obs-qsv11/libmfx/src/main.cpp
  19. 34 36
      plugins/obs-qsv11/libmfx/src/mfx_dispatcher.cpp
  20. 30 11
      plugins/obs-qsv11/libmfx/src/mfx_dxva2_device.cpp
  21. 113 23
      plugins/obs-qsv11/libmfx/src/mfx_library_iterator.cpp
  22. 12 5
      plugins/obs-qsv11/libmfx/src/mfx_load_dll.cpp
  23. 66 61
      plugins/obs-qsv11/libmfx/src/mfx_load_plugin.cpp
  24. 14 4
      plugins/obs-qsv11/libmfx/src/mfx_plugin_hive.cpp
  25. 2 2
      plugins/obs-qsv11/libmfx/src/mfx_win_reg_key.cpp

+ 27 - 11
plugins/obs-qsv11/libmfx/include/mfx_dispatcher.h

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2012-2015 Intel Corporation.  All rights reserved.
+Copyright (C) 2012-2017 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -40,6 +40,7 @@ File Name: mfx_dispatcher.h
 #include "mfxenc.h"
 #include "mfxpak.h"
 
+#define INTEL_VENDOR_ID 0x8086
 
 mfxStatus MFXQueryVersion(mfxSession session, mfxVersion *version);
 
@@ -75,6 +76,16 @@ enum eFunc
     eVideoFuncTotal
 };
 
+enum ePluginFunc
+{
+    eMFXVideoUSER_Load,
+    eMFXVideoUSER_LoadByPath,
+    eMFXVideoUSER_UnLoad,
+    eMFXAudioUSER_Load,
+    eMFXAudioUSER_UnLoad,
+    ePluginFuncTotal
+};
+
 enum eAudioFunc
 {
     eFakeAudioEnum = eMFXGetPriority,
@@ -111,8 +122,21 @@ enum
     MFX_DISPATCHER_VERSION_MINOR = 2
 };
 
+struct _mfxSession
+{
+    // A real handle from MFX engine passed to a called function
+    mfxSession session;
+
+    mfxFunctionPointer callTable[eVideoFuncTotal];
+    mfxFunctionPointer callPlugInsTable[ePluginFuncTotal];
+    mfxFunctionPointer callAudioTable[eAudioFuncTotal];
+
+    // Current library's implementation (exact implementation)
+    mfxIMPL impl;
+};
+
 // declare a dispatcher's handle
-struct MFX_DISP_HANDLE
+struct MFX_DISP_HANDLE : public _mfxSession
 {
     // Default constructor
     MFX_DISP_HANDLE(const mfxVersion requiredVersion);
@@ -133,15 +157,11 @@ struct MFX_DISP_HANDLE
 
     // Library's implementation type (hardware or software)
     eMfxImplType implType;
-    // Current library's implementation (exact implementation)
-    mfxIMPL impl;
     // Current library's VIA interface
     mfxIMPL implInterface;
     // Dispatcher's version. If version is 1.1 or lower, then old dispatcher's
     // architecture is used. Otherwise it means current dispatcher's version.
     mfxVersion dispVersion;
-    // A real handle passed to a called function
-    mfxSession session;
     // Required API version of session initialized
     const mfxVersion apiVersion;
     // Actual library API version
@@ -159,14 +179,10 @@ struct MFX_DISP_HANDLE
     MFX::MFXPluginStorage pluginHive;
     MFX::MFXPluginFactory pluginFactory;
 
-    // function call table
-    mfxFunctionPointer callTable[eVideoFuncTotal];
-    mfxFunctionPointer callAudioTable[eAudioFuncTotal];
-
 private:
     // Declare assignment operator and copy constructor to prevent occasional assignment
     MFX_DISP_HANDLE(const MFX_DISP_HANDLE &);
-    MFX_DISP_HANDLE & operator = (const MFX_DISP_HANDLE &);    
+    MFX_DISP_HANDLE & operator = (const MFX_DISP_HANDLE &);
 
 };
 

+ 5 - 2
plugins/obs-qsv11/libmfx/include/mfx_dispatcher_defs.h

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2013-2015 Intel Corporation.  All rights reserved.
+Copyright (C) 2013-2017 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -37,6 +37,9 @@ File Name: mfx_dispatcher_defs.h
 #include <string.h>
 #endif
 
+#define MAX_PLUGIN_PATH 4096
+#define MAX_PLUGIN_NAME 4096
+
 #if defined(_WIN32) || defined(_WIN64)
 typedef wchar_t  msdk_disp_char;
 #define MSDK2WIDE(x) x
@@ -73,7 +76,7 @@ inline std::wstring getWideString(const char * string)
 
 #endif
 
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(_WIN32) && !defined(_WIN64)
 #define  sscanf_s  sscanf
 #define  swscanf_s swscanf
 #endif

+ 26 - 3
plugins/obs-qsv11/libmfx/include/mfx_dxva2_device.h

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2012-2013 Intel Corporation.  All rights reserved.
+Copyright (C) 2012-2017 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -33,6 +33,24 @@ File Name: mfx_dxva2_device.h
 
 #if defined(_WIN32) || defined(_WIN64)
 #include <windows.h>
+
+#define TOSTRING(L) #L
+#define STRINGIFY(L) TOSTRING(L)
+
+#if defined(MEDIASDK_UWP_LOADER) || defined(MEDIASDK_UWP_PROCTABLE)
+    #if defined(MFX_D3D9_ENABLED) && !defined(MFX_FORCE_D3D9_ENABLED)
+        #undef MFX_D3D9_ENABLED
+        // if you really like to use D3D9 from intel_gfx_api-x64/x86.dll, use MFX_FORCE_D3D9_ENABLED
+        #pragma message("\n\nATTENTION:\nin file\n\t" __FILE__ " (" STRINGIFY(__LINE__) "):\nUsing of D3D9 disabled for UWP!\n\n")
+    #endif
+    #if defined(MFX_FORCE_D3D9_ENABLED)
+        #define MFX_D3D9_ENABLED
+    #endif
+#else
+    #define MFX_D3D9_ENABLED
+    #pragma message("\n\nATTENTION:\nin file\n\t" __FILE__ " (" STRINGIFY(__LINE__) "):\nUsing of D3D9 enabled!\n\n")
+#endif
+
 #endif // #if defined(_WIN32) || defined(_WIN64)
 
 #include <mfxdefs.h>
@@ -43,7 +61,7 @@ File Name: mfx_dxva2_device.h
 #define DXVA2DEVICE_TRACE_OPERATION(expr) expr;
 #else
 #define DXVA2DEVICE_TRACE(expr)
-#define DXVA2DEVICE_TRACE_OPERATION(expr) 
+#define DXVA2DEVICE_TRACE_OPERATION(expr)
 #endif
 
 namespace MFX
@@ -106,7 +124,10 @@ private:
     void operator=(const DXDevice &);
 };
 
+
 #if defined(_WIN32) || defined(_WIN64)
+
+#ifdef MFX_D3D9_ENABLED
 class D3D9Device : public DXDevice
 {
 public:
@@ -132,6 +153,7 @@ protected:
     void *m_pD3D9Ex;
 
 };
+#endif // MFX_D3D9_ENABLED
 
 class DXGI1Device : public DXDevice
 {
@@ -186,9 +208,10 @@ public:
 
 protected:
 
+#ifdef MFX_D3D9_ENABLED
     // Get vendor & device IDs by alternative way (D3D9 in Remote Desktop sessions)
     void UseAlternativeWay(const D3D9Device *pD3D9Device);
-
+#endif // MFX_D3D9_ENABLED
     // Number of adapters available
     mfxU32 m_numAdapters;
 

+ 10 - 1
plugins/obs-qsv11/libmfx/include/mfx_exposed_functions_list.h

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2012-2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2012-2016 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -139,4 +139,13 @@ FUNCTION(mfxStatus, MFXVideoPAK_ProcessFrameAsync, (mfxSession session, mfxPAKIn
 // FUNCTION(mfxStatus, MFXInitEx, (mfxInitParam par, mfxSession session), (par, session))
 FUNCTION(mfxStatus, MFXDoWork, (mfxSession session), (session))
 
+#undef API_VERSION
+
+#define API_VERSION {{19, 1}}
+
+FUNCTION(mfxStatus, MFXVideoENC_GetVideoParam, (mfxSession session, mfxVideoParam *par), (session, par))
+FUNCTION(mfxStatus, MFXVideoPAK_GetVideoParam, (mfxSession session, mfxVideoParam *par), (session, par))
+FUNCTION(mfxStatus, MFXVideoCORE_QueryPlatform, (mfxSession session, mfxPlatform* platform), (session, platform))
+FUNCTION(mfxStatus, MFXVideoUSER_GetPlugin, (mfxSession session, mfxU32 type, mfxPlugin *par), (session, type, par))
+
 #undef API_VERSION

+ 26 - 11
plugins/obs-qsv11/libmfx/include/mfx_library_iterator.h

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2012-2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2012-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -33,7 +33,11 @@ File Name: mfx_library_iterator.h
 
 
 #include <mfxvideo.h>
+
+#if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
 #include "mfx_win_reg_key.h"
+#endif
+
 #include "mfx_dispatcher.h"
 
 #if !defined(_WIN32) && !defined(_WIN64)
@@ -71,15 +75,21 @@ enum
     MFX_CURRENT_USER_KEY        = 0,
     MFX_LOCAL_MACHINE_KEY       = 1,
     MFX_APP_FOLDER              = 2,
-
+#if defined(MEDIASDK_USE_REGISTRY) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
+    MFX_PATH_MSDK_FOLDER = 3,
     MFX_STORAGE_ID_FIRST    = MFX_CURRENT_USER_KEY,
-    MFX_STORAGE_ID_LAST     = MFX_LOCAL_MACHINE_KEY
+    MFX_STORAGE_ID_LAST     = MFX_PATH_MSDK_FOLDER
+#else
+    MFX_PATH_MSDK_FOLDER = 3,
+    MFX_STORAGE_ID_FIRST = MFX_PATH_MSDK_FOLDER,
+    MFX_STORAGE_ID_LAST = MFX_PATH_MSDK_FOLDER
+#endif // !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
 };
 #else
 enum
 {
     MFX_UNKNOWN_KEY     = -1,
-    MFX_STORAGE_ID_OPT  = 0, // storage is: /opt/intel
+    MFX_STORAGE_ID_OPT  = 0, // storage is: MFX_MODULES_DIR
     MFX_APP_FOLDER      = 1,
 
     MFX_STORAGE_ID_FIRST   =  MFX_STORAGE_ID_OPT,
@@ -91,6 +101,8 @@ enum
 // Params: adapterNum - in, pImplInterface - in/out, pVendorID - out, pDeviceID - out
 mfxStatus SelectImplementationType(const mfxU32 adapterNum, mfxIMPL *pImplInterface, mfxU32 *pVendorID, mfxU32 *pDeviceID);
 
+const mfxU32 msdk_disp_path_len = 1024;
+
 class MFXLibraryIterator
 {
 public:
@@ -103,11 +115,11 @@ public:
     mfxStatus Init(eMfxImplType implType, mfxIMPL implInterface, const mfxU32 adapterNum, int storageID);
 
     // Get the next library path
-    mfxStatus SelectDLLVersion(msdk_disp_char *pPath, size_t pathSize, 
+    mfxStatus SelectDLLVersion(msdk_disp_char *pPath, size_t pathSize,
                                eMfxImplType *pImplType, mfxVersion minVersion);
 
     // Return interface type on which Intel adapter was found (if any): D3D9 or D3D11
-    mfxIMPL GetImplementationType(); 
+    mfxIMPL GetImplementationType();
 
     // Retrun registry subkey name on which dll was selected after sucesfull call to selectDllVesion
     bool GetSubKeyName(msdk_disp_char *subKeyName, size_t length) const;
@@ -124,17 +136,20 @@ protected:
     mfxStatus InitFolder(eMfxImplType implType, mfxIMPL implInterface, const mfxU32 adapterNum, const msdk_disp_char * path);
 
 
-    eMfxImplType m_implType;                                    // Required library implementation 
+    eMfxImplType m_implType;                                    // Required library implementation
     mfxIMPL m_implInterface;                                    // Required interface (D3D9, D3D11)
 
     mfxU32 m_vendorID;                                          // (mfxU32) property of used graphic card
     mfxU32 m_deviceID;                                          // (mfxU32) property of used graphic card
     bool   m_bIsSubKeyValid;
-    wchar_t m_SubKeyName[MFX_MAX_REGISTRY_KEY_NAME];            // registry subkey for selected module loaded 
+    wchar_t m_SubKeyName[MFX_MAX_REGISTRY_KEY_NAME];            // registry subkey for selected module loaded
     int    m_StorageID;
-    
+
 #if defined(_WIN32) || defined(_WIN64)
-    WinRegKey m_baseRegKey;                                     // (WinRegKey) main registry key    
+
+#if defined(MEDIASDK_USE_REGISTRY) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
+    WinRegKey m_baseRegKey;                                     // (WinRegKey) main registry key
+#endif
 
     mfxU32 m_lastLibIndex;                                      // (mfxU32) index of previously returned library
     mfxU32 m_lastLibMerit;                                      // (mfxU32) merit of previously returned library
@@ -148,7 +163,7 @@ protected:
     struct mfx_libs*          m_libs;
 #endif // #if defined(_WIN32) || defined(_WIN64)
 
-    msdk_disp_char  m_path[260];
+    msdk_disp_char  m_path[msdk_disp_path_len];
 
 private:
     // unimplemented by intent to make this class non-copyable

+ 4 - 2
plugins/obs-qsv11/libmfx/include/mfx_load_plugin.h

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2013-2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2013-2016 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -60,7 +60,9 @@ namespace MFX
             mfxPluginParam plgParams;
             PluginModule module;
             mfxPlugin plugin;
-            FactoryRecord () {}
+            FactoryRecord ()
+                : plugin()
+            {}
             FactoryRecord(const mfxPluginParam &plgParams,
                           PluginModule &module,
                           mfxPlugin plugin) 

+ 3 - 12
plugins/obs-qsv11/libmfx/include/mfx_plugin_hive.h

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2013-2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2013-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -42,16 +42,6 @@ struct MFX_DISP_HANDLE;
 
 namespace MFX {
 
-    enum 
-    {
-        MAX_PLUGIN_PATH = 4096
-    };
-    
-    enum
-    {
-        MAX_PLUGIN_NAME = 4096
-    };
-
     inline bool operator == (const mfxPluginUID &lhs, const mfxPluginUID & rhs) 
     {
         return !memcmp(lhs.Data, rhs.Data, sizeof(mfxPluginUID));
@@ -108,6 +98,7 @@ namespace MFX {
         MFXPluginsInHive(int mfxStorageID, const msdk_disp_char *msdkLibSubKey, mfxVersion currentAPIVersion);
     };
 
+#if defined(MEDIASDK_USE_CFGFILES) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
     //plugins are loaded from FS close to executable
     class MFXPluginsInFS : public MFXPluginStorageBase
     {
@@ -119,7 +110,7 @@ namespace MFX {
         bool ParseFile(FILE * f, PluginDescriptionRecord & des);
         bool ParseKVPair( msdk_disp_char *key, msdk_disp_char * value, PluginDescriptionRecord & des);
     };
-
+#endif //#if defined(MEDIASDK_USE_CFGFILES) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
 
     //plugins are loaded from FS close to Runtime library
     class MFXDefaultPlugins : public MFXPluginStorageBase

+ 28 - 5
plugins/obs-qsv11/libmfx/include/msdk/include/mfxcommon.h

@@ -1,6 +1,6 @@
 /*******************************************************************************
 
-Copyright (C) 2013-2015 Intel Corporation.  All rights reserved.
+Copyright (C) 2013-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -61,15 +61,14 @@ enum  {
     MFX_IMPL_HARDWARE2    = 0x0005,  /* Hardware accelerated implementation (2nd device) */
     MFX_IMPL_HARDWARE3    = 0x0006,  /* Hardware accelerated implementation (3rd device) */
     MFX_IMPL_HARDWARE4    = 0x0007,  /* Hardware accelerated implementation (4th device) */
-    MFX_IMPL_RUNTIME      = 0x0008, 
-
+    MFX_IMPL_RUNTIME      = 0x0008,
     MFX_IMPL_VIA_ANY      = 0x0100,
     MFX_IMPL_VIA_D3D9     = 0x0200,
     MFX_IMPL_VIA_D3D11    = 0x0300,
     MFX_IMPL_VIA_VAAPI    = 0x0400,
 
-    MFX_IMPL_AUDIO        = 0x8000,
-     
+    MFX_IMPL_AUDIO                     = 0x8000,
+
     MFX_IMPL_UNSUPPORTED  = 0x0000  /* One of the MFXQueryIMPL returns */
 };
 
@@ -151,6 +150,30 @@ typedef struct {
     mfxU16       reserved[55];
 } mfxExtThreadsParam;
 
+/* PlatformCodeName */
+enum {
+    MFX_PLATFORM_UNKNOWN        = 0,
+    MFX_PLATFORM_SANDYBRIDGE    = 1,
+    MFX_PLATFORM_IVYBRIDGE      = 2,
+    MFX_PLATFORM_HASWELL        = 3,
+    MFX_PLATFORM_BAYTRAIL       = 4,
+    MFX_PLATFORM_BROADWELL      = 5,
+    MFX_PLATFORM_CHERRYTRAIL    = 6,
+    MFX_PLATFORM_SKYLAKE        = 7,
+    MFX_PLATFORM_APOLLOLAKE     = 8,
+    MFX_PLATFORM_KABYLAKE       = 9,
+    MFX_PLATFORM_GEMINILAKE     = 10,
+    MFX_PLATFORM_COFFEELAKE     = 11,
+    MFX_PLATFORM_CANNONLAKE     = 20,
+    MFX_PLATFORM_ICELAKE = 30,
+};
+
+typedef struct {
+    mfxU16 CodeName;
+    mfxU16 DeviceId;
+    mfxU16 reserved[14];
+} mfxPlatform;
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

+ 16 - 2
plugins/obs-qsv11/libmfx/include/msdk/include/mfxdefs.h

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2007-2015 Intel Corporation.  All rights reserved.
+Copyright (C) 2007-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,15 @@ File Name: mfxdefs.h
 #ifndef __MFXDEFS_H__
 #define __MFXDEFS_H__
 
+#define MFX_VERSION_MAJOR 1
+#define MFX_VERSION_MINOR 27
+
+#define MFX_VERSION_NEXT 1028
+
+#ifndef MFX_VERSION
+#define MFX_VERSION (MFX_VERSION_MAJOR * 1000 + MFX_VERSION_MINOR)
+#endif
+
 #ifdef __cplusplus
 extern "C"
 {
@@ -118,6 +127,8 @@ typedef enum
     MFX_ERR_MORE_BITSTREAM              = -18,  /* expect more bitstream buffers at output */
     MFX_ERR_INCOMPATIBLE_AUDIO_PARAM    = -19,  /* incompatible audio parameters */
     MFX_ERR_INVALID_AUDIO_PARAM         = -20,  /* invalid audio parameters */
+    MFX_ERR_GPU_HANG                    = -21,  /* device operation failure caused by GPU hang */
+    MFX_ERR_REALLOC_SURFACE             = -22,  /* bigger output surface required */
 
     /* warnings >0 */
     MFX_WRN_IN_EXECUTION                = 1,    /* the previous asynchronous operation is in execution */
@@ -133,7 +144,10 @@ typedef enum
     /* threading statuses */
     MFX_TASK_DONE = MFX_ERR_NONE,               /* task has been completed */
     MFX_TASK_WORKING                    = 8,    /* there is some more work to do */
-    MFX_TASK_BUSY                       = 9     /* task is waiting for resources */
+    MFX_TASK_BUSY                       = 9,    /* task is waiting for resources */
+
+    /* plug-in statuses */
+    MFX_ERR_MORE_DATA_SUBMIT_TASK       = -10000, /* return MFX_ERR_MORE_DATA but submit internal asynchronous task */
 
 } mfxStatus;
 

+ 3 - 1
plugins/obs-qsv11/libmfx/include/msdk/include/mfxenc.h

@@ -1,6 +1,6 @@
 /******************************************************************************* *\
 
-Copyright (C) 2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2014-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -51,6 +51,7 @@ struct _mfxENCInput{
     mfxU16  NumExtParam;
     mfxExtBuffer    **ExtParam;
 } ;
+
 typedef struct _mfxENCOutput mfxENCOutput;
 struct _mfxENCOutput{
     mfxU32  reserved[32];
@@ -70,6 +71,7 @@ mfxStatus MFX_CDECL MFXVideoENC_Close(mfxSession session);
 
 mfxStatus MFX_CDECL MFXVideoENC_ProcessFrameAsync(mfxSession session, mfxENCInput *in, mfxENCOutput *out, mfxSyncPoint *syncp);
 
+mfxStatus MFX_CDECL MFXVideoENC_GetVideoParam(mfxSession session, mfxVideoParam *par);
 
 #ifdef __cplusplus
 } // extern "C"

+ 11 - 7
plugins/obs-qsv11/libmfx/include/msdk/include/mfxjpeg.h

@@ -1,6 +1,6 @@
 /******************************************************************************* *\
 
-Copyright (C) 2010-2013 Intel Corporation.  All rights reserved.
+Copyright (C) 2010-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -57,22 +57,26 @@ enum
 };
 
 enum {
-    MFX_EXTBUFF_JPEG_QT     =   MFX_MAKEFOURCC('J','P','G','Q'),
-    MFX_EXTBUFF_JPEG_HUFFMAN     =   MFX_MAKEFOURCC('J','P','G','H')
+    MFX_EXTBUFF_JPEG_QT      = MFX_MAKEFOURCC('J','P','G','Q'),
+    MFX_EXTBUFF_JPEG_HUFFMAN = MFX_MAKEFOURCC('J','P','G','H')
 };
 
 enum {
     MFX_JPEG_COLORFORMAT_UNKNOWN = 0,
-    MFX_JPEG_COLORFORMAT_YCbCr = 1,
-    MFX_JPEG_COLORFORMAT_RGB = 2
+    MFX_JPEG_COLORFORMAT_YCbCr   = 1,
+    MFX_JPEG_COLORFORMAT_RGB     = 2
 };
 
 enum {
-    MFX_SCANTYPE_UNKNOWN = 0,
-    MFX_SCANTYPE_INTERLEAVED = 1,
+    MFX_SCANTYPE_UNKNOWN        = 0,
+    MFX_SCANTYPE_INTERLEAVED    = 1,
     MFX_SCANTYPE_NONINTERLEAVED = 2
 };
 
+enum {
+    MFX_CHROMAFORMAT_JPEG_SAMPLING = 6
+};
+
 typedef struct {
     mfxExtBuffer    Header;
 

+ 10 - 4
plugins/obs-qsv11/libmfx/include/msdk/include/mfxpak.h

@@ -1,6 +1,6 @@
 /******************************************************************************* *\
 
-Copyright (C) 2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2014-2017 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -38,7 +38,7 @@ extern "C"
 #endif /* __cplusplus */
 
 typedef struct {
-    mfxU32  reserved[32];
+    mfxU16 reserved[32];
 
     mfxFrameSurface1 *InSurface;
 
@@ -49,10 +49,15 @@ typedef struct {
 
     mfxU16  NumExtParam;
     mfxExtBuffer    **ExtParam;
+
+    mfxU16 NumPayload;
+    mfxPayload      **Payload;
 } mfxPAKInput;
 
 typedef struct {
-    mfxBitstream     *Bs; 
+    mfxU16  reserved[32];
+
+    mfxBitstream     *Bs;
 
     mfxFrameSurface1 *OutSurface;
 
@@ -62,13 +67,14 @@ typedef struct {
 
 typedef struct _mfxSession *mfxSession;
 mfxStatus MFX_CDECL MFXVideoPAK_Query(mfxSession session, mfxVideoParam *in, mfxVideoParam *out);
-mfxStatus MFX_CDECL MFXVideoPAK_QueryIOSurf(mfxSession session, mfxVideoParam *par, mfxFrameAllocRequest *request);
+mfxStatus MFX_CDECL MFXVideoPAK_QueryIOSurf(mfxSession session, mfxVideoParam *par, mfxFrameAllocRequest request[2]);
 mfxStatus MFX_CDECL MFXVideoPAK_Init(mfxSession session, mfxVideoParam *par);
 mfxStatus MFX_CDECL MFXVideoPAK_Reset(mfxSession session, mfxVideoParam *par);
 mfxStatus MFX_CDECL MFXVideoPAK_Close(mfxSession session);
 
 mfxStatus MFX_CDECL MFXVideoPAK_ProcessFrameAsync(mfxSession session, mfxPAKInput *in, mfxPAKOutput *out,  mfxSyncPoint *syncp);
 
+mfxStatus MFX_CDECL MFXVideoPAK_GetVideoParam(mfxSession session, mfxVideoParam *par);
 
 #ifdef __cplusplus
 } // extern "C"

+ 37 - 24
plugins/obs-qsv11/libmfx/include/msdk/include/mfxplugin++.h

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2007-2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2007-2016 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -156,7 +156,7 @@ struct MFXGenericPlugin : MFXPlugin
     virtual mfxStatus Submit(const mfxHDL *in, mfxU32 in_num, const mfxHDL *out, mfxU32 out_num, mfxThreadTask *task) = 0;
 };
 
-//decoder plugins may only support this interface 
+//decoder plugins may only support this interface
 struct MFXDecoderPlugin : MFXCodecPlugin
 {
     virtual mfxStatus DecodeHeader(mfxBitstream *bs, mfxVideoParam *par) = 0;
@@ -164,7 +164,7 @@ struct MFXDecoderPlugin : MFXCodecPlugin
     virtual mfxStatus DecodeFrameSubmit(mfxBitstream *bs, mfxFrameSurface1 *surface_work, mfxFrameSurface1 **surface_out,  mfxThreadTask *task) = 0;
 };
 
-//audio decoder plugins may only support this interface 
+//audio decoder plugins may only support this interface
 struct MFXAudioDecoderPlugin : MFXAudioCodecPlugin
 {
     virtual mfxStatus DecodeHeader(mfxBitstream *bs, mfxAudioParam *par) = 0;
@@ -172,19 +172,19 @@ struct MFXAudioDecoderPlugin : MFXAudioCodecPlugin
     virtual mfxStatus DecodeFrameSubmit(mfxBitstream *in, mfxAudioFrame *out, mfxThreadTask *task) = 0;
 };
 
-//encoder plugins may only support this interface 
+//encoder plugins may only support this interface
 struct MFXEncoderPlugin : MFXCodecPlugin
 {
     virtual mfxStatus EncodeFrameSubmit(mfxEncodeCtrl *ctrl, mfxFrameSurface1 *surface, mfxBitstream *bs, mfxThreadTask *task) = 0;
 };
 
-//audio encoder plugins may only support this interface 
+//audio encoder plugins may only support this interface
 struct MFXAudioEncoderPlugin : MFXAudioCodecPlugin
 {
     virtual mfxStatus EncodeFrameSubmit(mfxAudioFrame *aFrame, mfxBitstream *out, mfxThreadTask *task) = 0;
 };
 
-//vpp plugins may only support this interface 
+//vpp plugins may only support this interface
 struct MFXVPPPlugin : MFXCodecPlugin
 {
     virtual mfxStatus VPPFrameSubmit(mfxFrameSurface1 *surface_in, mfxFrameSurface1 *surface_out, mfxExtVppAuxData *aux, mfxThreadTask *task) = 0;
@@ -216,7 +216,7 @@ public:
         : m_core(that.m_core) {
     }
     MFXCoreInterface &operator = (const MFXCoreInterface & that)
-    { 
+    {
         m_core = that.m_core;
         return *this;
     }
@@ -292,12 +292,23 @@ public:
     mfxFrameAllocator & FrameAllocator() {
         return m_core.FrameAllocator;
     }
-
+    mfxStatus GetFrameHandle(mfxFrameData *fd, mfxHDL *handle) {
+        if (!IsCoreSet()) {
+            return MFX_ERR_NULL_PTR;
+        }
+        return m_core.GetFrameHandle(m_core.pthis, fd, handle);
+    }
+    mfxStatus QueryPlatform(mfxPlatform *platform) {
+        if (!IsCoreSet()) {
+            return MFX_ERR_NULL_PTR;
+        }
+        return m_core.QueryPlatform(m_core.pthis, platform);
+    }
 } ;
 
 /* Class adapter between "C" structure mfxPlugin and C++ interface MFXPlugin */
 
-namespace detail 
+namespace detail
 {
     template <class T>
     class MFXPluginAdapterBase
@@ -306,11 +317,13 @@ namespace detail
         mfxPlugin m_mfxAPI;
     public:
         MFXPluginAdapterBase( T *plugin, mfxVideoCodecPlugin *pCodec = NULL)
+            : m_mfxAPI()
         {
             SetupCallbacks(plugin, pCodec);
         }
 
         MFXPluginAdapterBase( T *plugin, mfxAudioCodecPlugin *pCodec)
+            : m_mfxAPI()
         {
             SetupCallbacks(plugin, pCodec);
         }
@@ -340,19 +353,19 @@ namespace detail
     private:
 
         static mfxStatus _PluginInit(mfxHDL pthis, mfxCoreInterface *core) {
-            return reinterpret_cast<T*>(pthis)->PluginInit(core); 
+            return reinterpret_cast<T*>(pthis)->PluginInit(core);
         }
-        static mfxStatus _PluginClose(mfxHDL pthis) { 
-            return reinterpret_cast<T*>(pthis)->PluginClose(); 
+        static mfxStatus _PluginClose(mfxHDL pthis) {
+            return reinterpret_cast<T*>(pthis)->PluginClose();
         }
-        static mfxStatus _GetPluginParam(mfxHDL pthis, mfxPluginParam *par) { 
-            return reinterpret_cast<T*>(pthis)->GetPluginParam(par); 
+        static mfxStatus _GetPluginParam(mfxHDL pthis, mfxPluginParam *par) {
+            return reinterpret_cast<T*>(pthis)->GetPluginParam(par);
         }
-        static mfxStatus _Execute(mfxHDL pthis, mfxThreadTask task, mfxU32 thread_id, mfxU32 call_count) { 
-            return reinterpret_cast<T*>(pthis)->Execute(task, thread_id, call_count); 
+        static mfxStatus _Execute(mfxHDL pthis, mfxThreadTask task, mfxU32 thread_id, mfxU32 call_count) {
+            return reinterpret_cast<T*>(pthis)->Execute(task, thread_id, call_count);
         }
-        static mfxStatus _FreeResources(mfxHDL pthis, mfxThreadTask task, mfxStatus sts) { 
-            return reinterpret_cast<T*>(pthis)->FreeResources(task, sts); 
+        static mfxStatus _FreeResources(mfxHDL pthis, mfxThreadTask task, mfxStatus sts) {
+            return reinterpret_cast<T*>(pthis)->FreeResources(task, sts);
         }
     };
 
@@ -374,7 +387,7 @@ namespace detail
             m_codecPlg.Close = _Close;
             m_codecPlg.GetVideoParam = _GetVideoParam;
         }
-        MFXCodecPluginAdapterBase(const MFXCodecPluginAdapterBase<T> & that) 
+        MFXCodecPluginAdapterBase(const MFXCodecPluginAdapterBase<T> & that)
             : MFXPluginAdapterBase<T>(reinterpret_cast<T*>(that.m_mfxAPI.pthis), &m_codecPlg)
             , m_codecPlg() {
             SetupCallbacks();
@@ -432,7 +445,7 @@ namespace detail
             m_codecPlg.Close = _Close;
             m_codecPlg.GetAudioParam = _GetAudioParam;
         }
-        MFXAudioCodecPluginAdapterBase(const MFXCodecPluginAdapterBase<T> & that) 
+        MFXAudioCodecPluginAdapterBase(const MFXCodecPluginAdapterBase<T> & that)
             : MFXPluginAdapterBase<T>(reinterpret_cast<T*>(that.m_mfxAPI.pthis), &m_codecPlg)
             , m_codecPlg() {
             SetupCallbacks();
@@ -471,7 +484,7 @@ namespace detail
             return reinterpret_cast<T*>(pthis)->GetAudioParam(par);
         }
     };
-    
+
     template <class T>
     struct MFXPluginAdapterInternal{};
     template<>
@@ -494,8 +507,8 @@ namespace detail
         }
 
     private:
-        static mfxStatus _Submit(mfxHDL pthis, const mfxHDL *in, mfxU32 in_num, const mfxHDL *out, mfxU32 out_num, mfxThreadTask *task) { 
-            return reinterpret_cast<MFXGenericPlugin*>(pthis)->Submit(in, in_num, out, out_num, task); 
+        static mfxStatus _Submit(mfxHDL pthis, const mfxHDL *in, mfxU32 in_num, const mfxHDL *out, mfxU32 out_num, mfxThreadTask *task) {
+            return reinterpret_cast<MFXGenericPlugin*>(pthis)->Submit(in, in_num, out, out_num, task);
         }
     };
 
@@ -698,7 +711,7 @@ class MFXPluginAdapter
 {
 public:
     detail::MFXPluginAdapterInternal<T> m_Adapter;
-    
+
     operator  mfxPlugin () const {
         return m_Adapter.operator mfxPlugin();
     }

+ 40 - 35
plugins/obs-qsv11/libmfx/include/msdk/include/mfxplugin.h

@@ -1,6 +1,6 @@
 /******************************************************************************* *\
 
-Copyright (C) 2007-2015 Intel Corporation.  All rights reserved.
+Copyright (C) 2007-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -41,22 +41,24 @@ typedef struct {
     mfxU8  Data[16];
 } mfxPluginUID;
 
-static const mfxPluginUID  MFX_PLUGINID_HEVCD_SW     = {{0x15, 0xdd, 0x93, 0x68, 0x25, 0xad, 0x47, 0x5e, 0xa3, 0x4e, 0x35, 0xf3, 0xf5, 0x42, 0x17, 0xa6}};
-static const mfxPluginUID  MFX_PLUGINID_HEVCD_HW     = {{0x33, 0xa6, 0x1c, 0x0b, 0x4c, 0x27, 0x45, 0x4c, 0xa8, 0xd8, 0x5d, 0xde, 0x75, 0x7c, 0x6f, 0x8e}};
-static const mfxPluginUID  MFX_PLUGINID_HEVCE_SW     = {{0x2f, 0xca, 0x99, 0x74, 0x9f, 0xdb, 0x49, 0xae, 0xb1, 0x21, 0xa5, 0xb6, 0x3e, 0xf5, 0x68, 0xf7}};
-static const mfxPluginUID  MFX_PLUGINID_HEVCE_GACC   = {{0xe5, 0x40, 0x0a, 0x06, 0xc7, 0x4d, 0x41, 0xf5, 0xb1, 0x2d, 0x43, 0x0b, 0xba, 0xa2, 0x3d, 0x0b}};
-static const mfxPluginUID  MFX_PLUGINID_HEVCE_HW     = {{0x6f, 0xad, 0xc7, 0x91, 0xa0, 0xc2, 0xeb, 0x47, 0x9a, 0xb6, 0xdc, 0xd5, 0xea, 0x9d, 0xa3, 0x47}};
-static const mfxPluginUID  MFX_PLUGINID_VP8D_HW      = {{0xf6, 0x22, 0x39, 0x4d, 0x8d, 0x87, 0x45, 0x2f, 0x87, 0x8c, 0x51, 0xf2, 0xfc, 0x9b, 0x41, 0x31}};
-static const mfxPluginUID  MFX_PLUGINID_VP8E_HW      = {{0xbf, 0xfc, 0x51, 0x8c, 0xde, 0x13, 0x4d, 0xf9, 0x8a, 0x96, 0xf4, 0xcf, 0x81, 0x6c, 0x0f, 0xac}};
-static const mfxPluginUID  MFX_PLUGINID_VP9E_HW      = {{0xce, 0x44, 0xef, 0x6f, 0x1a, 0x6d, 0x22, 0x46, 0xb4, 0x12, 0xbb, 0x38, 0xd6, 0xe4, 0x51, 0x82}};
-static const mfxPluginUID  MFX_PLUGINID_VP9D_HW      = {{0xa9, 0x22, 0x39, 0x4d, 0x8d, 0x87, 0x45, 0x2f, 0x87, 0x8c, 0x51, 0xf2, 0xfc, 0x9b, 0x41, 0x31}};
-static const mfxPluginUID  MFX_PLUGINID_CAMERA_HW    = {{0x54, 0x54, 0x26, 0x16, 0x24, 0x33, 0x41, 0xe6, 0x93, 0xae, 0x89, 0x99, 0x42, 0xce, 0x73, 0x55}};
-static const mfxPluginUID  MFX_PLUGINID_CAPTURE_HW   = {{0x22, 0xd6, 0x2c, 0x07, 0xe6, 0x72, 0x40, 0x8f, 0xbb, 0x4c, 0xc2, 0x0e, 0xd7, 0xa0, 0x53, 0xe4}};
-static const mfxPluginUID  MFX_PLUGINID_ITELECINE_HW = {{0xe7, 0x44, 0x75, 0x3a, 0xcd, 0x74, 0x40, 0x2e, 0x89, 0xa2, 0xee, 0x06, 0x35, 0x49, 0x61, 0x79}};
-static const mfxPluginUID  MFX_PLUGINID_H264LA_HW    = {{0x58, 0x8f, 0x11, 0x85, 0xd4, 0x7b, 0x42, 0x96, 0x8d, 0xea, 0x37, 0x7b, 0xb5, 0xd0, 0xdc, 0xb4}};
-static const mfxPluginUID  MFX_PLUGINID_AACD         = {{0xe9, 0x34, 0x67, 0x25, 0xac, 0x2f, 0x4c, 0x93, 0xaa, 0x58, 0x5c, 0x11, 0xc7, 0x08, 0x7c, 0xf4}};
-static const mfxPluginUID  MFX_PLUGINID_AACE         = {{0xb2, 0xa2, 0xa0, 0x5a, 0x4e, 0xac, 0x46, 0xbf, 0xa9, 0xde, 0x7e, 0x80, 0xc9, 0x8d, 0x2e, 0x18}};
-static const mfxPluginUID  MFX_PLUGINID_HEVCE_FEI_HW = {{0x87, 0xe0, 0xe8, 0x02, 0x07, 0x37, 0x52, 0x40, 0x85, 0x25, 0x15, 0xcf, 0x4a, 0x5e, 0xdd, 0xe6}};
+static const mfxPluginUID  MFX_PLUGINID_HEVCD_SW        = {{0x15, 0xdd, 0x93, 0x68, 0x25, 0xad, 0x47, 0x5e, 0xa3, 0x4e, 0x35, 0xf3, 0xf5, 0x42, 0x17, 0xa6}};
+static const mfxPluginUID  MFX_PLUGINID_HEVCD_HW        = {{0x33, 0xa6, 0x1c, 0x0b, 0x4c, 0x27, 0x45, 0x4c, 0xa8, 0xd8, 0x5d, 0xde, 0x75, 0x7c, 0x6f, 0x8e}};
+static const mfxPluginUID  MFX_PLUGINID_HEVCE_SW        = {{0x2f, 0xca, 0x99, 0x74, 0x9f, 0xdb, 0x49, 0xae, 0xb1, 0x21, 0xa5, 0xb6, 0x3e, 0xf5, 0x68, 0xf7}};
+static const mfxPluginUID  MFX_PLUGINID_HEVCE_GACC      = {{0xe5, 0x40, 0x0a, 0x06, 0xc7, 0x4d, 0x41, 0xf5, 0xb1, 0x2d, 0x43, 0x0b, 0xba, 0xa2, 0x3d, 0x0b}};
+static const mfxPluginUID  MFX_PLUGINID_HEVCE_DP_GACC   = {{0x2b, 0xad, 0x6f, 0x9d, 0x77, 0x54, 0x41, 0x2d, 0xbf, 0x63, 0x03, 0xed, 0x4b, 0xb5, 0x09, 0x68}};
+static const mfxPluginUID  MFX_PLUGINID_HEVCE_HW        = {{0x6f, 0xad, 0xc7, 0x91, 0xa0, 0xc2, 0xeb, 0x47, 0x9a, 0xb6, 0xdc, 0xd5, 0xea, 0x9d, 0xa3, 0x47}};
+static const mfxPluginUID  MFX_PLUGINID_VP8D_HW         = {{0xf6, 0x22, 0x39, 0x4d, 0x8d, 0x87, 0x45, 0x2f, 0x87, 0x8c, 0x51, 0xf2, 0xfc, 0x9b, 0x41, 0x31}};
+static const mfxPluginUID  MFX_PLUGINID_VP8E_HW         = {{0xbf, 0xfc, 0x51, 0x8c, 0xde, 0x13, 0x4d, 0xf9, 0x8a, 0x96, 0xf4, 0xcf, 0x81, 0x6c, 0x0f, 0xac}};
+static const mfxPluginUID  MFX_PLUGINID_VP9E_HW         = {{0xce, 0x44, 0xef, 0x6f, 0x1a, 0x6d, 0x22, 0x46, 0xb4, 0x12, 0xbb, 0x38, 0xd6, 0xe4, 0x51, 0x82}};
+static const mfxPluginUID  MFX_PLUGINID_VP9D_HW         = {{0xa9, 0x22, 0x39, 0x4d, 0x8d, 0x87, 0x45, 0x2f, 0x87, 0x8c, 0x51, 0xf2, 0xfc, 0x9b, 0x41, 0x31}};
+static const mfxPluginUID  MFX_PLUGINID_CAMERA_HW       = {{0x54, 0x54, 0x26, 0x16, 0x24, 0x33, 0x41, 0xe6, 0x93, 0xae, 0x89, 0x99, 0x42, 0xce, 0x73, 0x55}};
+static const mfxPluginUID  MFX_PLUGINID_CAPTURE_HW      = {{0x22, 0xd6, 0x2c, 0x07, 0xe6, 0x72, 0x40, 0x8f, 0xbb, 0x4c, 0xc2, 0x0e, 0xd7, 0xa0, 0x53, 0xe4}};
+static const mfxPluginUID  MFX_PLUGINID_ITELECINE_HW    = {{0xe7, 0x44, 0x75, 0x3a, 0xcd, 0x74, 0x40, 0x2e, 0x89, 0xa2, 0xee, 0x06, 0x35, 0x49, 0x61, 0x79}};
+static const mfxPluginUID  MFX_PLUGINID_H264LA_HW       = {{0x58, 0x8f, 0x11, 0x85, 0xd4, 0x7b, 0x42, 0x96, 0x8d, 0xea, 0x37, 0x7b, 0xb5, 0xd0, 0xdc, 0xb4}};
+static const mfxPluginUID  MFX_PLUGINID_AACD            = {{0xe9, 0x34, 0x67, 0x25, 0xac, 0x2f, 0x4c, 0x93, 0xaa, 0x58, 0x5c, 0x11, 0xc7, 0x08, 0x7c, 0xf4}};
+static const mfxPluginUID  MFX_PLUGINID_AACE            = {{0xb2, 0xa2, 0xa0, 0x5a, 0x4e, 0xac, 0x46, 0xbf, 0xa9, 0xde, 0x7e, 0x80, 0xc9, 0x8d, 0x2e, 0x18}};
+static const mfxPluginUID  MFX_PLUGINID_HEVCE_FEI_HW    = {{0x87, 0xe0, 0xe8, 0x02, 0x07, 0x37, 0x52, 0x40, 0x85, 0x25, 0x15, 0xcf, 0x4a, 0x5e, 0xdd, 0xe6}};
+static const mfxPluginUID  MFX_PLUGINID_HEVC_FEI_ENCODE = {{0x54, 0x18, 0xa7, 0x06, 0x66, 0xf9, 0x4d, 0x5c, 0xb4, 0xf7, 0xb1, 0xca, 0xee, 0x86, 0x33, 0x9b}};
 
 
 typedef enum {
@@ -71,26 +73,26 @@ typedef enum {
 
 typedef enum {
     MFX_THREADPOLICY_SERIAL    = 0,
-    MFX_THREADPOLICY_PARALLEL    = 1
+    MFX_THREADPOLICY_PARALLEL  = 1
 } mfxThreadPolicy;
 
 typedef struct mfxPluginParam {
-    mfxU32  reserved[6];
-    mfxU16  reserved1;
-    mfxU16  PluginVersion;
-    mfxVersion   APIVersion;
-    mfxPluginUID PluginUID;
-    mfxU32  Type;
-    mfxU32  CodecId;
+    mfxU32          reserved[6];
+    mfxU16          reserved1;
+    mfxU16          PluginVersion;
+    mfxVersion      APIVersion;
+    mfxPluginUID    PluginUID;
+    mfxU32          Type;
+    mfxU32          CodecId;
     mfxThreadPolicy ThreadPolicy;
-    mfxU32  MaxThreadNum;
+    mfxU32          MaxThreadNum;
 } mfxPluginParam;
 
 typedef struct mfxCoreParam{
-    mfxU32  reserved[13];
-    mfxIMPL Impl;
+    mfxU32     reserved[13];
+    mfxIMPL    Impl;
     mfxVersion Version;
-    mfxU32  NumWorkingThread;
+    mfxU32     NumWorkingThread;
 } mfxCoreParam;
 
 typedef struct mfxCoreInterface {
@@ -114,23 +116,25 @@ typedef struct mfxCoreInterface {
     mfxStatus (MFX_CDECL *GetOpaqueSurface)(mfxHDL pthis, mfxFrameSurface1 *surf, mfxFrameSurface1 **op_surf);
 
     mfxStatus (MFX_CDECL *CreateAccelerationDevice)(mfxHDL pthis, mfxHandleType type, mfxHDL *handle);
+    mfxStatus (MFX_CDECL *GetFrameHandle) (mfxHDL pthis, mfxFrameData *fd, mfxHDL *handle);
+    mfxStatus (MFX_CDECL *QueryPlatform) (mfxHDL pthis, mfxPlatform *platform);
 
-    mfxHDL reserved4[3];
+    mfxHDL reserved4[1];
 } mfxCoreInterface;
 
-/* video codec plugin extension*/
+/* video codec plugin extension */
 typedef struct _mfxENCInput mfxENCInput;
 typedef struct _mfxENCOutput mfxENCOutput;
 typedef struct mfxVideoCodecPlugin{
     mfxStatus (MFX_CDECL *Query)(mfxHDL pthis, mfxVideoParam *in, mfxVideoParam *out);
-    mfxStatus (MFX_CDECL *QueryIOSurf)(mfxHDL pthis, mfxVideoParam *par, mfxFrameAllocRequest *in, mfxFrameAllocRequest *out); 
+    mfxStatus (MFX_CDECL *QueryIOSurf)(mfxHDL pthis, mfxVideoParam *par, mfxFrameAllocRequest *in, mfxFrameAllocRequest *out);
     mfxStatus (MFX_CDECL *Init)(mfxHDL pthis, mfxVideoParam *par);
     mfxStatus (MFX_CDECL *Reset)(mfxHDL pthis, mfxVideoParam *par);
     mfxStatus (MFX_CDECL *Close)(mfxHDL pthis);
     mfxStatus (MFX_CDECL *GetVideoParam)(mfxHDL pthis, mfxVideoParam *par);
 
     mfxStatus (MFX_CDECL *EncodeFrameSubmit)(mfxHDL pthis, mfxEncodeCtrl *ctrl, mfxFrameSurface1 *surface, mfxBitstream *bs, mfxThreadTask *task);
-    
+
     mfxStatus (MFX_CDECL *DecodeHeader)(mfxHDL pthis, mfxBitstream *bs, mfxVideoParam *par);
     mfxStatus (MFX_CDECL *GetPayload)(mfxHDL pthis, mfxU64 *ts, mfxPayload *payload);
     mfxStatus (MFX_CDECL *DecodeFrameSubmit)(mfxHDL pthis, mfxBitstream *bs, mfxFrameSurface1 *surface_work, mfxFrameSurface1 **surface_out,  mfxThreadTask *task);
@@ -146,14 +150,14 @@ typedef struct mfxVideoCodecPlugin{
 
 typedef struct mfxAudioCodecPlugin{
     mfxStatus (MFX_CDECL *Query)(mfxHDL pthis, mfxAudioParam *in, mfxAudioParam *out);
-    mfxStatus (MFX_CDECL *QueryIOSize)(mfxHDL pthis, mfxAudioParam *par, mfxAudioAllocRequest *request); 
+    mfxStatus (MFX_CDECL *QueryIOSize)(mfxHDL pthis, mfxAudioParam *par, mfxAudioAllocRequest *request);
     mfxStatus (MFX_CDECL *Init)(mfxHDL pthis, mfxAudioParam *par);
     mfxStatus (MFX_CDECL *Reset)(mfxHDL pthis, mfxAudioParam *par);
     mfxStatus (MFX_CDECL *Close)(mfxHDL pthis);
     mfxStatus (MFX_CDECL *GetAudioParam)(mfxHDL pthis, mfxAudioParam *par);
 
     mfxStatus (MFX_CDECL *EncodeFrameSubmit)(mfxHDL pthis, mfxAudioFrame *aFrame, mfxBitstream *out, mfxThreadTask *task);
-    
+
     mfxStatus (MFX_CDECL *DecodeHeader)(mfxHDL pthis, mfxBitstream *bs, mfxAudioParam *par);
 //    mfxStatus (MFX_CDECL *GetPayload)(mfxHDL pthis, mfxU64 *ts, mfxPayload *payload);
     mfxStatus (MFX_CDECL *DecodeFrameSubmit)(mfxHDL pthis, mfxBitstream *in, mfxAudioFrame *out, mfxThreadTask *task);
@@ -186,6 +190,7 @@ typedef struct mfxPlugin{
 
 mfxStatus MFX_CDECL MFXVideoUSER_Register(mfxSession session, mfxU32 type, const mfxPlugin *par);
 mfxStatus MFX_CDECL MFXVideoUSER_Unregister(mfxSession session, mfxU32 type);
+mfxStatus MFX_CDECL MFXVideoUSER_GetPlugin(mfxSession session, mfxU32 type, mfxPlugin *par);
 mfxStatus MFX_CDECL MFXVideoUSER_ProcessFrameAsync(mfxSession session, const mfxHDL *in, mfxU32 in_num, const mfxHDL *out, mfxU32 out_num, mfxSyncPoint *syncp);
 
 mfxStatus MFX_CDECL MFXVideoUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32 version);

+ 590 - 99
plugins/obs-qsv11/libmfx/include/msdk/include/mfxstructures.h

@@ -1,6 +1,6 @@
 /******************************************************************************* *\
 
-Copyright (C) 2007-2015 Intel Corporation.  All rights reserved.
+Copyright (C) 2007-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -106,7 +106,7 @@ enum {
     MFX_FOURCC_RGB4         = MFX_MAKEFOURCC('R','G','B','4'),   /* ARGB in that order, A channel is 8 MSBs */
     MFX_FOURCC_P8           = 41,                                /*  D3DFMT_P8   */
     MFX_FOURCC_P8_TEXTURE   = MFX_MAKEFOURCC('P','8','M','B'),
-    MFX_FOURCC_P010         = MFX_MAKEFOURCC('P','0','1','0'), 
+    MFX_FOURCC_P010         = MFX_MAKEFOURCC('P','0','1','0'),
     MFX_FOURCC_P210         = MFX_MAKEFOURCC('P','2','1','0'),
     MFX_FOURCC_BGR4         = MFX_MAKEFOURCC('B','G','R','4'),   /* ABGR in that order, A channel is 8 MSBs */
     MFX_FOURCC_A2RGB10      = MFX_MAKEFOURCC('R','G','1','0'),   /* ARGB in that order, A channel is two MSBs */
@@ -115,7 +115,9 @@ enum {
     MFX_FOURCC_R16          = MFX_MAKEFOURCC('R','1','6','U'),
     MFX_FOURCC_AYUV         = MFX_MAKEFOURCC('A','Y','U','V'),   /* YUV 4:4:4, AYUV in that order, A channel is 8 MSBs */
     MFX_FOURCC_AYUV_RGB4    = MFX_MAKEFOURCC('A','V','U','Y'),   /* ARGB in that order, A channel is 8 MSBs stored in AYUV surface*/
-    MFX_FOURCC_UYVY         = MFX_MAKEFOURCC('U','Y','V','Y')
+    MFX_FOURCC_UYVY         = MFX_MAKEFOURCC('U','Y','V','Y'),
+    MFX_FOURCC_Y210         = MFX_MAKEFOURCC('Y','2','1','0'),
+    MFX_FOURCC_Y410         = MFX_MAKEFOURCC('Y','4','1','0'),
 };
 
 /* PicStruct */
@@ -127,7 +129,13 @@ enum {
 
     MFX_PICSTRUCT_FIELD_REPEATED=0x10,  /* first field repeated, pic_struct=5 or 6 in H.264 */
     MFX_PICSTRUCT_FRAME_DOUBLING=0x20,  /* pic_struct=7 in H.264 */
-    MFX_PICSTRUCT_FRAME_TRIPLING=0x40   /* pic_struct=8 in H.264 */
+    MFX_PICSTRUCT_FRAME_TRIPLING=0x40,  /* pic_struct=8 in H.264 */
+
+    MFX_PICSTRUCT_FIELD_SINGLE      =0x100,
+    MFX_PICSTRUCT_FIELD_TOP         =MFX_PICSTRUCT_FIELD_SINGLE | MFX_PICSTRUCT_FIELD_TFF,
+    MFX_PICSTRUCT_FIELD_BOTTOM      =MFX_PICSTRUCT_FIELD_SINGLE | MFX_PICSTRUCT_FIELD_BFF,
+    MFX_PICSTRUCT_FIELD_PAIRED_PREV =0x200,
+    MFX_PICSTRUCT_FIELD_PAIRED_NEXT =0x400,
 };
 
 /* ColorFormat */
@@ -139,7 +147,8 @@ enum {
     MFX_CHROMAFORMAT_YUV400     = MFX_CHROMAFORMAT_MONOCHROME,
     MFX_CHROMAFORMAT_YUV411     = 4,
     MFX_CHROMAFORMAT_YUV422H    = MFX_CHROMAFORMAT_YUV422,
-    MFX_CHROMAFORMAT_YUV422V    = 5
+    MFX_CHROMAFORMAT_YUV422V    = 5,
+    MFX_CHROMAFORMAT_RESERVED1  = 6
 };
 
 enum {
@@ -165,6 +174,27 @@ enum {
     MFX_CORRUPTION_REFERENCE_LIST  = 0x0020
 };
 
+#pragma pack(push, 4)
+typedef struct
+{
+    mfxU32 U : 10;
+    mfxU32 Y : 10;
+    mfxU32 V : 10;
+    mfxU32 A :  2;
+} mfxY410;
+#pragma pack(pop)
+
+#pragma pack(push, 4)
+typedef struct
+{
+    mfxU32 B : 10;
+    mfxU32 G : 10;
+    mfxU32 R : 10;
+    mfxU32 A :  2;
+} mfxA2RGB10;
+#pragma pack(pop)
+
+
 /* Frame Data Info */
 typedef struct {
     union {
@@ -173,7 +203,8 @@ typedef struct {
     };
     mfxU16  NumExtParam;
 
-    mfxU16      reserved[10];
+    mfxU16      reserved[9];
+    mfxU16      MemType;
     mfxU16      PitchHigh;
 
     mfxU64      TimeStamp;
@@ -199,12 +230,14 @@ typedef struct {
         mfxU8   *U;
         mfxU16  *U16;
         mfxU8   *G;
+        mfxY410 *Y410;          /* for Y410 format (merged AVYU) */
     };
     union {
         mfxU8   *Cr;
         mfxU8   *V;
         mfxU16  *V16;
         mfxU8   *B;
+        mfxA2RGB10 *A2RGB10;    /* for A2RGB10 format (merged ARGB) */
     };
     mfxU8       *A;
     mfxMemId    MemId;
@@ -240,7 +273,7 @@ typedef struct {
     mfxU16  NumThread;
 
     union {
-        struct {   /* MPEG-2/H.264 Encoding Options */
+        struct {   /* Encoding Options */
             mfxU16  TargetUsage;
 
             mfxU16  GopPicSize;
@@ -270,20 +303,23 @@ typedef struct {
             mfxU16  NumRefFrame;
             mfxU16  EncodedOrder;
         };
-        struct {   /* H.264, MPEG-2 and VC-1 Decoding Options */
+        struct {   /* Decoding Options */
             mfxU16  DecodedOrder;
             mfxU16  ExtendedPicStruct;
             mfxU16  TimeStampCalc;
             mfxU16  SliceGroupsPresent;
             mfxU16  MaxDecFrameBuffering;
-            mfxU16  reserved2[8];
+            mfxU16  EnableReallocRequest;
+            mfxU16  reserved2[7];
         };
         struct {   /* JPEG Decoding Options */
             mfxU16  JPEGChromaFormat;
             mfxU16  Rotation;
             mfxU16  JPEGColorFormat;
             mfxU16  InterleavedDec;
-            mfxU16  reserved3[9];
+            mfxU8   SamplingFactorH[4];
+            mfxU8   SamplingFactorV[4];
+            mfxU16  reserved3[5];
         };
         struct {   /* JPEG Encoding Options */
             mfxU16  Interleaved;
@@ -333,7 +369,9 @@ enum {
     MFX_CODEC_HEVC        =MFX_MAKEFOURCC('H','E','V','C'),
     MFX_CODEC_MPEG2       =MFX_MAKEFOURCC('M','P','G','2'),
     MFX_CODEC_VC1         =MFX_MAKEFOURCC('V','C','1',' '),
-    MFX_CODEC_CAPTURE     =MFX_MAKEFOURCC('C','A','P','T')
+    MFX_CODEC_CAPTURE     =MFX_MAKEFOURCC('C','A','P','T'),
+    MFX_CODEC_VP9         =MFX_MAKEFOURCC('V','P','9',' '),
+    MFX_CODEC_AV1         =MFX_MAKEFOURCC('A','V','1',' ')
 };
 
 /* CodecProfile, CodecLevel */
@@ -426,6 +464,13 @@ enum {
 
     MFX_TIER_HEVC_MAIN  = 0,
     MFX_TIER_HEVC_HIGH  = 0x100,
+
+    /* VP9 Profiles */
+    MFX_PROFILE_VP9_0                       = 1,
+    MFX_PROFILE_VP9_1                       = 2,
+    MFX_PROFILE_VP9_2                       = 3,
+    MFX_PROFILE_VP9_3                       = 4,
+
 };
 
 /* GopOptFlag */
@@ -466,7 +511,7 @@ enum {
     MFX_RATECONTROL_LA_ICQ    =11,
     MFX_RATECONTROL_LA_EXT    =12,
     MFX_RATECONTROL_LA_HRD    =13,
-    MFX_RATECONTROL_QVBR      =14
+    MFX_RATECONTROL_QVBR      =14,
 };
 
 /* Trellis control*/
@@ -538,6 +583,14 @@ enum {
     MFX_SKIPFRAME_BRC_ONLY        = 3,
 };
 
+/* Intra refresh types */
+enum {
+        MFX_REFRESH_NO             = 0,
+        MFX_REFRESH_VERTICAL       = 1,
+        MFX_REFRESH_HORIZONTAL     = 2,
+        MFX_REFRESH_SLICE          = 3
+};
+
 typedef struct {
     mfxExtBuffer Header;
 
@@ -606,6 +659,7 @@ enum {
     MFX_P_REF_PYRAMID = 2
 };
 
+
 typedef struct {
     mfxExtBuffer Header;
 
@@ -632,14 +686,46 @@ typedef struct {
     mfxU16      OverscanAppropriate;            /* tri-state option */
     mfxU16      TimingInfoPresent;              /* tri-state option */
     mfxU16      BitstreamRestriction;           /* tri-state option */
-    mfxU16      reserved1[4];
+    mfxU16      LowDelayHrd;                    /* tri-state option */
+    mfxU16      MotionVectorsOverPicBoundaries; /* tri-state option */
+    mfxU16      reserved1[2];
 
     mfxU16      ScenarioInfo;
     mfxU16      ContentInfo;
 
     mfxU16      PRefType;
     mfxU16      FadeDetection;            /* tri-state option */
-    mfxU16      reserved[225];
+    mfxU16      reserved2[2];
+    mfxU16      GPB;                      /* tri-state option */
+
+    mfxU32      MaxFrameSizeI;
+    mfxU32      MaxFrameSizeP;
+    mfxU32      reserved3[3];
+
+    mfxU16      EnableQPOffset;           /* tri-state option */
+    mfxI16      QPOffset[8];              /* FrameQP = QPX + QPOffset[pyramid_layer]; QPX = QPB for B-pyramid, QPP for P-pyramid */
+
+    mfxU16      NumRefActiveP[8];
+    mfxU16      NumRefActiveBL0[8];
+    mfxU16      NumRefActiveBL1[8];
+
+    mfxU16      reserved6;
+    mfxU16      TransformSkip;  /* tri-state option; HEVC transform_skip_enabled_flag */
+    mfxU16      TargetChromaFormatPlus1;   /* Minus 1 specifies target encoding chroma format (see ColorFormat enum). May differ from input one. */
+    mfxU16      TargetBitDepthLuma;        /* Target encoding bit depth for luma samples. May differ from input one. */
+    mfxU16      TargetBitDepthChroma;      /* Target encoding bit depth for chroma samples. May differ from input one. */
+    mfxU16      BRCPanicMode;              /* tri-state option */
+
+    mfxU16      LowDelayBRC;               /* tri-state option */
+    mfxU16      EnableMBForceIntra;        /* tri-state option */
+    mfxU16      AdaptiveMaxFrameSize;      /* tri-state option */
+
+    mfxU16      RepartitionCheckEnable;    /* tri-state option */
+    mfxU16      reserved5[3];
+    mfxU16      EncodedUnitsInfo;          /* tri-state option */
+    mfxU16      EnableNalUnitType;         /* tri-state option */
+    mfxU16      ExtBrcAdaptiveLTR;         /* tri-state option for ExtBRC */
+    mfxU16      reserved[163];
 } mfxExtCodingOption3;
 
 /* IntraPredBlockSize/InterPredBlockSize */
@@ -670,51 +756,72 @@ enum {
     MFX_BITSTREAM_COMPLETE_FRAME    = 0x0001,        /* the bitstream contains a complete frame or field pair of data */
     MFX_BITSTREAM_EOS               = 0x0002
 };
-
 /* Extended Buffer Ids */
 enum {
-    MFX_EXTBUFF_CODING_OPTION              = MFX_MAKEFOURCC('C','D','O','P'),
-    MFX_EXTBUFF_CODING_OPTION_SPSPPS       = MFX_MAKEFOURCC('C','O','S','P'),
-    MFX_EXTBUFF_VPP_DONOTUSE               = MFX_MAKEFOURCC('N','U','S','E'),
-    MFX_EXTBUFF_VPP_AUXDATA                = MFX_MAKEFOURCC('A','U','X','D'),
-    MFX_EXTBUFF_VPP_DENOISE                = MFX_MAKEFOURCC('D','N','I','S'),
-    MFX_EXTBUFF_VPP_SCENE_ANALYSIS         = MFX_MAKEFOURCC('S','C','L','Y'),
-    MFX_EXTBUFF_VPP_SCENE_CHANGE           = MFX_EXTBUFF_VPP_SCENE_ANALYSIS,
-    MFX_EXTBUFF_VPP_PROCAMP                = MFX_MAKEFOURCC('P','A','M','P'),
-    MFX_EXTBUFF_VPP_DETAIL                 = MFX_MAKEFOURCC('D','E','T',' '),
-    MFX_EXTBUFF_VIDEO_SIGNAL_INFO          = MFX_MAKEFOURCC('V','S','I','N'),
-    MFX_EXTBUFF_VPP_DOUSE                  = MFX_MAKEFOURCC('D','U','S','E'),
-    MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION  = MFX_MAKEFOURCC('O','P','Q','S'),
-    MFX_EXTBUFF_AVC_REFLIST_CTRL           = MFX_MAKEFOURCC('R','L','S','T'),
-    MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION  = MFX_MAKEFOURCC('F','R','C',' '),
-    MFX_EXTBUFF_PICTURE_TIMING_SEI         = MFX_MAKEFOURCC('P','T','S','E'),
-    MFX_EXTBUFF_AVC_TEMPORAL_LAYERS        = MFX_MAKEFOURCC('A','T','M','L'),
-    MFX_EXTBUFF_CODING_OPTION2             = MFX_MAKEFOURCC('C','D','O','2'),
-    MFX_EXTBUFF_VPP_IMAGE_STABILIZATION    = MFX_MAKEFOURCC('I','S','T','B'),
-    MFX_EXTBUFF_VPP_PICSTRUCT_DETECTION    = MFX_MAKEFOURCC('I','D','E','T'),
-    MFX_EXTBUFF_ENCODER_CAPABILITY         = MFX_MAKEFOURCC('E','N','C','P'),
-    MFX_EXTBUFF_ENCODER_RESET_OPTION       = MFX_MAKEFOURCC('E','N','R','O'),
-    MFX_EXTBUFF_ENCODED_FRAME_INFO         = MFX_MAKEFOURCC('E','N','F','I'),
-    MFX_EXTBUFF_VPP_COMPOSITE              = MFX_MAKEFOURCC('V','C','M','P'),
-    MFX_EXTBUFF_VPP_VIDEO_SIGNAL_INFO      = MFX_MAKEFOURCC('V','V','S','I'),
-    MFX_EXTBUFF_ENCODER_ROI                = MFX_MAKEFOURCC('E','R','O','I'),
-    MFX_EXTBUFF_VPP_DEINTERLACING          = MFX_MAKEFOURCC('V','P','D','I'),
-    MFX_EXTBUFF_AVC_REFLISTS               = MFX_MAKEFOURCC('R','L','T','S'),
-    MFX_EXTBUFF_VPP_FIELD_PROCESSING       = MFX_MAKEFOURCC('F','P','R','O'),
-    MFX_EXTBUFF_CODING_OPTION3             = MFX_MAKEFOURCC('C','D','O','3'),
-    MFX_EXTBUFF_CHROMA_LOC_INFO            = MFX_MAKEFOURCC('C','L','I','N'),
-    MFX_EXTBUFF_MBQP                       = MFX_MAKEFOURCC('M','B','Q','P'),
-    MFX_EXTBUFF_HEVC_TILES                 = MFX_MAKEFOURCC('2','6','5','T'),
-    MFX_EXTBUFF_MB_DISABLE_SKIP_MAP        = MFX_MAKEFOURCC('M','D','S','M'),
-    MFX_EXTBUFF_HEVC_PARAM                 = MFX_MAKEFOURCC('2','6','5','P'),
-    MFX_EXTBUFF_DECODED_FRAME_INFO         = MFX_MAKEFOURCC('D','E','F','I'),
-    MFX_EXTBUFF_TIME_CODE                  = MFX_MAKEFOURCC('T','M','C','D'),
-    MFX_EXTBUFF_HEVC_REGION                = MFX_MAKEFOURCC('2','6','5','R'),
-    MFX_EXTBUFF_PRED_WEIGHT_TABLE          = MFX_MAKEFOURCC('E','P','W','T'),
-    MFX_EXTBUFF_DIRTY_RECTANGLES           = MFX_MAKEFOURCC('D','R','O','I'),
-    MFX_EXTBUFF_MOVING_RECTANGLES          = MFX_MAKEFOURCC('M','R','O','I'),
-    MFX_EXTBUFF_CODING_OPTION_VPS          = MFX_MAKEFOURCC('C','O','V','P'),
-    MFX_EXTBUFF_VPP_ROTATION               = MFX_MAKEFOURCC('R','O','T',' ')
+    MFX_EXTBUFF_CODING_OPTION                   = MFX_MAKEFOURCC('C','D','O','P'),
+    MFX_EXTBUFF_CODING_OPTION_SPSPPS            = MFX_MAKEFOURCC('C','O','S','P'),
+    MFX_EXTBUFF_VPP_DONOTUSE                    = MFX_MAKEFOURCC('N','U','S','E'),
+    MFX_EXTBUFF_VPP_AUXDATA                     = MFX_MAKEFOURCC('A','U','X','D'),
+    MFX_EXTBUFF_VPP_DENOISE                     = MFX_MAKEFOURCC('D','N','I','S'),
+    MFX_EXTBUFF_VPP_SCENE_ANALYSIS              = MFX_MAKEFOURCC('S','C','L','Y'),
+    MFX_EXTBUFF_VPP_SCENE_CHANGE                = MFX_EXTBUFF_VPP_SCENE_ANALYSIS,
+    MFX_EXTBUFF_VPP_PROCAMP                     = MFX_MAKEFOURCC('P','A','M','P'),
+    MFX_EXTBUFF_VPP_DETAIL                      = MFX_MAKEFOURCC('D','E','T',' '),
+    MFX_EXTBUFF_VIDEO_SIGNAL_INFO               = MFX_MAKEFOURCC('V','S','I','N'),
+    MFX_EXTBUFF_VPP_DOUSE                       = MFX_MAKEFOURCC('D','U','S','E'),
+    MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION       = MFX_MAKEFOURCC('O','P','Q','S'),
+    MFX_EXTBUFF_AVC_REFLIST_CTRL                = MFX_MAKEFOURCC('R','L','S','T'),
+    MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION       = MFX_MAKEFOURCC('F','R','C',' '),
+    MFX_EXTBUFF_PICTURE_TIMING_SEI              = MFX_MAKEFOURCC('P','T','S','E'),
+    MFX_EXTBUFF_AVC_TEMPORAL_LAYERS             = MFX_MAKEFOURCC('A','T','M','L'),
+    MFX_EXTBUFF_CODING_OPTION2                  = MFX_MAKEFOURCC('C','D','O','2'),
+    MFX_EXTBUFF_VPP_IMAGE_STABILIZATION         = MFX_MAKEFOURCC('I','S','T','B'),
+    MFX_EXTBUFF_VPP_PICSTRUCT_DETECTION         = MFX_MAKEFOURCC('I','D','E','T'),
+    MFX_EXTBUFF_ENCODER_CAPABILITY              = MFX_MAKEFOURCC('E','N','C','P'),
+    MFX_EXTBUFF_ENCODER_RESET_OPTION            = MFX_MAKEFOURCC('E','N','R','O'),
+    MFX_EXTBUFF_ENCODED_FRAME_INFO              = MFX_MAKEFOURCC('E','N','F','I'),
+    MFX_EXTBUFF_VPP_COMPOSITE                   = MFX_MAKEFOURCC('V','C','M','P'),
+    MFX_EXTBUFF_VPP_VIDEO_SIGNAL_INFO           = MFX_MAKEFOURCC('V','V','S','I'),
+    MFX_EXTBUFF_ENCODER_ROI                     = MFX_MAKEFOURCC('E','R','O','I'),
+    MFX_EXTBUFF_VPP_DEINTERLACING               = MFX_MAKEFOURCC('V','P','D','I'),
+    MFX_EXTBUFF_AVC_REFLISTS                    = MFX_MAKEFOURCC('R','L','T','S'),
+    MFX_EXTBUFF_DEC_VIDEO_PROCESSING            = MFX_MAKEFOURCC('D','E','C','V'),
+    MFX_EXTBUFF_VPP_FIELD_PROCESSING            = MFX_MAKEFOURCC('F','P','R','O'),
+    MFX_EXTBUFF_CODING_OPTION3                  = MFX_MAKEFOURCC('C','D','O','3'),
+    MFX_EXTBUFF_CHROMA_LOC_INFO                 = MFX_MAKEFOURCC('C','L','I','N'),
+    MFX_EXTBUFF_MBQP                            = MFX_MAKEFOURCC('M','B','Q','P'),
+    MFX_EXTBUFF_MB_FORCE_INTRA                  = MFX_MAKEFOURCC('M','B','F','I'),
+    MFX_EXTBUFF_HEVC_TILES                      = MFX_MAKEFOURCC('2','6','5','T'),
+    MFX_EXTBUFF_MB_DISABLE_SKIP_MAP             = MFX_MAKEFOURCC('M','D','S','M'),
+    MFX_EXTBUFF_HEVC_PARAM                      = MFX_MAKEFOURCC('2','6','5','P'),
+    MFX_EXTBUFF_DECODED_FRAME_INFO              = MFX_MAKEFOURCC('D','E','F','I'),
+    MFX_EXTBUFF_TIME_CODE                       = MFX_MAKEFOURCC('T','M','C','D'),
+    MFX_EXTBUFF_HEVC_REGION                     = MFX_MAKEFOURCC('2','6','5','R'),
+    MFX_EXTBUFF_PRED_WEIGHT_TABLE               = MFX_MAKEFOURCC('E','P','W','T'),
+    MFX_EXTBUFF_DIRTY_RECTANGLES                = MFX_MAKEFOURCC('D','R','O','I'),
+    MFX_EXTBUFF_MOVING_RECTANGLES               = MFX_MAKEFOURCC('M','R','O','I'),
+    MFX_EXTBUFF_CODING_OPTION_VPS               = MFX_MAKEFOURCC('C','O','V','P'),
+    MFX_EXTBUFF_VPP_ROTATION                    = MFX_MAKEFOURCC('R','O','T',' '),
+    MFX_EXTBUFF_ENCODED_SLICES_INFO             = MFX_MAKEFOURCC('E','N','S','I'),
+    MFX_EXTBUFF_VPP_SCALING                     = MFX_MAKEFOURCC('V','S','C','L'),
+    MFX_EXTBUFF_HEVC_REFLIST_CTRL               = MFX_EXTBUFF_AVC_REFLIST_CTRL,
+    MFX_EXTBUFF_HEVC_REFLISTS                   = MFX_EXTBUFF_AVC_REFLISTS,
+    MFX_EXTBUFF_HEVC_TEMPORAL_LAYERS            = MFX_EXTBUFF_AVC_TEMPORAL_LAYERS,
+    MFX_EXTBUFF_VPP_MIRRORING                   = MFX_MAKEFOURCC('M','I','R','R'),
+    MFX_EXTBUFF_MV_OVER_PIC_BOUNDARIES          = MFX_MAKEFOURCC('M','V','P','B'),
+    MFX_EXTBUFF_VPP_COLORFILL                   = MFX_MAKEFOURCC('V','C','L','F'),
+    MFX_EXTBUFF_DECODE_ERROR_REPORT             = MFX_MAKEFOURCC('D', 'E', 'R', 'R'),
+    MFX_EXTBUFF_VPP_COLOR_CONVERSION            = MFX_MAKEFOURCC('V', 'C', 'S', 'C'),
+    MFX_EXTBUFF_CONTENT_LIGHT_LEVEL_INFO        = MFX_MAKEFOURCC('L', 'L', 'I', 'S'),
+    MFX_EXTBUFF_MASTERING_DISPLAY_COLOUR_VOLUME = MFX_MAKEFOURCC('D', 'C', 'V', 'S'),
+    MFX_EXTBUFF_MULTI_FRAME_PARAM               = MFX_MAKEFOURCC('M', 'F', 'R', 'P'),
+    MFX_EXTBUFF_MULTI_FRAME_CONTROL             = MFX_MAKEFOURCC('M', 'F', 'R', 'C'),
+    MFX_EXTBUFF_ENCODED_UNITS_INFO              = MFX_MAKEFOURCC('E', 'N', 'U', 'I'),
+    MFX_EXTBUFF_VPP_MCTF                        = MFX_MAKEFOURCC('M', 'C', 'T', 'F'),
+    MFX_EXTBUFF_VP9_SEGMENTATION                = MFX_MAKEFOURCC('9', 'S', 'E', 'G'),
+    MFX_EXTBUFF_VP9_TEMPORAL_LAYERS             = MFX_MAKEFOURCC('9', 'T', 'M', 'L'),
+    MFX_EXTBUFF_VP9_PARAM                       = MFX_MAKEFOURCC('9', 'P', 'A', 'R'),
+    MFX_EXTBUFF_AVC_ROUNDING_OFFSET             = MFX_MAKEFOURCC('R','N','D','O'),
 };
 
 /* VPP Conf: Do not use certain algorithms  */
@@ -781,8 +888,14 @@ typedef struct {
     mfxU16          RepeatedFrame;
 } mfxExtVppAuxData;
 
+/* CtrlFlags */
+enum {
+    MFX_PAYLOAD_CTRL_SUFFIX = 0x00000001 /* HEVC suffix SEI */
+};
+
 typedef struct {
-    mfxU32      reserved[4];
+    mfxU32      CtrlFlags;
+    mfxU32      reserved[3];
     mfxU8       *Data;      /* buffer pointer */
     mfxU32      NumBit;     /* number of bits */
     mfxU16      Type;       /* SEI message type in H.264 or user data start_code in MPEG-2 */
@@ -791,7 +904,9 @@ typedef struct {
 
 typedef struct {
     mfxExtBuffer    Header;
-    mfxU32  reserved[5];
+    mfxU32  reserved[4];
+    mfxU16  reserved1;
+    mfxU16  MfxNalUnitType;
     mfxU16  SkipFrame;
 
     mfxU16  QP; /* per frame QP */
@@ -812,7 +927,7 @@ enum {
 };
 
 /* Frame Memory Types */
-#define MFX_MEMTYPE_BASE(x) (0xf0ff & (x))
+#define MFX_MEMTYPE_BASE(x) (0x90ff & (x))
 
 enum {
     MFX_MEMTYPE_DXVA2_DECODER_TARGET       =0x0010,
@@ -826,13 +941,15 @@ enum {
     MFX_MEMTYPE_FROM_DECODE     = 0x0200,
     MFX_MEMTYPE_FROM_VPPIN      = 0x0400,
     MFX_MEMTYPE_FROM_VPPOUT     = 0x0800,
+    MFX_MEMTYPE_FROM_ENC        = 0x2000,
+    MFX_MEMTYPE_FROM_PAK        = 0x4000, //reserved
 
     MFX_MEMTYPE_INTERNAL_FRAME  = 0x0001,
     MFX_MEMTYPE_EXTERNAL_FRAME  = 0x0002,
     MFX_MEMTYPE_OPAQUE_FRAME    = 0x0004,
     MFX_MEMTYPE_EXPORT_FRAME    = 0x0008,
-
-    MFX_MEMTYPE_RESERVED2       = 0x1000
+    MFX_MEMTYPE_SHARED_RESOURCE = MFX_MEMTYPE_EXPORT_FRAME,
+    MFX_MEMTYPE_VIDEO_MEMORY_ENCODER_TARGET = 0x1000
 };
 
 typedef struct {
@@ -877,13 +994,26 @@ enum {
     MFX_FRAMETYPE_xIDR          =0x8000
 };
 
+enum {
+    MFX_HEVC_NALU_TYPE_UNKNOWN    =      0,
+    MFX_HEVC_NALU_TYPE_TRAIL_N    = ( 0+1),
+    MFX_HEVC_NALU_TYPE_TRAIL_R    = ( 1+1),
+    MFX_HEVC_NALU_TYPE_RADL_N     = ( 6+1),
+    MFX_HEVC_NALU_TYPE_RADL_R     = ( 7+1),
+    MFX_HEVC_NALU_TYPE_RASL_N     = ( 8+1),
+    MFX_HEVC_NALU_TYPE_RASL_R     = ( 9+1),
+    MFX_HEVC_NALU_TYPE_IDR_W_RADL = (19+1),
+    MFX_HEVC_NALU_TYPE_IDR_N_LP   = (20+1),
+    MFX_HEVC_NALU_TYPE_CRA_NUT    = (21+1)
+};
+
 typedef enum {
     MFX_HANDLE_DIRECT3D_DEVICE_MANAGER9         =1,      /* IDirect3DDeviceManager9      */
     MFX_HANDLE_D3D9_DEVICE_MANAGER              = MFX_HANDLE_DIRECT3D_DEVICE_MANAGER9,
     MFX_HANDLE_RESERVED1                        = 2,
     MFX_HANDLE_D3D11_DEVICE                     = 3,
     MFX_HANDLE_VA_DISPLAY                       = 4,
-    MFX_HANDLE_RESERVED3                        = 5
+    MFX_HANDLE_RESERVED3                        = 5,
 } mfxHandleType;
 
 typedef enum {
@@ -983,6 +1113,36 @@ typedef struct {
     mfxU16  reserved[11];
 } mfxExtVPPImageStab;
 
+
+enum {
+    MFX_PAYLOAD_OFF = 0,
+    MFX_PAYLOAD_IDR = 1
+};
+
+typedef struct {
+    mfxExtBuffer    Header;
+    mfxU16      reserved[15];
+
+    mfxU16 InsertPayloadToggle;
+    mfxU16 DisplayPrimariesX[3];
+    mfxU16 DisplayPrimariesY[3];
+    mfxU16 WhitePointX;
+    mfxU16 WhitePointY;
+    mfxU32 MaxDisplayMasteringLuminance;
+    mfxU32 MinDisplayMasteringLuminance;
+} mfxExtMasteringDisplayColourVolume;
+
+
+typedef struct {
+    mfxExtBuffer    Header;
+    mfxU16      reserved[9];
+
+    mfxU16 InsertPayloadToggle;
+    mfxU16 MaxContentLightLevel;
+    mfxU16 MaxPicAverageLightLevel;
+} mfxExtContentLightLevelInfo;
+
+
 typedef struct {
   mfxExtBuffer    Header;
   mfxU32      reserved[14];
@@ -1018,6 +1178,7 @@ typedef struct {
     }Layer[8];
 } mfxExtAvcTemporalLayers;
 
+
 typedef struct {
     mfxExtBuffer Header;
 
@@ -1038,7 +1199,7 @@ enum {
 };
 
 typedef struct {
-    mfxExtBuffer    Header; 
+    mfxExtBuffer    Header;
 
     mfxU32          FrameOrder;
     mfxU16          PicStruct;
@@ -1050,30 +1211,31 @@ typedef struct {
     mfxU16          reserved[2];
 
     struct {
-            mfxU32      FrameOrder;
-            mfxU16      PicStruct;
-            mfxU16      LongTermIdx;
-            mfxU16      reserved[4];
+        mfxU32      FrameOrder;
+        mfxU16      PicStruct;
+        mfxU16      LongTermIdx;
+        mfxU16      reserved[4];
     } UsedRefListL0[32], UsedRefListL1[32];
 } mfxExtAVCEncodedFrameInfo;
 
 typedef struct mfxVPPCompInputStream {
-        mfxU32  DstX;
-        mfxU32  DstY;
-        mfxU32  DstW;
-        mfxU32  DstH;
+    mfxU32  DstX;
+    mfxU32  DstY;
+    mfxU32  DstW;
+    mfxU32  DstH;
 
-        mfxU16  LumaKeyEnable;
-        mfxU16  LumaKeyMin;
-        mfxU16  LumaKeyMax;
+    mfxU16  LumaKeyEnable;
+    mfxU16  LumaKeyMin;
+    mfxU16  LumaKeyMax;
 
-        mfxU16  GlobalAlphaEnable;
-        mfxU16  GlobalAlpha;
+    mfxU16  GlobalAlphaEnable;
+    mfxU16  GlobalAlpha;
+    mfxU16  PixelAlphaEnable;
 
-        mfxU16 PixelAlphaEnable;
+    mfxU16  TileId;
 
-        mfxU16  reserved2[18];
-} mfxVPPCompInputStream;     
+    mfxU16  reserved2[17];
+} mfxVPPCompInputStream;
 
 typedef struct {
     mfxExtBuffer    Header;
@@ -1091,11 +1253,11 @@ typedef struct {
         mfxU16   V;
         mfxU16   B;
     };
+    mfxU16       NumTiles;
+    mfxU16       reserved1[23];
 
-    mfxU16      reserved1[24];
-
-    mfxU16      NumInputStream;
-    mfxVPPCompInputStream *InputStream;     
+    mfxU16       NumInputStream;
+    mfxVPPCompInputStream *InputStream;
 } mfxExtVPPComposite;
 
 /* TransferMatrix */
@@ -1116,26 +1278,44 @@ typedef struct {
     mfxExtBuffer    Header;
     mfxU16          reserved1[4];
 
-    struct  {
-        mfxU16  TransferMatrix;
-        mfxU16  NominalRange;
-        mfxU16  reserved2[6];
-    } In, Out;
+    union {
+        struct { // Init
+            struct  {
+                mfxU16  TransferMatrix;
+                mfxU16  NominalRange;
+                mfxU16  reserved2[6];
+            } In, Out;
+        };
+        struct { // Runtime
+            mfxU16  TransferMatrix;
+            mfxU16  NominalRange;
+            mfxU16  reserved3[14];
+        };
+    };
 } mfxExtVPPVideoSignalInfo;
 
+/* ROI encoding mode */
+enum {
+    MFX_ROI_MODE_PRIORITY =  0,
+    MFX_ROI_MODE_QP_DELTA =  1
+};
+
 typedef struct {
     mfxExtBuffer    Header;
 
     mfxU16  NumROI;
-    mfxU16  reserved1[11];
+    mfxU16  ROIMode;
+    mfxU16  reserved1[10];
 
     struct  {
         mfxU32  Left;
         mfxU32  Top;
         mfxU32  Right;
         mfxU32  Bottom;
-
-        mfxI16  Priority;
+        union {
+            mfxI16  Priority;
+            mfxI16  DeltaQP;
+        };
         mfxU16  reserved2[7];
     } ROI[256];
 } mfxExtEncoderROI;
@@ -1152,7 +1332,9 @@ enum {
     MFX_DEINTERLACING_FIXED_TELECINE_PATTERN =  8,
     MFX_DEINTERLACING_30FPS_OUT              =  9,
     MFX_DEINTERLACING_DETECT_INTERLACE       = 10,
-    MFX_DEINTERLACING_ADVANCED_NOREF         = 11
+    MFX_DEINTERLACING_ADVANCED_NOREF         = 11,
+    MFX_DEINTERLACING_ADVANCED_SCD           = 12,
+    MFX_DEINTERLACING_FIELD_WEAVING          = 13
 };
 
 /*TelecinePattern*/
@@ -1209,6 +1391,35 @@ typedef struct {
     mfxU16          reserved[25];
 } mfxExtVPPFieldProcessing;
 
+typedef struct {
+    mfxExtBuffer    Header;
+
+    struct mfxIn{
+        mfxU16  CropX;
+        mfxU16  CropY;
+        mfxU16  CropW;
+        mfxU16  CropH;
+        mfxU16  reserved[12];
+    }In;
+
+    struct mfxOut{
+        mfxU32  FourCC;
+        mfxU16  ChromaFormat;
+        mfxU16  reserved1;
+
+        mfxU16  Width;
+        mfxU16  Height;
+
+        mfxU16  CropX;
+        mfxU16  CropY;
+        mfxU16  CropW;
+        mfxU16  CropH;
+        mfxU16  reserved[22];
+    }Out;
+
+    mfxU16  reserved[13];
+} mfxExtDecVideoProcessing;
+
 typedef struct {
     mfxExtBuffer Header;
 
@@ -1218,17 +1429,37 @@ typedef struct {
     mfxU16       reserved[9];
 } mfxExtChromaLocInfo;
 
+/* MBQPMode */
+enum {
+    MFX_MBQP_MODE_QP_VALUE = 0, // supported in CQP mode only
+    MFX_MBQP_MODE_QP_DELTA = 1
+};
+
 typedef struct {
     mfxExtBuffer    Header;
 
-    mfxU32 reserved[11];
-    mfxU32 NumQPAlloc;
+    mfxU32 reserved[10];
+    mfxU16 Mode;        // see MBQPMode enum
+    mfxU16 BlockSize;   // QP block size, valid for HEVC only during Init and Runtime
+    mfxU32 NumQPAlloc;  // Size of allocated by application QP or DeltaQP array
     union {
-        mfxU8  *QP;
+        mfxU8  *QP;         // Block QP value. Valid when Mode = MFX_MBQP_MODE_QP_VALUE
+        mfxI8  *DeltaQP;    // For block i: QP[i] = BrcQP[i] + DeltaQP[i]. Valid when Mode = MFX_MBQP_MODE_QP_DELTA
         mfxU64 reserved2;
     };
 } mfxExtMBQP;
 
+typedef struct {
+    mfxExtBuffer Header;
+
+    mfxU32 reserved[11];
+    mfxU32 MapSize;
+    union {
+        mfxU8  *Map;
+        mfxU64  reserved2;
+    };
+} mfxExtMBForceIntra;
+
 typedef struct {
     mfxExtBuffer Header;
 
@@ -1239,7 +1470,7 @@ typedef struct {
 
 typedef struct {
     mfxExtBuffer Header;
-    
+
     mfxU32 reserved[11];
     mfxU32 MapSize;
     union {
@@ -1248,6 +1479,7 @@ typedef struct {
     };
 } mfxExtMBDisableSkipMap;
 
+
 /*GeneralConstraintFlags*/
 enum {
     /* REXT Profile constraint flags*/
@@ -1262,6 +1494,16 @@ enum {
     MFX_HEVC_CONSTR_REXT_LOWER_BIT_RATE     = (1 << 8)
 };
 
+
+/* SampleAdaptiveOffset */
+enum {
+    MFX_SAO_UNKNOWN       = 0x00,
+    MFX_SAO_DISABLE       = 0x01,
+    MFX_SAO_ENABLE_LUMA   = 0x02,
+    MFX_SAO_ENABLE_CHROMA = 0x04
+};
+
+
 #pragma pack(push, 4)
 typedef struct {
     mfxExtBuffer    Header;
@@ -1269,10 +1511,29 @@ typedef struct {
     mfxU16          PicWidthInLumaSamples;
     mfxU16          PicHeightInLumaSamples;
     mfxU64          GeneralConstraintFlags;
-    mfxU16          reserved[118];
+    mfxU16          SampleAdaptiveOffset;   /* see enum SampleAdaptiveOffset, valid during Init and Runtime */
+    mfxU16          LCUSize;
+    mfxU16          reserved[116];
 } mfxExtHEVCParam;
 #pragma pack(pop)
 
+/*ErrorTypes in mfxExtDecodeErrorReport*/
+enum {
+    MFX_ERROR_PPS           = (1 << 0),
+    MFX_ERROR_SPS           = (1 << 1),
+    MFX_ERROR_SLICEHEADER   = (1 << 2),
+    MFX_ERROR_SLICEDATA     = (1 << 3),
+    MFX_ERROR_FRAME_GAP     = (1 << 4),
+};
+
+typedef struct {
+    mfxExtBuffer    Header;
+
+    mfxU32          ErrorTypes;
+    mfxU16          reserved[10];
+} mfxExtDecodeErrorReport;
+
+
 typedef struct {
     mfxExtBuffer Header;
 
@@ -1322,6 +1583,18 @@ typedef struct {
     mfxU16       reserved[58];
 } mfxExtPredWeightTable;
 
+typedef struct {
+    mfxExtBuffer Header;
+
+    mfxU16       EnableRoundingIntra;       // tri-state option
+    mfxU16       RoundingOffsetIntra;       // valid value [0,7]
+    mfxU16       EnableRoundingInter;       // tri-state option
+    mfxU16       RoundingOffsetInter;       // valid value [0,7]
+
+    mfxU16       reserved[24];
+} mfxExtAVCRoundingOffset;
+
+
 typedef struct {
     mfxExtBuffer Header;
 
@@ -1356,6 +1629,7 @@ typedef struct {
     } Rect[256];
 } mfxExtMoveRect;
 
+
 /* Angle */
 enum {
     MFX_ANGLE_0     =   0,
@@ -1371,9 +1645,226 @@ typedef struct {
     mfxU16 reserved[11];
 } mfxExtVPPRotation;
 
+typedef struct {
+    mfxExtBuffer Header;
+
+    mfxU16  SliceSizeOverflow;
+    mfxU16  NumSliceNonCopliant;
+    mfxU16  NumEncodedSlice;
+    mfxU16  NumSliceSizeAlloc;
+    union {
+        mfxU16  *SliceSize;
+        mfxU64  reserved1;
+    };
+
+    mfxU16 reserved[20];
+} mfxExtEncodedSlicesInfo;
+
+/* ScalingMode */
+enum {
+    MFX_SCALING_MODE_DEFAULT    = 0,
+    MFX_SCALING_MODE_LOWPOWER   = 1,
+    MFX_SCALING_MODE_QUALITY    = 2
+};
+
+typedef struct {
+    mfxExtBuffer Header;
+
+    mfxU16 ScalingMode;
+    mfxU16 reserved[11];
+} mfxExtVPPScaling;
+
+
+typedef mfxExtAVCRefListCtrl mfxExtHEVCRefListCtrl;
+typedef mfxExtAVCRefLists mfxExtHEVCRefLists;
+typedef mfxExtAvcTemporalLayers mfxExtHEVCTemporalLayers;
+
+/* MirroringType */
+enum
+{
+    MFX_MIRRORING_DISABLED   = 0,
+    MFX_MIRRORING_HORIZONTAL = 1,
+    MFX_MIRRORING_VERTICAL   = 2
+};
+
+typedef struct {
+    mfxExtBuffer Header;
+
+    mfxU16 Type;
+    mfxU16 reserved[11];
+} mfxExtVPPMirroring;
+
+typedef struct {
+    mfxExtBuffer Header;
+
+    mfxU16 StickTop;     /* tri-state option */
+    mfxU16 StickBottom;  /* tri-state option */
+    mfxU16 StickLeft;    /* tri-state option */
+    mfxU16 StickRight;   /* tri-state option */
+    mfxU16 reserved[8];
+} mfxExtMVOverPicBoundaries;
+
+typedef struct {
+    mfxExtBuffer Header;
+
+    mfxU16 Enable;        /* tri-state option */
+    mfxU16 reserved[11];
+} mfxExtVPPColorFill;
+
+
+/* ChromaSiting */
+enum {
+    MFX_CHROMA_SITING_UNKNOWN             = 0x0000,
+    MFX_CHROMA_SITING_VERTICAL_TOP        = 0x0001, /* Chroma samples are co-sited vertically on the top with the luma samples. */
+    MFX_CHROMA_SITING_VERTICAL_CENTER     = 0x0002, /* Chroma samples are not co-sited vertically with the luma samples. */
+    MFX_CHROMA_SITING_VERTICAL_BOTTOM     = 0x0004, /* Chroma samples are co-sited vertically on the bottom with the luma samples. */
+    MFX_CHROMA_SITING_HORIZONTAL_LEFT     = 0x0010, /* Chroma samples are co-sited horizontally on the left with the luma samples. */
+    MFX_CHROMA_SITING_HORIZONTAL_CENTER   = 0x0020  /* Chroma samples are not co-sited horizontally with the luma samples. */
+};
+
+typedef struct {
+    mfxExtBuffer Header;
+
+    mfxU16 ChromaSiting;
+    mfxU16 reserved[27];
+} mfxExtColorConversion;
+
+
+/* VP9ReferenceFrame */
+enum {
+    MFX_VP9_REF_INTRA   = 0,
+    MFX_VP9_REF_LAST    = 1,
+    MFX_VP9_REF_GOLDEN  = 2,
+    MFX_VP9_REF_ALTREF  = 3
+};
+
+/* SegmentIdBlockSize */
+enum {
+    MFX_VP9_SEGMENT_ID_BLOCK_SIZE_UNKNOWN =  0,
+    MFX_VP9_SEGMENT_ID_BLOCK_SIZE_8x8     =  8,
+    MFX_VP9_SEGMENT_ID_BLOCK_SIZE_16x16   = 16,
+    MFX_VP9_SEGMENT_ID_BLOCK_SIZE_32x32   = 32,
+    MFX_VP9_SEGMENT_ID_BLOCK_SIZE_64x64   = 64,
+};
+
+/* SegmentFeature */
+enum {
+    MFX_VP9_SEGMENT_FEATURE_QINDEX      = 0x0001,
+    MFX_VP9_SEGMENT_FEATURE_LOOP_FILTER = 0x0002,
+    MFX_VP9_SEGMENT_FEATURE_REFERENCE   = 0x0004,
+    MFX_VP9_SEGMENT_FEATURE_SKIP        = 0x0008 /* (0,0) MV, no residual */
+};
+
+typedef struct {
+    mfxU16  FeatureEnabled;         /* see enum SegmentFeature */
+    mfxI16  QIndexDelta;
+    mfxI16  LoopFilterLevelDelta;
+    mfxU16  ReferenceFrame;        /* see enum VP9ReferenceFrame */
+    mfxU16  reserved[12];
+} mfxVP9SegmentParam;
+
+typedef struct {
+    mfxExtBuffer        Header;
+    mfxU16              NumSegments;            /* 0..8 */
+    mfxVP9SegmentParam  Segment[8];
+    mfxU16              SegmentIdBlockSize;     /* see enum SegmentIdBlockSize */
+    mfxU32              NumSegmentIdAlloc;      /* >= (Ceil(Width / SegmentIdBlockSize) * Ceil(Height / SegmentIdBlockSize)) */
+    union {
+        mfxU8           *SegmentId;             /*[NumSegmentIdAlloc] = 0..7, index in Segment array, blocks of SegmentIdBlockSize map */
+        mfxU64          reserved1;
+    };
+    mfxU16  reserved[52];
+} mfxExtVP9Segmentation;
+
+typedef struct {
+    mfxU16 FrameRateScale;  /* Layer[n].FrameRateScale = Layer[n - 1].FrameRateScale * (uint)m */
+    mfxU16 TargetKbps;      /* affected by BRCParamMultiplier, Layer[n].TargetKbps > Layer[n - 1].TargetKbps */
+    mfxU16 reserved[14];
+} mfxVP9TemporalLayer;
+
+typedef struct {
+    mfxExtBuffer        Header;
+    mfxVP9TemporalLayer Layer[8];
+    mfxU16              reserved[60];
+} mfxExtVP9TemporalLayers;
+
+typedef struct {
+    mfxExtBuffer Header;
+
+    mfxU16  FrameWidth;
+    mfxU16  FrameHeight;
+
+    mfxU16  WriteIVFHeaders;        /* tri-state option */
+
+    mfxI16  reserved1[6];
+    mfxI16  QIndexDeltaLumaDC;
+    mfxI16  QIndexDeltaChromaAC;
+    mfxI16  QIndexDeltaChromaDC;
+    mfxU16  reserved[112];
+} mfxExtVP9Param;
+
+
+/* Multi-Frame Mode */
+enum {
+    MFX_MF_DEFAULT = 0,
+    MFX_MF_DISABLED = 1,
+    MFX_MF_AUTO = 2,
+    MFX_MF_MANUAL = 3
+};
+
+/* Multi-Frame Initialization parameters */
+typedef struct {
+    mfxExtBuffer Header;
+
+    mfxU16      MFMode;
+    mfxU16      MaxNumFrames;
+
+    mfxU16      reserved[58];
+} mfxExtMultiFrameParam;
+
+/* Multi-Frame Run-time controls */
+typedef struct {
+    mfxExtBuffer Header;
+
+    mfxU32      Timeout;      /* timeout in millisecond */
+    mfxU16      Flush;        /* Flush internal frame buffer, e.g. submit all collected frames. */
+
+    mfxU16      reserved[57];
+} mfxExtMultiFrameControl;
+
+typedef struct {
+    mfxU16 Type;
+    mfxU16 reserved1;
+    mfxU32 Offset;
+    mfxU32 Size;
+    mfxU32 reserved[5];
+} mfxEncodedUnitInfo;
+
+typedef struct {
+    mfxExtBuffer Header;
+
+    union {
+        mfxEncodedUnitInfo *UnitInfo;
+        mfxU64  reserved1;
+    };
+    mfxU16 NumUnitsAlloc;
+    mfxU16 NumUnitsEncoded;
+
+    mfxU16 reserved[22];
+} mfxExtEncodedUnitsInfo;
+
+
+
+/* MCTF initialization & runtime */
+typedef struct {
+    mfxExtBuffer Header;
+    mfxU16       FilterStrength;
+    mfxU16       reserved[27];
+} mfxExtVppMctf;
+
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
 
 #endif
-

+ 4 - 2
plugins/obs-qsv11/libmfx/include/msdk/include/mfxvideo++.h

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2007-2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2007-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -64,6 +64,7 @@ public:
     virtual mfxStatus SetFrameAllocator(mfxFrameAllocator *allocator) { return MFXVideoCORE_SetFrameAllocator(m_session, allocator); }
     virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl) { return MFXVideoCORE_SetHandle(m_session, type, hdl); }
     virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *hdl) { return MFXVideoCORE_GetHandle(m_session, type, hdl); }
+    virtual mfxStatus QueryPlatform(mfxPlatform* platform) { return MFXVideoCORE_QueryPlatform(m_session, platform); }
 
     virtual mfxStatus SyncOperation(mfxSyncPoint syncp, mfxU32 wait) { return MFXVideoCORE_SyncOperation(m_session, syncp, wait); }
 
@@ -164,6 +165,7 @@ public:
     virtual mfxStatus Reset(mfxVideoParam *par) { return MFXVideoENC_Reset(m_session, par); }
     virtual mfxStatus Close(void) { return MFXVideoENC_Close(m_session); }
 
+    virtual mfxStatus GetVideoParam(mfxVideoParam *par) { return MFXVideoENC_GetVideoParam(m_session, par); }
     virtual mfxStatus ProcessFrameAsync(mfxENCInput *in, mfxENCOutput *out, mfxSyncPoint *syncp) { return MFXVideoENC_ProcessFrameAsync(m_session, in, out, syncp); }
 
 protected:
@@ -184,7 +186,7 @@ public:
     virtual mfxStatus Reset(mfxVideoParam *par) { return MFXVideoPAK_Reset(m_session, par); }
     virtual mfxStatus Close(void) { return MFXVideoPAK_Close(m_session); }
 
-    //virtual mfxStatus GetVideoParam(mfxVideoParam *par) { return MFXVideoENCODE_GetVideoParam(m_session, par); }
+    virtual mfxStatus GetVideoParam(mfxVideoParam *par) { return MFXVideoPAK_GetVideoParam(m_session, par); }
     //virtual mfxStatus GetEncodeStat(mfxEncodeStat *stat) { return MFXVideoENCODE_GetEncodeStat(m_session, stat); }
 
     virtual mfxStatus ProcessFrameAsync(mfxPAKInput *in, mfxPAKOutput *out, mfxSyncPoint *syncp) { return MFXVideoPAK_ProcessFrameAsync(m_session, in, out, syncp); }

+ 2 - 4
plugins/obs-qsv11/libmfx/include/msdk/include/mfxvideo.h

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2007-2015 Intel Corporation.  All rights reserved.
+Copyright (C) 2007-2017 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -32,9 +32,6 @@ File Name: mfxvideo.h
 #include "mfxsession.h"
 #include "mfxvstructures.h"
 
-#define MFX_VERSION_MAJOR 1
-#define MFX_VERSION_MINOR 17
-
 #ifdef __cplusplus
 extern "C"
 {
@@ -66,6 +63,7 @@ mfxStatus MFX_CDECL MFXVideoCORE_SetBufferAllocator(mfxSession session, mfxBuffe
 mfxStatus MFX_CDECL MFXVideoCORE_SetFrameAllocator(mfxSession session, mfxFrameAllocator *allocator);
 mfxStatus MFX_CDECL MFXVideoCORE_SetHandle(mfxSession session, mfxHandleType type, mfxHDL hdl);
 mfxStatus MFX_CDECL MFXVideoCORE_GetHandle(mfxSession session, mfxHandleType type, mfxHDL *hdl);
+mfxStatus MFX_CDECL MFXVideoCORE_QueryPlatform(mfxSession session, mfxPlatform* platform);
 mfxStatus MFX_CDECL MFXVideoCORE_SyncOperation(mfxSession session, mfxSyncPoint syncp, mfxU32 wait);
 
 /* VideoENCODE */

+ 283 - 166
plugins/obs-qsv11/libmfx/src/main.cpp

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2012-2015 Intel Corporation.  All rights reserved.
+Copyright (C) 2012-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -28,6 +28,9 @@ File Name: main.cpp
 
 \* ****************************************************************************** */
 
+#include <new>
+#include <memory>
+
 #include "mfx_dispatcher.h"
 #include "mfx_load_dll.h"
 #include "mfx_dispatcher_log.h"
@@ -35,7 +38,7 @@ File Name: main.cpp
 #include "mfx_critical_section.h"
 
 #include <string.h> /* for memset on Linux */
-#include <memory>
+
 #include <stdlib.h> /* for qsort on Linux */
 #include "mfx_load_plugin.h"
 #include "mfx_plugin_hive.h"
@@ -66,7 +69,7 @@ namespace
         {MFX_LIB_HARDWARE, MFX_IMPL_HARDWARE3, 2},
         {MFX_LIB_HARDWARE, MFX_IMPL_HARDWARE4, 3},
         {MFX_LIB_SOFTWARE, MFX_IMPL_SOFTWARE,  0},
-        {MFX_LIB_SOFTWARE, MFX_IMPL_SOFTWARE | MFX_IMPL_AUDIO,  0}
+        {MFX_LIB_SOFTWARE, MFX_IMPL_SOFTWARE | MFX_IMPL_AUDIO,  0},
     };
 
     const
@@ -78,16 +81,17 @@ namespace
         mfxU32 maxIndex;
 
     } implTypesRange[] =
-    {    
-        {0, 1},  // MFX_IMPL_AUTO    
-        {1, 1},  // MFX_IMPL_SOFTWARE    
-        {0, 0},  // MFX_IMPL_HARDWARE    
-        {2, 6},  // MFX_IMPL_AUTO_ANY    
-        {2, 5},  // MFX_IMPL_HARDWARE_ANY    
-        {3, 3},  // MFX_IMPL_HARDWARE2    
-        {4, 4},  // MFX_IMPL_HARDWARE3    
+    {
+        {0, 1},  // MFX_IMPL_AUTO
+        {1, 1},  // MFX_IMPL_SOFTWARE
+        {0, 0},  // MFX_IMPL_HARDWARE
+        {2, 6},  // MFX_IMPL_AUTO_ANY
+        {2, 5},  // MFX_IMPL_HARDWARE_ANY
+        {3, 3},  // MFX_IMPL_HARDWARE2
+        {4, 4},  // MFX_IMPL_HARDWARE3
         {5, 5},  // MFX_IMPL_HARDWARE4
         {2, 6},  // MFX_IMPL_RUNTIME, same as MFX_IMPL_HARDWARE_ANY
+        {8, 11},  // MFX_SINGLE_THREAD,
         {7, 7}   // MFX_IMPL_AUDIO
     };
 
@@ -96,6 +100,36 @@ namespace
 } // namespace
 
 using namespace MFX;
+
+#if defined(MEDIASDK_UWP_LOADER)
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+    //
+    // intel_gfx_api-*.dll calls these functions to do not mix MFXInitEx exposed 
+    // from dispatcher_proc_table.lib with the libmfx[hw/sw] engines' call MFXInitEx
+    //
+
+    mfxStatus InitMediaSDKSession(mfxInitParam par, mfxSession* session)
+    {
+        return MFXInitEx(par, session);
+    }
+
+    mfxStatus DisposeMediaSDKSession(mfxSession session)
+    {
+        return MFXClose(session);
+    }
+
+#ifdef __cplusplus
+}; //extern "C"
+#endif /* __cplusplus */
+
+#endif // defined(MEDIASDK_UWP_LOADER)
+
+#if !defined(MEDIASDK_UWP_PROCTABLE)
+
 //
 // Implement DLL exposed functions. MFXInit and MFXClose have to do
 // slightly more than other. They require to be implemented explicitly.
@@ -110,7 +144,7 @@ struct VectorHandleGuard
     VectorHandleGuard(HandleVector& aVector): m_vector(aVector) {}
     ~VectorHandleGuard()
     {
-        HandleVector::iterator it = m_vector.begin(), 
+        HandleVector::iterator it = m_vector.begin(),
                                et = m_vector.end();
         for ( ; it != et; ++it)
         {
@@ -129,16 +163,16 @@ int HandleSort (const void * plhs, const void * prhs)
     const MFX_DISP_HANDLE * lhs = *(const MFX_DISP_HANDLE **)plhs;
     const MFX_DISP_HANDLE * rhs = *(const MFX_DISP_HANDLE **)prhs;
 
-    if (lhs->actualApiVersion < rhs->actualApiVersion) 
+    if (lhs->actualApiVersion < rhs->actualApiVersion)
     {
         return -1;
     }
-    if (rhs->actualApiVersion < lhs->actualApiVersion) 
+    if (rhs->actualApiVersion < lhs->actualApiVersion)
     {
         return 1;
     }
 
-    // if versions are equal prefer library with HW 
+    // if versions are equal prefer library with HW
     if (lhs->loadStatus == MFX_WRN_PARTIAL_ACCELERATION && rhs->loadStatus == MFX_ERR_NONE)
     {
         return 1;
@@ -151,24 +185,8 @@ int HandleSort (const void * plhs, const void * prhs)
     return 0;
 }
 
-mfxStatus MFXInit(mfxIMPL impl, mfxVersion *pVer, mfxSession *session)
-{
-    mfxInitParam par = {};
-
-    par.Implementation = impl;
-    if (pVer)
-    {
-        par.Version = *pVer;
-    }
-    else
-    {
-        par.Version.Major = DEFAULT_API_VERSION_MAJOR;
-        par.Version.Minor = DEFAULT_API_VERSION_MINOR;
-    }
-    par.ExternalThreads = 0;
-
-    return MFXInitEx(par, session);
-}
+// for LEGACY and UWP_LOADER purposes implementation of MFXinitEx is traditionally loading
+// required libmfx*.dll and fill the array of API functions' with corresponded pointers to instantiated libmfx*.dll
 
 mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
 {
@@ -186,8 +204,9 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
     VectorHandleGuard handleGuard(allocatedHandle);
 
     MFX_DISP_HANDLE *pHandle;
-    msdk_disp_char dllName[MFX_MAX_DLL_PATH];
+    msdk_disp_char dllName[MFX_MAX_DLL_PATH] = { 0 };
     MFX::MFXLibraryIterator libIterator;
+
     // there iterators are used only if the caller specified implicit type like AUTO
     mfxU32 curImplIdx, maxImplIdx;
     // particular implementation value
@@ -232,7 +251,6 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
     // Load HW library or RT from system location
     curImplIdx = implTypesRange[implMethod].minIndex;
     maxImplIdx = implTypesRange[implMethod].maxIndex;
-    mfxU32 hwImplIdx = 0;
     do
     {
         int currentStorage = MFX::MFX_STORAGE_ID_FIRST;
@@ -240,7 +258,7 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
         do
         {
             // initialize the library iterator
-            mfxRes = libIterator.Init(implTypes[curImplIdx].implType, 
+            mfxRes = libIterator.Init(implTypes[curImplIdx].implType,
                 implInterface,
                 implTypes[curImplIdx].adapterID,
                 currentStorage);
@@ -252,7 +270,7 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
 
                 if (
                     MFX_LIB_HARDWARE == implTypes[curImplIdx].implType
-                    && (!implInterface 
+                    && (!implInterface
                     || MFX_IMPL_VIA_ANY == implInterface))
                 {
                     implInterface = libIterator.GetImplementationType();
@@ -260,7 +278,7 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
 
                 do
                 {
-                    eMfxImplType implType;
+                    eMfxImplType implType = implTypes[curImplIdx].implType;
 
                     // select a desired DLL
                     mfxRes = libIterator.SelectDLLVersion(dllName,
@@ -272,8 +290,6 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
                         break;
                     }
                     DISPATCHER_LOG_INFO((("loading library %S\n"), MSDK2WIDE(dllName)));
-                    if (MFX_LIB_HARDWARE == implTypes[curImplIdx].implType)
-                        hwImplIdx = curImplIdx;
                     // try to load the selected DLL
                     curImpl = implTypes[curImplIdx].impl;
                     mfxRes = pHandle->LoadSelectedDLL(dllName, implType, curImpl, implInterface, par);
@@ -284,7 +300,7 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
                     }
                     else
                     {
-                        libIterator.GetSubKeyName(pHandle->subkeyName, sizeof(pHandle->subkeyName)/sizeof(pHandle->subkeyName[0])) ;
+                        libIterator.GetSubKeyName(pHandle->subkeyName, sizeof(pHandle->subkeyName) / sizeof(pHandle->subkeyName[0]));
                         pHandle->storageID = libIterator.GetStorageID();
                         allocatedHandle.push_back(pHandle);
                         pHandle = new MFX_DISP_HANDLE(requiredVersion);
@@ -293,7 +309,7 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
                 } while (MFX_ERR_NONE != mfxRes);
             }
 
-            // select another registry key
+            // select another place for loading engine
             currentStorage += 1;
 
         } while ((MFX_ERR_NONE != mfxRes) && (MFX::MFX_STORAGE_ID_LAST >= currentStorage));
@@ -304,12 +320,15 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
     curImplIdx = implTypesRange[implMethod].minIndex;
     maxImplIdx = implTypesRange[implMethod].maxIndex;
 
+    // SOLID dispatcher checks if there are other available media sdk engines implementations in working dir
+    // UWP dispatcher does not use libraries other than in System32 folder
+#if !defined(MEDIASDK_UWP_LOADER)
     // Load RT from app folder (libmfxsw64 with API >= 1.10)
     do
     {
         implInterface = implInterfaceOrig;
         // initialize the library iterator
-        mfxRes = libIterator.Init(implTypes[curImplIdx].implType, 
+        mfxRes = libIterator.Init(implTypes[curImplIdx].implType,
             implInterface,
             implTypes[curImplIdx].adapterID,
             MFX::MFX_APP_FOLDER);
@@ -319,7 +338,7 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
 
             if (
                 MFX_LIB_HARDWARE == implTypes[curImplIdx].implType
-                && (!implInterface 
+                && (!implInterface
                 || MFX_IMPL_VIA_ANY == implInterface))
             {
                 implInterface = libIterator.GetImplementationType();
@@ -365,18 +384,15 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
         }
     } while ((MFX_ERR_NONE != mfxRes) && (++curImplIdx <= maxImplIdx));
 
+#endif // !defined(MEDIASDK_UWP_LOADER)
+
     // Load HW and SW libraries using legacy default DLL search mechanism
     // set current library index again
     curImplIdx = implTypesRange[implMethod].minIndex;
     do
     {
-        mfxU32 backupIdx = curImplIdx;
-        if (MFX_LIB_HARDWARE == implTypes[curImplIdx].implType)
-        {
-            curImplIdx = hwImplIdx;
-        }
         implInterface = implInterfaceOrig;
-            
+
         if (par.Implementation & MFX_IMPL_AUDIO)
         {
             mfxRes = MFX::mfx_get_default_audio_dll_name(dllName,
@@ -397,11 +413,14 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
                 // try to load the selected DLL using default DLL search mechanism
                 if (MFX_LIB_HARDWARE == implTypes[curImplIdx].implType)
                 {
-                    if (!implInterface) 
+                    if (!implInterface)
                     {
                         implInterface = MFX_IMPL_VIA_ANY;
                     }
-                    mfxRes = MFX::SelectImplementationType(implTypes[curImplIdx].adapterID, &implInterface, NULL, NULL);
+                    mfxU32 curVendorID = 0, curDeviceID = 0;
+                    mfxRes = MFX::SelectImplementationType(implTypes[curImplIdx].adapterID, &implInterface, &curVendorID, &curDeviceID);
+                    if (curVendorID != INTEL_VENDOR_ID)
+                        mfxRes = MFX_ERR_UNKNOWN;
                 }
                 if (MFX_ERR_NONE == mfxRes)
                 {
@@ -419,13 +438,12 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
                     pHandle->Close();
                 }
                 else
-                {                    
+                {
                     pHandle->storageID = MFX::MFX_UNKNOWN_KEY;
                     allocatedHandle.push_back(pHandle);
                     pHandle = new MFX_DISP_HANDLE(requiredVersion);
                 }
         }
-        curImplIdx = backupIdx;
     }
     while ((MFX_ERR_NONE > mfxRes) && (++curImplIdx <= maxImplIdx));
     delete pHandle;
@@ -433,28 +451,29 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
     if (allocatedHandle.size() == 0)
         return MFX_ERR_UNSUPPORTED;
 
-    bool NeedSort = false;
-    HandleVector::iterator first = allocatedHandle.begin(),
-                           it = allocatedHandle.begin(),
-                           et = allocatedHandle.end();
-    for (it++; it != et; ++it)
-        if (HandleSort(&(*first), &(*it)) != 0)
-            NeedSort = true;
-
-    // select dll with version with lowest version number still greater or equal to requested
-    if (NeedSort)
-        qsort(&(*allocatedHandle.begin()), allocatedHandle.size(), sizeof(MFX_DISP_HANDLE*), &HandleSort);
-
+    { // sort candidate list
+        bool NeedSort = false;
+        HandleVector::iterator first = allocatedHandle.begin(),
+            it = allocatedHandle.begin(),
+            et = allocatedHandle.end();
+        for (it++; it != et; ++it)
+            if (HandleSort(&(*first), &(*it)) != 0)
+                NeedSort = true;
+
+        // select dll with version with lowest version number still greater or equal to requested
+        if (NeedSort)
+            qsort(&(*allocatedHandle.begin()), allocatedHandle.size(), sizeof(MFX_DISP_HANDLE*), &HandleSort);
+    }
     HandleVector::iterator candidate = allocatedHandle.begin();
     // check the final result of loading
-    try 
+    try
     {
         pHandle = *candidate;
         //pulling up current mediasdk version, that required to match plugin version
-        mfxVersion apiVerActual;
-        mfxStatus stsQueryVersion;
-        stsQueryVersion = MFXQueryVersion((mfxSession)pHandle, &apiVerActual);
-        if (MFX_ERR_NONE !=  stsQueryVersion) 
+        mfxVersion apiVerActual = { 0 };
+        mfxStatus stsQueryVersion = MFXQueryVersion((mfxSession)pHandle, &apiVerActual);
+
+        if (MFX_ERR_NONE !=  stsQueryVersion)
         {
             DISPATCHER_LOG_ERROR((("MFXQueryVersion returned: %d, cannot load plugins\n"), mfxRes))
         }
@@ -479,15 +498,26 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
             }
 
             //setting up plugins records
-            for(int i = MFX::MFX_STORAGE_ID_FIRST; i <= MFX::MFX_STORAGE_ID_LAST; i++) 
+            for(int i = MFX::MFX_STORAGE_ID_FIRST; i <= MFX::MFX_STORAGE_ID_LAST; i++)
             {
                 MFX::MFXPluginsInHive plgsInHive(i, NULL, apiVerActual);
                 hive.insert(hive.end(), plgsInHive.begin(), plgsInHive.end());
             }
 
+#if defined(MEDIASDK_USE_CFGFILES) || !defined(MEDIASDK_UWP_LOADER)
+            // SOLID dispatcher also loads plug-ins from file system
             MFX::MFXPluginsInFS plgsInFS(apiVerActual);
             hive.insert(hive.end(), plgsInFS.begin(), plgsInFS.end());
+#endif // defined(MEDIASDK_USE_CFGFILES) || !defined(MEDIASDK_UWP_LOADER)
         }
+
+        // UWP dispatcher uses stubs
+        pHandle->callPlugInsTable[eMFXVideoUSER_Load] = (mfxFunctionPointer)MFXVideoUSER_Load;
+        pHandle->callPlugInsTable[eMFXVideoUSER_LoadByPath] = (mfxFunctionPointer)MFXVideoUSER_LoadByPath;
+        pHandle->callPlugInsTable[eMFXVideoUSER_UnLoad] = (mfxFunctionPointer)MFXVideoUSER_UnLoad;
+        pHandle->callPlugInsTable[eMFXAudioUSER_Load] = (mfxFunctionPointer)MFXAudioUSER_Load;
+        pHandle->callPlugInsTable[eMFXAudioUSER_UnLoad] = (mfxFunctionPointer)MFXAudioUSER_UnLoad;
+
     }
     catch(...)
     {
@@ -495,12 +525,12 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
     }
 
     // everything is OK. Save pointers to the output variable
-    *candidate = 0; // keep this one safe from guard destructor 
+    *candidate = 0; // keep this one safe from guard destructor
     *((MFX_DISP_HANDLE **) session) = pHandle;
 
     return pHandle->loadStatus;
 
-} // mfxStatus MFXInit(mfxIMPL impl, mfxVersion *ver, mfxSession *session)
+} // mfxStatus MFXInitEx(mfxIMPL impl, mfxVersion *ver, mfxSession *session)
 
 mfxStatus MFXClose(mfxSession session)
 {
@@ -535,73 +565,6 @@ mfxStatus MFXClose(mfxSession session)
 
 } // mfxStatus MFXClose(mfxSession session)
 
-mfxStatus MFXJoinSession(mfxSession session, mfxSession child_session)
-{
-    mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE;
-    MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *) session;
-    MFX_DISP_HANDLE *pChildHandle = (MFX_DISP_HANDLE *) child_session;
-
-    // get the function's address and make a call
-    if ((pHandle) && (pChildHandle) && (pHandle->apiVersion == pChildHandle->apiVersion))
-    {
-        /* check whether it is audio session or video */
-        int tableIndex = eMFXJoinSession; 
-        mfxFunctionPointer pFunc;
-        if (pHandle->impl & MFX_IMPL_AUDIO) 
-        { 
-            pFunc = pHandle->callAudioTable[tableIndex];
-        }
-        else
-        {
-            pFunc = pHandle->callTable[tableIndex];
-        }
-
-        if (pFunc)
-        {
-            // pass down the call
-            mfxRes = (*(mfxStatus (MFX_CDECL *) (mfxSession, mfxSession)) pFunc) (pHandle->session, 
-                pChildHandle->session);
-        }
-    }
-
-    return mfxRes;
-
-} // mfxStatus MFXJoinSession(mfxSession session, mfxSession child_session)
-
-mfxStatus MFXCloneSession(mfxSession session, mfxSession *clone)
-{
-    mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE;
-    MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *) session;
-    mfxVersion apiVersion;
-    mfxIMPL impl;
-
-    // check error(s)
-    if (pHandle)
-    {
-        // initialize the clone session
-        apiVersion = pHandle->apiVersion;
-        impl = pHandle->impl | pHandle->implInterface;
-        mfxRes = MFXInit(impl, &apiVersion, clone);
-        if (MFX_ERR_NONE != mfxRes)
-        {
-            return mfxRes;
-        }
-
-        // join the sessions
-        mfxRes = MFXJoinSession(session, *clone);
-        if (MFX_ERR_NONE != mfxRes)
-        {
-            MFXClose(*clone);
-            *clone = NULL;
-            return mfxRes;
-        }
-    }
-
-    return mfxRes;
-
-} // mfxStatus MFXCloneSession(mfxSession session, mfxSession *clone)
-
-
 mfxStatus MFXVideoUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32 version)
 {
     mfxStatus sts = MFX_ERR_NONE;
@@ -617,7 +580,7 @@ mfxStatus MFXVideoUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32
         DISPATCHER_LOG_ERROR((("MFXVideoUSER_Load: uid=NULL\n")));
         return MFX_ERR_NULL_PTR;
     }
-    DISPATCHER_LOG_INFO((("MFXVideoUSER_Load: uid="MFXGUIDTYPE()" version=%d\n")
+    DISPATCHER_LOG_INFO((("MFXVideoUSER_Load: uid=" MFXGUIDTYPE()" version=%d\n")
         , MFXGUIDTOHEX(uid)
         , version))
         size_t pluginsChecked = 0;
@@ -631,7 +594,7 @@ mfxStatus MFXVideoUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32
         //check rest in records
         if (i->PluginVersion < version)
         {
-            DISPATCHER_LOG_INFO((("MFXVideoUSER_Load: registered \"Plugin Version\" for GUID="MFXGUIDTYPE()" is %d, that is smaller that requested\n")
+            DISPATCHER_LOG_INFO((("MFXVideoUSER_Load: registered \"Plugin Version\" for GUID=" MFXGUIDTYPE()" is %d, that is smaller that requested\n")
                 , MFXGUIDTOHEX(uid)
                 , i->PluginVersion))
                 continue;
@@ -698,7 +661,7 @@ mfxStatus MFXVideoUSER_LoadByPath(mfxSession session, const mfxPluginUID *uid, m
         return MFX_ERR_NULL_PTR;
     }
 
-    DISPATCHER_LOG_INFO((("MFXVideoUSER_LoadByPath: %S uid="MFXGUIDTYPE()" version=%d\n")
+    DISPATCHER_LOG_INFO((("MFXVideoUSER_LoadByPath: %S uid=" MFXGUIDTYPE()" version=%d\n")
         , MSDK2WIDE(path)
         , MFXGUIDTOHEX(uid)
         , version))
@@ -708,18 +671,20 @@ mfxStatus MFXVideoUSER_LoadByPath(mfxSession session, const mfxPluginUID *uid, m
 
 #ifdef _WIN32
     msdk_disp_char wPath[MAX_PLUGIN_PATH];
-    int res = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path, len, wPath, MAX_PLUGIN_PATH);
+    int res = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path, len<MAX_PLUGIN_PATH-1 ? len : MAX_PLUGIN_PATH-1, wPath, MAX_PLUGIN_PATH);
+    wPath[res]=0;
+
     if (!res)
     {
         DISPATCHER_LOG_ERROR((("MFXVideoUSER_LoadByPath: cant convert UTF-8 path to UTF-16\n")));
         return MFX_ERR_NOT_FOUND;
     }
-    msdk_disp_char_cpy_s(record.sPath, res < MAX_PLUGIN_PATH ? res : MAX_PLUGIN_PATH, wPath);
-#else // Linux/Android 
-    msdk_disp_char_cpy_s(record.sPath, len < MAX_PLUGIN_PATH ? len : MAX_PLUGIN_PATH, path);
+    msdk_disp_char_cpy_s(record.sPath, MAX_PLUGIN_PATH, wPath);
+#else // Linux/Android
+    msdk_disp_char_cpy_s(record.sPath, MAX_PLUGIN_PATH, path);
 #endif
-    
-    record.PluginUID = *uid; 
+
+    record.PluginUID = *uid;
     record.PluginVersion = (mfxU16)version;
     record.Default = true;
 
@@ -737,24 +702,24 @@ mfxStatus MFXVideoUSER_LoadByPath(mfxSession session, const mfxPluginUID *uid, m
 mfxStatus MFXVideoUSER_UnLoad(mfxSession session, const mfxPluginUID *uid)
 {
     MFX_DISP_HANDLE &rHandle = *(MFX_DISP_HANDLE *) session;
-    if (!&rHandle) 
+    if (!&rHandle)
     {
         DISPATCHER_LOG_ERROR((("MFXVideoUSER_UnLoad: session=NULL\n")));
         return MFX_ERR_NULL_PTR;
     }
     if (!uid)
     {
-        DISPATCHER_LOG_ERROR((("MFXVideoUSER_Load: uid=NULL\n")));
+        DISPATCHER_LOG_ERROR((("MFXVideoUSER_UnLoad: uid=NULL\n")));
         return MFX_ERR_NULL_PTR;
     }
 
     bool bDestroyed = rHandle.pluginFactory.Destroy(*uid);
-    if (bDestroyed) 
+    if (bDestroyed)
     {
-        DISPATCHER_LOG_INFO((("MFXVideoUSER_UnLoad : plugin with GUID="MFXGUIDTYPE()" unloaded\n"), MFXGUIDTOHEX(uid)));
-    } else 
+        DISPATCHER_LOG_INFO((("MFXVideoUSER_UnLoad : plugin with GUID=" MFXGUIDTYPE()" unloaded\n"), MFXGUIDTOHEX(uid)));
+    } else
     {
-        DISPATCHER_LOG_ERROR((("MFXVideoUSER_UnLoad : plugin with GUID="MFXGUIDTYPE()" not found\n"), MFXGUIDTOHEX(uid)));
+        DISPATCHER_LOG_ERROR((("MFXVideoUSER_UnLoad : plugin with GUID=" MFXGUIDTYPE()" not found\n"), MFXGUIDTOHEX(uid)));
     }
 
     return bDestroyed ? MFX_ERR_NONE : MFX_ERR_NOT_FOUND;
@@ -773,7 +738,7 @@ mfxStatus MFXAudioUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32
         DISPATCHER_LOG_ERROR((("MFXAudioUSER_Load: uid=NULL\n")));
         return MFX_ERR_NULL_PTR;
     }
-    DISPATCHER_LOG_INFO((("MFXAudioUSER_Load: uid="MFXGUIDTYPE()" version=%d\n")
+    DISPATCHER_LOG_INFO((("MFXAudioUSER_Load: uid=" MFXGUIDTYPE()" version=%d\n")
         , MFXGUIDTOHEX(uid)
         , version))
         size_t pluginsChecked = 0;
@@ -791,7 +756,7 @@ mfxStatus MFXAudioUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32
         //check rest in records
         if (i->PluginVersion < version)
         {
-            DISPATCHER_LOG_INFO((("MFXAudioUSER_Load: registered \"Plugin Version\" for GUID="MFXGUIDTYPE()" is %d, that is smaller that requested\n")
+            DISPATCHER_LOG_INFO((("MFXAudioUSER_Load: registered \"Plugin Version\" for GUID=" MFXGUIDTYPE()" is %d, that is smaller that requested\n")
                 , MFXGUIDTOHEX(uid)
                 , i->PluginVersion))
                 continue;
@@ -825,7 +790,7 @@ mfxStatus MFXAudioUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32
 mfxStatus MFXAudioUSER_UnLoad(mfxSession session, const mfxPluginUID *uid)
 {
     MFX_DISP_HANDLE &rHandle = *(MFX_DISP_HANDLE *) session;
-    if (!&rHandle) 
+    if (!&rHandle)
     {
         DISPATCHER_LOG_ERROR((("MFXAudioUSER_UnLoad: session=NULL\n")));
         return MFX_ERR_NULL_PTR;
@@ -837,17 +802,162 @@ mfxStatus MFXAudioUSER_UnLoad(mfxSession session, const mfxPluginUID *uid)
     }
 
     bool bDestroyed = rHandle.pluginFactory.Destroy(*uid);
-    if (bDestroyed) 
+    if (bDestroyed)
     {
-        DISPATCHER_LOG_INFO((("MFXAudioUSER_UnLoad : plugin with GUID="MFXGUIDTYPE()" unloaded\n"), MFXGUIDTOHEX(uid)));
-    } else 
+        DISPATCHER_LOG_INFO((("MFXAudioUSER_UnLoad : plugin with GUID=" MFXGUIDTYPE()" unloaded\n"), MFXGUIDTOHEX(uid)));
+    } else
     {
-        DISPATCHER_LOG_ERROR((("MFXAudioUSER_UnLoad : plugin with GUID="MFXGUIDTYPE()" not found\n"), MFXGUIDTOHEX(uid)));
+        DISPATCHER_LOG_ERROR((("MFXAudioUSER_UnLoad : plugin with GUID=" MFXGUIDTYPE()" not found\n"), MFXGUIDTOHEX(uid)));
     }
 
     return bDestroyed ? MFX_ERR_NONE : MFX_ERR_NOT_FOUND;
 }
+#else // relates to !defined (MEDIASDK_UWP_PROCTABLE) from line 137, i.e. #else part as if MEDIASDK_UWP_PROCTABLE defined
+
+#include <windows.h>
+#include "intel_api_factory.h"
+
+// for the UWP_PROCTABLE purposes implementation of MFXinitEx is calling
+// InitializeInstance() implemented in intel_uwp-api.dll
+mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
+{
+    HRESULT hr = InitialiseMediaSession((HANDLE*)session, &par, nullptr);
+    return (hr == S_OK) ? mfxStatus::MFX_ERR_NONE : (mfxStatus)hr;
+}
+
+// for the UWP_PROCTABLE purposes implementation of MFXClose is calling
+// DisposeInstance() implemented in intel_uwp-api.dll
+mfxStatus MFXClose(mfxSession session)
+{
+    if (nullptr == session) {
+        return MFX_ERR_INVALID_HANDLE;
+    }
+
+    HRESULT hr = DisposeMediaSession(HANDLE(session));
+    session = (mfxSession)NULL;
+    return (hr == S_OK) ? MFX_ERR_NONE : mfxStatus(hr);
+}
+
+#undef FUNCTION
+#define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) \
+    return_value func_name formal_param_list \
+{ \
+    mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE; \
+\
+    _mfxSession *pHandle = (_mfxSession *) session; \
+\
+    /* get the function's address and make a call */ \
+    if (pHandle) \
+{ \
+    mfxFunctionPointer pFunc = pHandle->callPlugInsTable[e##func_name]; \
+    if (pFunc) \
+{ \
+    /* pass down the call */ \
+    mfxRes = (*(mfxStatus (MFX_CDECL  *) formal_param_list) pFunc) actual_param_list; \
+} \
+} \
+    return mfxRes; \
+}
+
+FUNCTION(mfxStatus, MFXVideoUSER_Load, (mfxSession session, const mfxPluginUID *uid, mfxU32 version), (session, uid, version))
+FUNCTION(mfxStatus, MFXVideoUSER_LoadByPath, (mfxSession session, const mfxPluginUID *uid, mfxU32 version, const mfxChar *path, mfxU32 len), (session, uid, version, path, len))
+FUNCTION(mfxStatus, MFXVideoUSER_UnLoad, (mfxSession session, const mfxPluginUID *uid), (session, uid))
+FUNCTION(mfxStatus, MFXAudioUSER_Load, (mfxSession session, const mfxPluginUID *uid, mfxU32 version), (session, uid, version))
+FUNCTION(mfxStatus, MFXAudioUSER_UnLoad, (mfxSession session, const mfxPluginUID *uid), (session, uid))
+
+#endif //!defined(MEDIASDK_UWP_PROCTABLE)
 
+
+#if !defined(MEDIASDK_UWP_LOADER)
+
+mfxStatus MFXJoinSession(mfxSession session, mfxSession child_session)
+{
+    mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE;
+    MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *)session;
+    MFX_DISP_HANDLE *pChildHandle = (MFX_DISP_HANDLE *)child_session;
+
+    // get the function's address and make a call
+    if ((pHandle) && (pChildHandle) && (pHandle->apiVersion == pChildHandle->apiVersion))
+    {
+        /* check whether it is audio session or video */
+        int tableIndex = eMFXJoinSession;
+        mfxFunctionPointer pFunc;
+        if (pHandle->impl & MFX_IMPL_AUDIO)
+        {
+            pFunc = pHandle->callAudioTable[tableIndex];
+        }
+        else
+        {
+            pFunc = pHandle->callTable[tableIndex];
+        }
+
+        if (pFunc)
+        {
+            // pass down the call
+            mfxRes = (*(mfxStatus(MFX_CDECL *) (mfxSession, mfxSession)) pFunc) (pHandle->session,
+                pChildHandle->session);
+        }
+    }
+
+    return mfxRes;
+
+} // mfxStatus MFXJoinSession(mfxSession session, mfxSession child_session)
+
+mfxStatus MFXCloneSession(mfxSession session, mfxSession *clone)
+{
+    mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE;
+    MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *)session;
+    mfxVersion apiVersion;
+    mfxIMPL impl;
+
+    // check error(s)
+    if (pHandle)
+    {
+        // initialize the clone session
+        apiVersion = pHandle->apiVersion;
+        impl = pHandle->impl | pHandle->implInterface;
+        mfxRes = MFXInit(impl, &apiVersion, clone);
+        if (MFX_ERR_NONE != mfxRes)
+        {
+            return mfxRes;
+        }
+
+        // join the sessions
+        mfxRes = MFXJoinSession(session, *clone);
+        if (MFX_ERR_NONE != mfxRes)
+        {
+            MFXClose(*clone);
+            *clone = NULL;
+            return mfxRes;
+        }
+    }
+
+    return mfxRes;
+
+} // mfxStatus MFXCloneSession(mfxSession session, mfxSession *clone)
+
+#endif // !defined(MEDIASDK_UWP_LOADER)
+
+mfxStatus MFXInit(mfxIMPL impl, mfxVersion *pVer, mfxSession *session)
+{
+    mfxInitParam par = {};
+
+    par.Implementation = impl;
+    if (pVer)
+    {
+        par.Version = *pVer;
+    }
+    else
+    {
+        par.Version.Major = DEFAULT_API_VERSION_MAJOR;
+        par.Version.Minor = DEFAULT_API_VERSION_MINOR;
+    }
+    par.ExternalThreads = 0;
+
+    return MFXInitEx(par, session);
+}
+
+//
 //
 // implement all other calling functions.
 // They just call a procedure of DLL library from the table.
@@ -859,7 +969,7 @@ mfxStatus MFXAudioUSER_UnLoad(mfxSession session, const mfxPluginUID *uid)
     return_value func_name formal_param_list \
 { \
     mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE; \
-    MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *) session; \
+     _mfxSession *pHandle = (_mfxSession *) session; \
     /* get the function's address and make a call */ \
     if (pHandle) \
 { \
@@ -887,16 +997,23 @@ mfxStatus MFXAudioUSER_UnLoad(mfxSession session, const mfxPluginUID *uid)
 
 FUNCTION(mfxStatus, MFXQueryIMPL, (mfxSession session, mfxIMPL *impl), (session, impl))
 FUNCTION(mfxStatus, MFXQueryVersion, (mfxSession session, mfxVersion *version), (session, version))
+
+#if !defined(MEDIASDK_UWP_LOADER)
+// these functions are not necessary in LOADER part of dispatcher and
+// need to be included only in in SOLID dispatcher or PROCTABLE part of dispatcher
+
 FUNCTION(mfxStatus, MFXDisjoinSession, (mfxSession session), (session))
 FUNCTION(mfxStatus, MFXSetPriority, (mfxSession session, mfxPriority priority), (session, priority))
 FUNCTION(mfxStatus, MFXGetPriority, (mfxSession session, mfxPriority *priority), (session, priority))
 
+#endif // !defined(MEDIASDK_UWP_LOADER)
+
 #undef FUNCTION
 #define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) \
     return_value func_name formal_param_list \
 { \
     mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE; \
-    MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *) session; \
+     _mfxSession *pHandle = (_mfxSession *) session;\
     /* get the function's address and make a call */ \
     if (pHandle) \
 { \
@@ -918,7 +1035,7 @@ FUNCTION(mfxStatus, MFXGetPriority, (mfxSession session, mfxPriority *priority),
     return_value func_name formal_param_list \
 { \
     mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE; \
-    MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *) session; \
+     _mfxSession *pHandle = (_mfxSession *) session; \
     /* get the function's address and make a call */ \
     if (pHandle) \
 { \

+ 34 - 36
plugins/obs-qsv11/libmfx/src/mfx_dispatcher.cpp

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2012-2015 Intel Corporation.  All rights reserved.
+Copyright (C) 2012-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -32,20 +32,22 @@ File Name: mfx_dispatcher.cpp
 #include "mfx_dispatcher_log.h"
 #include "mfx_load_dll.h"
 
+#include <assert.h>
+
 #include <string.h>
 #if defined(_WIN32) || defined(_WIN64)
     #include <windows.h>
     #pragma warning(disable:4355)
 #else
-
-#include <dlfcn.h>
-#include <iostream>
-
+    #include <dlfcn.h>
+    #include <iostream>
 #endif // defined(_WIN32) || defined(_WIN64)
 
+
 MFX_DISP_HANDLE::MFX_DISP_HANDLE(const mfxVersion requiredVersion) :
-    apiVersion(requiredVersion),
-    pluginFactory((mfxSession)this)
+    _mfxSession()
+    ,apiVersion(requiredVersion)
+    ,pluginFactory((mfxSession)this)
 {
     actualApiVersion.Version = 0;
     implType = MFX_LIB_SOFTWARE;
@@ -53,13 +55,11 @@ MFX_DISP_HANDLE::MFX_DISP_HANDLE(const mfxVersion requiredVersion) :
     loadStatus = MFX_ERR_NOT_FOUND;
     dispVersion.Major = MFX_DISPATCHER_VERSION_MAJOR;
     dispVersion.Minor = MFX_DISPATCHER_VERSION_MINOR;
-    session = (mfxSession) 0;
+    storageID = 0;
+    implInterface = MFX_IMPL_HARDWARE_ANY;
 
     hModule = (mfxModuleHandle) 0;
 
-    memset(callTable, 0, sizeof(callTable));
-    memset(callAudioTable, 0, sizeof(callAudioTable));
-
 } // MFX_DISP_HANDLE::MFX_DISP_HANDLE(const mfxVersion requiredVersion)
 
 MFX_DISP_HANDLE::~MFX_DISP_HANDLE(void)
@@ -82,38 +82,34 @@ mfxStatus MFX_DISP_HANDLE::Close(void)
         loadStatus = MFX_ERR_NOT_FOUND;
         dispVersion.Major = MFX_DISPATCHER_VERSION_MAJOR;
         dispVersion.Minor = MFX_DISPATCHER_VERSION_MINOR;
-        session = (mfxSession) 0;
-
+        *static_cast<_mfxSession*>(this) = _mfxSession();
         hModule = (mfxModuleHandle) 0;
-
-        memset(callTable, 0, sizeof(callTable));
-        memset(callAudioTable, 0, sizeof(callAudioTable));
     }
 
     return mfxRes;
 
 } // mfxStatus MFX_DISP_HANDLE::Close(void)
 
-mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImplType implType,
-                                           mfxIMPL impl, mfxIMPL implInterface, mfxInitParam &par)
+mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImplType reqImplType,
+                                           mfxIMPL reqImpl, mfxIMPL reqImplInterface, mfxInitParam &par)
 {
     mfxStatus mfxRes = MFX_ERR_NONE;
 
     // check error(s)
-    if ((MFX_LIB_SOFTWARE != implType) &&
-        (MFX_LIB_HARDWARE != implType))
+    if ((MFX_LIB_SOFTWARE != reqImplType) &&
+        (MFX_LIB_HARDWARE != reqImplType))
     {
-        DISPATCHER_LOG_ERROR((("implType == %s, should be either MFX_LIB_SOFTWARE ot MFX_LIB_HARDWARE\n"), DispatcherLog_GetMFXImplString(implType).c_str()));
+        DISPATCHER_LOG_ERROR((("implType == %s, should be either MFX_LIB_SOFTWARE ot MFX_LIB_HARDWARE\n"), DispatcherLog_GetMFXImplString(reqImplType).c_str()));
         loadStatus = MFX_ERR_ABORTED;
         return loadStatus;
     }
     // only exact types of implementation is allowed
-    if (!(impl & MFX_IMPL_AUDIO) &&
-        (MFX_IMPL_SOFTWARE != impl) &&
-        (MFX_IMPL_HARDWARE != impl) &&
-        (MFX_IMPL_HARDWARE2 != impl) &&
-        (MFX_IMPL_HARDWARE3 != impl) &&
-        (MFX_IMPL_HARDWARE4 != impl))
+    if (!(reqImpl & MFX_IMPL_AUDIO) &&
+        (MFX_IMPL_SOFTWARE != reqImpl) &&
+        (MFX_IMPL_HARDWARE != reqImpl) &&
+        (MFX_IMPL_HARDWARE2 != reqImpl) &&
+        (MFX_IMPL_HARDWARE3 != reqImpl) &&
+        (MFX_IMPL_HARDWARE4 != reqImpl))
     {
         DISPATCHER_LOG_ERROR((("invalid implementation impl == %s\n"), DispatcherLog_GetMFXImplString(impl).c_str()));
         loadStatus = MFX_ERR_ABORTED;
@@ -139,15 +135,17 @@ mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImpl
     Close();
 
     // save the library's type
-    this->implType = implType;
-    this->impl = impl;
-    this->implInterface = implInterface;
+    this->implType = reqImplType;
+    this->impl = reqImpl;
+    this->implInterface = reqImplInterface;
 
     {
+        assert(hModule == (mfxModuleHandle)0);
         DISPATCHER_LOG_BLOCK(("invoking LoadLibrary(%S)\n", MSDK2WIDE(pPath)));
+
         // load the DLL into the memory
         hModule = MFX::mfx_dll_load(pPath);
-        
+
         if (hModule)
         {
             int i;
@@ -279,7 +277,7 @@ mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImpl
         else
         {
             mfxRes = MFXQueryVersion((mfxSession) this, &actualApiVersion);
-            
+
             if (MFX_ERR_NONE != mfxRes)
             {
                 DISPATCHER_LOG_ERROR((("MFXQueryVersion returned: %d, skiped this library\n"), mfxRes))
@@ -310,12 +308,12 @@ mfxStatus MFX_DISP_HANDLE::UnLoadSelectedDLL(void)
     if (session)
     {
         /* check whether it is audio session or video */
-        int tableIndex = eMFXClose; 
+        int tableIndex = eMFXClose;
         mfxFunctionPointer pFunc;
-        if (impl & MFX_IMPL_AUDIO) 
-        { 
+        if (impl & MFX_IMPL_AUDIO)
+        {
             pFunc = callAudioTable[tableIndex];
-        } 
+        }
         else
         {
             pFunc = callTable[tableIndex];

+ 30 - 11
plugins/obs-qsv11/libmfx/src/mfx_dxva2_device.cpp

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2012-2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2012-2017 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -104,26 +104,30 @@ void DXDevice::Close(void)
 
 void DXDevice::LoadDLLModule(const wchar_t *pModuleName)
 {
-    DWORD prevErrorMode = 0;
-
     // unload the module if it is required
     UnloadDLLModule();
 
+#if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+    DWORD prevErrorMode = 0;
     // set the silent error mode
 #if (_WIN32_WINNT >= 0x0600) && !(__GNUC__)
     SetThreadErrorMode(SEM_FAILCRITICALERRORS, &prevErrorMode); 
 #else
     prevErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
 #endif
+#endif // !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+
     // load specified library
-	m_hModule = LoadLibraryExW(pModuleName, NULL, 0);
+    m_hModule = LoadLibraryExW(pModuleName, NULL, 0);
 
+#if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
     // set the previous error mode
 #if (_WIN32_WINNT >= 0x0600) && !(__GNUC__)
     SetThreadErrorMode(prevErrorMode, NULL);
 #else
     SetErrorMode(prevErrorMode);
 #endif
+#endif //!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
 
 } // void LoadDLLModule(const wchar_t *pModuleName)
 
@@ -137,7 +141,7 @@ void DXDevice::UnloadDLLModule(void)
 
 } // void DXDevice::UnloaDLLdModule(void)
 
-
+#ifdef MFX_D3D9_ENABLED
 D3D9Device::D3D9Device(void)
 {
     m_pD3D9 = (void *) 0;
@@ -280,6 +284,7 @@ bool D3D9Device::Init(const mfxU32 adapterNum)
     return true;
 
 } // bool D3D9Device::Init(const mfxU32 adapterNum)
+#endif //MFX_D3D9_ENABLED
 
 typedef
 HRESULT (WINAPI *DXGICreateFactoryFunc) (REFIID riid, void **ppFactory);
@@ -328,15 +333,17 @@ bool DXGI1Device::Init(const mfxU32 adapterNum)
 
     if (m_hModule)
     {
-        DXGICreateFactoryFunc pFunc;
-        IDXGIFactory1 *pFactory;
-        IDXGIAdapter1 *pAdapter;
-        DXGI_ADAPTER_DESC1 desc;
-        mfxU32 curAdapter, maxAdapters;
-        HRESULT hRes;
+        DXGICreateFactoryFunc pFunc = NULL;
+        IDXGIFactory1 *pFactory = NULL;
+        IDXGIAdapter1 *pAdapter = NULL;
+        DXGI_ADAPTER_DESC1 desc = { 0 };
+        mfxU32 curAdapter = 0;
+        mfxU32 maxAdapters = 0;
+        HRESULT hRes = E_FAIL;
 
         // load address of procedure to create DXGI 1.1 factory
         pFunc = (DXGICreateFactoryFunc) GetProcAddress(m_hModule, "CreateDXGIFactory1");
+
         if (NULL == pFunc)
         {
             return false;
@@ -413,6 +420,7 @@ DXVA2Device::DXVA2Device(void)
     m_vendorID = 0;
     m_deviceID = 0;
 
+    m_driverVersion = 0;
 } // DXVA2Device::DXVA2Device(void)
 
 DXVA2Device::~DXVA2Device(void)
@@ -428,8 +436,10 @@ void DXVA2Device::Close(void)
     m_vendorID = 0;
     m_deviceID = 0;
 
+    m_driverVersion = 0;
 } // void DXVA2Device::Close(void)
 
+#ifdef MFX_D3D9_ENABLED
 bool DXVA2Device::InitD3D9(const mfxU32 adapterNum)
 {
     D3D9Device d3d9Device;
@@ -464,6 +474,13 @@ bool DXVA2Device::InitD3D9(const mfxU32 adapterNum)
     // ... say goodbye
     return true;
 } // bool InitD3D9(const mfxU32 adapterNum)
+#else // MFX_D3D9_ENABLED
+bool DXVA2Device::InitD3D9(const mfxU32 adapterNum)
+{
+    (void)adapterNum;
+    return false;
+}
+#endif // MFX_D3D9_ENABLED
 
 bool DXVA2Device::InitDXGI1(const mfxU32 adapterNum)
 {
@@ -490,6 +507,7 @@ bool DXVA2Device::InitDXGI1(const mfxU32 adapterNum)
 
 } // bool DXVA2Device::InitDXGI1(const mfxU32 adapterNum)
 
+#ifdef MFX_D3D9_ENABLED
 void DXVA2Device::UseAlternativeWay(const D3D9Device *pD3D9Device)
 {
     mfxU64 d3d9LUID = pD3D9Device->GetLUID();
@@ -532,6 +550,7 @@ void DXVA2Device::UseAlternativeWay(const D3D9Device *pD3D9Device)
     // we need to match a DXGI(1) device to the D3D9 device
 
 } // void DXVA2Device::UseAlternativeWay(const D3D9Device *pD3D9Device)
+#endif // MFX_D3D9_ENABLED
 
 mfxU32 DXVA2Device::GetVendorID(void) const
 {

+ 113 - 23
plugins/obs-qsv11/libmfx/src/mfx_library_iterator.cpp

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2012-2015 Intel Corporation.  All rights reserved.
+Copyright (C) 2012-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -41,6 +41,8 @@ File Name: mfx_library_iterator.cpp
 #include <tchar.h>
 #include <windows.h>
 
+#include <vector>
+
 namespace MFX
 {
 
@@ -72,9 +74,10 @@ mfxStatus SelectImplementationType(const mfxU32 adapterNum, mfxIMPL *pImplInterf
     {
         return MFX_ERR_NULL_PTR;
     }
+    mfxIMPL impl_via = *pImplInterface;
 
     DXVA2Device dxvaDevice;
-    if (MFX_IMPL_VIA_D3D9 == *pImplInterface)
+    if (MFX_IMPL_VIA_D3D9 == impl_via)
     {
         // try to create the Direct3D 9 device and find right adapter
         if (!dxvaDevice.InitD3D9(adapterNum))
@@ -83,7 +86,7 @@ mfxStatus SelectImplementationType(const mfxU32 adapterNum, mfxIMPL *pImplInterf
             return MFX_ERR_UNSUPPORTED;
         }
     }
-    else if (MFX_IMPL_VIA_D3D11 == *pImplInterface)
+    else if (MFX_IMPL_VIA_D3D11 == impl_via)
     {
         // try to open DXGI 1.1 device to get hardware ID
         if (!dxvaDevice.InitDXGI1(adapterNum))
@@ -91,8 +94,8 @@ mfxStatus SelectImplementationType(const mfxU32 adapterNum, mfxIMPL *pImplInterf
             DISPATCHER_LOG_INFO((("dxvaDevice.InitDXGI1(%d) Failed "), adapterNum ));
             return MFX_ERR_UNSUPPORTED;
         }
-    } 
-    else if (MFX_IMPL_VIA_ANY == *pImplInterface)
+    }
+    else if (MFX_IMPL_VIA_ANY == impl_via)
     {
         // try the Direct3D 9 device
         if (dxvaDevice.InitD3D9(adapterNum))
@@ -163,6 +166,62 @@ void MFXLibraryIterator::Release(void)
 
 } // void MFXLibraryIterator::Release(void)
 
+DECLSPEC_NOINLINE HMODULE GetThisDllModuleHandle()
+{
+  HMODULE hDll = HMODULE(-1);
+
+  GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
+                      GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
+                      reinterpret_cast<LPCWSTR>(&GetThisDllModuleHandle), &hDll);
+  return hDll;
+}
+
+// msdk_disp_char* sImplPath must be allocated with size not less then msdk_disp_path_len
+bool GetImplPath(int storageID, msdk_disp_char* sImplPath)
+{
+    HMODULE hModule = NULL;
+
+    sImplPath[0] = L'\0';
+
+    switch (storageID) {
+    case MFX_APP_FOLDER:
+        hModule = 0;
+        break;
+
+#if defined(MEDIASDK_UWP_LOADER) || defined(MEDIASDK_UWP_PROCTABLE)
+    case MFX_PATH_MSDK_FOLDER:
+        hModule = GetThisDllModuleHandle();
+        break;
+#endif
+
+    }
+
+    if(hModule == HMODULE(-1)) {
+        return false;
+    }
+
+    DWORD nSize = 0;
+    DWORD allocSize = msdk_disp_path_len;
+
+    nSize = GetModuleFileNameW(hModule, &sImplPath[0], allocSize);
+
+    if (nSize  == 0 || nSize == allocSize) {
+        // nSize == 0 meanse that system can't get this info for hModule
+        // nSize == allocSize buffer is too small
+        return false;
+    }
+
+    // for any case because WinXP implementation of GetModuleFileName does not add \0 to the end of string
+    sImplPath[nSize] = L'\0';
+
+    msdk_disp_char * dirSeparator = wcsrchr(sImplPath, L'\\');
+    if (dirSeparator != NULL && dirSeparator < (sImplPath + msdk_disp_path_len))
+    {
+        *++dirSeparator = 0;
+    }
+    return true;
+}
+
 mfxStatus MFXLibraryIterator::Init(eMfxImplType implType, mfxIMPL implInterface, const mfxU32 adapterNum, int storageID)
 {
     // check error(s)
@@ -177,29 +236,26 @@ mfxStatus MFXLibraryIterator::Init(eMfxImplType implType, mfxIMPL implInterface,
     m_StorageID = storageID;
     m_lastLibIndex = 0;
 
+#if defined(MEDIASDK_USE_REGISTRY) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
     if (storageID == MFX_CURRENT_USER_KEY || storageID == MFX_LOCAL_MACHINE_KEY)
     {
         return InitRegistry(implType, implInterface, adapterNum, storageID);
     }
-    else if (storageID == MFX_APP_FOLDER)
-    {
-        msdk_disp_char path[_MAX_PATH] = {};
+#endif
 
-        ::GetModuleFileNameW(0, path, _MAX_PATH);
-        msdk_disp_char * dirSeparator = wcsrchr(path, L'\\');
-        if (dirSeparator < (path + _MAX_PATH))
-        {
-            *++dirSeparator = 0;
-        }        
-        
-        return InitFolder(implType, implInterface, adapterNum, path);
+    msdk_disp_char  sCurrentModulePath[msdk_disp_path_len];
+
+    if(!GetImplPath(storageID, sCurrentModulePath)) {
+        return MFX_ERR_UNSUPPORTED;
     }
 
-    return MFX_ERR_UNSUPPORTED;
+    return InitFolder(implType, implInterface, adapterNum, sCurrentModulePath);
+
 } // mfxStatus MFXLibraryIterator::Init(eMfxImplType implType, const mfxU32 adapterNum, int storageID)
 
 mfxStatus MFXLibraryIterator::InitRegistry(eMfxImplType implType, mfxIMPL implInterface, const mfxU32 adapterNum, int storageID)
 {
+#if defined(MEDIASDK_USE_REGISTRY) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
     HKEY rootHKey;
     bool bRes;
 
@@ -216,7 +272,7 @@ mfxStatus MFXLibraryIterator::InitRegistry(eMfxImplType implType, mfxIMPL implIn
 
     // set the required library's implementation type
     m_implType = implType;
-    m_implInterface = implInterface != 0 
+    m_implInterface = implInterface != 0
         ? implInterface
         : MFX_IMPL_VIA_ANY;
 
@@ -235,6 +291,14 @@ mfxStatus MFXLibraryIterator::InitRegistry(eMfxImplType implType, mfxIMPL implIn
         rootDispPath))
 
     return MFX_ERR_NONE;
+#else
+    (void) storageID;
+    (void) adapterNum;
+    (void) implInterface;
+    (void) implType;
+    return MFX_ERR_UNSUPPORTED;
+#endif // #if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+
 } // mfxStatus MFXLibraryIterator::InitRegistry(eMfxImplType implType, mfxIMPL implInterface, const mfxU32 adapterNum, int storageID)
 
 mfxStatus MFXLibraryIterator::InitFolder(eMfxImplType implType, mfxIMPL implInterface, const mfxU32 adapterNum, const msdk_disp_char * path)
@@ -244,12 +308,16 @@ mfxStatus MFXLibraryIterator::InitFolder(eMfxImplType implType, mfxIMPL implInte
      msdk_disp_char_cpy_s(m_path, maxPathLen, path);
      size_t pathLen = wcslen(m_path);
 
+#if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
      // we looking for runtime in application folder, it should be named libmfxsw64 or libmfxsw32
-     mfx_get_default_dll_name(m_path + pathLen, maxPathLen - pathLen,  MFX_LIB_SOFTWARE);
+     mfx_get_default_dll_name(m_path + pathLen, msdk_disp_path_len - pathLen,  MFX_LIB_SOFTWARE);
+#else
+     mfx_get_default_dll_name(m_path + pathLen, msdk_disp_path_len - pathLen, implType);
+#endif
 
      // set the required library's implementation type
      m_implType = implType;
-     m_implInterface = implInterface != 0 
+     m_implInterface = implInterface != 0
          ? implInterface
          : MFX_IMPL_VIA_ANY;
 
@@ -275,6 +343,8 @@ mfxStatus MFXLibraryIterator::SelectDLLVersion(wchar_t *pPath
     {
         if (m_lastLibIndex != 0)
             return MFX_ERR_NOT_FOUND;
+        if (m_vendorID != INTEL_VENDOR_ID)
+            return MFX_ERR_UNKNOWN;
 
         m_lastLibIndex = 1;
         msdk_disp_char_cpy_s(pPath, pathSize, m_path);
@@ -282,6 +352,25 @@ mfxStatus MFXLibraryIterator::SelectDLLVersion(wchar_t *pPath
         return MFX_ERR_NONE;
     }
 
+#if defined(MEDIASDK_UWP_LOADER) || defined(MEDIASDK_UWP_PROCTABLE)
+
+    if (m_StorageID == MFX_PATH_MSDK_FOLDER) {
+
+        if (m_lastLibIndex != 0)
+            return MFX_ERR_NOT_FOUND;
+        if (m_vendorID != INTEL_VENDOR_ID)
+            return MFX_ERR_UNKNOWN;
+
+        m_lastLibIndex = 1;
+        msdk_disp_char_cpy_s(pPath, pathSize, m_path);
+        // do not change impl type
+        //*pImplType = MFX_LIB_HARDWARE;
+        return MFX_ERR_NONE;
+    }
+
+#endif
+
+#if defined(MEDIASDK_USE_REGISTRY) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
     wchar_t libPath[MFX_MAX_DLL_PATH] = L"";
     DWORD libIndex = 0;
     DWORD libMerit = 0;
@@ -294,7 +383,7 @@ mfxStatus MFXLibraryIterator::SelectDLLVersion(wchar_t *pPath
     do
     {
         WinRegKey subKey;
-        wchar_t subKeyName[MFX_MAX_REGISTRY_KEY_NAME];
+        wchar_t subKeyName[MFX_MAX_REGISTRY_KEY_NAME] = { 0 };
         DWORD subKeyNameSize = sizeof(subKeyName) / sizeof(subKeyName[0]);
 
         // query next value name
@@ -375,7 +464,7 @@ mfxStatus MFXLibraryIterator::SelectDLLVersion(wchar_t *pPath
                     // compare device's and library's IDs
                     if (MFX_LIB_HARDWARE == m_implType)
                     {
-                        if (m_vendorID != vendorID) 
+                        if (m_vendorID != vendorID)
                         {
                             bRes = false;
                             DISPATCHER_LOG_WRN((("%S conflict, actual = 0x%x : required = 0x%x\n"), vendorIDKeyName, m_vendorID, vendorID));
@@ -424,7 +513,6 @@ mfxStatus MFXLibraryIterator::SelectDLLVersion(wchar_t *pPath
                             if ((0 == vendorID) || (0 == deviceID))
                             {
                                 *pImplType = MFX_LIB_SOFTWARE;
-                                
                                 DISPATCHER_LOG_INFO((("Library type is MFX_LIB_SOFTWARE\n")));
                             }
                             else
@@ -456,6 +544,8 @@ mfxStatus MFXLibraryIterator::SelectDLLVersion(wchar_t *pPath
     m_lastLibMerit = libMerit;
     m_bIsSubKeyValid = true;
 
+#endif
+
     return MFX_ERR_NONE;
 
 } // mfxStatus MFXLibraryIterator::SelectDLLVersion(wchar_t *pPath, size_t pathSize, eMfxImplType *pImplType, mfxVersion minVersion)

+ 12 - 5
plugins/obs-qsv11/libmfx/src/mfx_load_dll.cpp

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2012-2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2012-2017 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -164,7 +164,7 @@ mfxModuleHandle mfx_dll_load(const msdk_disp_char *pFileName)
     {
         return NULL;
     }
-
+#if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
     // set the silent error mode
     DWORD prevErrorMode = 0;
 #if (_WIN32_WINNT >= 0x0600) && !(__GNUC__)
@@ -172,14 +172,19 @@ mfxModuleHandle mfx_dll_load(const msdk_disp_char *pFileName)
 #else
     prevErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
 #endif
-    // load the library's module
-    hModule = LoadLibraryExW(pFileName,NULL,0);
-    // set the previous error mode
+#endif // !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+
+        // load the library's module
+        hModule = LoadLibraryExW(pFileName, NULL, 0);
+
+#if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+        // set the previous error mode
 #if (_WIN32_WINNT >= 0x0600) && !(__GNUC__)
     SetThreadErrorMode(prevErrorMode, NULL);
 #else
     SetErrorMode(prevErrorMode);
 #endif
+#endif // !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
 
     return hModule;
 
@@ -207,6 +212,7 @@ bool mfx_dll_free(mfxModuleHandle handle)
     return !!bRes;
 } // bool mfx_dll_free(mfxModuleHandle handle)
 
+#if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
 mfxModuleHandle mfx_get_dll_handle(const msdk_disp_char *pFileName)
 {
     mfxModuleHandle hModule = (mfxModuleHandle) 0;
@@ -234,6 +240,7 @@ mfxModuleHandle mfx_get_dll_handle(const msdk_disp_char *pFileName)
 #endif
     return hModule;
 }
+#endif //!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
 
 
 } // namespace MFX

+ 66 - 61
plugins/obs-qsv11/libmfx/src/mfx_load_plugin.cpp

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2013-2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2013-2017 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -32,28 +32,28 @@ File Name: mfx_load_plugin.h
 #include "mfx_load_dll.h"
 #include "mfx_dispatcher_log.h"
 
-#define TRACE_PLUGIN_ERROR(str, ...) DISPATCHER_LOG_ERROR((("[PLUGIN]: "str), __VA_ARGS__))
-#define TRACE_PLUGIN_INFO(str, ...) DISPATCHER_LOG_INFO((("[PLUGIN]: "str), __VA_ARGS__))
+#define TRACE_PLUGIN_ERROR(str, ...) DISPATCHER_LOG_ERROR((("[PLUGIN]: " str), __VA_ARGS__))
+#define TRACE_PLUGIN_INFO(str, ...) DISPATCHER_LOG_INFO((("[PLUGIN]: " str), __VA_ARGS__))
 
 #define CREATE_PLUGIN_FNC "CreatePlugin"
 
 MFX::PluginModule::PluginModule()
     : mHmodule()
-    , mCreatePluginPtr() 
+    , mCreatePluginPtr()
     , mPath()
 {
 }
 
-MFX::PluginModule::PluginModule(const PluginModule & that) 
+MFX::PluginModule::PluginModule(const PluginModule & that)
     : mHmodule(mfx_dll_load(that.mPath))
-    , mCreatePluginPtr(that.mCreatePluginPtr) 
+    , mCreatePluginPtr(that.mCreatePluginPtr)
 {
     msdk_disp_char_cpy_s(mPath, sizeof(mPath) / sizeof(*mPath), that.mPath);
 }
 
-MFX::PluginModule & MFX::PluginModule::operator = (const MFX::PluginModule & that) 
+MFX::PluginModule & MFX::PluginModule::operator = (const MFX::PluginModule & that)
 {
-    if (this != &that) 
+    if (this != &that)
     {
         Tidy();
         mHmodule = mfx_dll_load(that.mPath);
@@ -64,7 +64,7 @@ MFX::PluginModule & MFX::PluginModule::operator = (const MFX::PluginModule & tha
 }
 
 MFX::PluginModule::PluginModule(const msdk_disp_char * path)
-    : mCreatePluginPtr() 
+    : mCreatePluginPtr()
 {
     mHmodule = mfx_dll_load(path);
     if (NULL == mHmodule) {
@@ -72,20 +72,20 @@ MFX::PluginModule::PluginModule(const msdk_disp_char * path)
         return ;
     }
     TRACE_PLUGIN_INFO("Plugin loaded at: %S\n", MSDK2WIDE(path));
-    
+
     mCreatePluginPtr = (CreatePluginPtr_t)mfx_dll_get_addr(mHmodule, CREATE_PLUGIN_FNC);
     if (NULL == mCreatePluginPtr) {
         TRACE_PLUGIN_ERROR("Cannot get procedure address: %s\n", CREATE_PLUGIN_FNC);
         return ;
     }
-    
+
     msdk_disp_char_cpy_s(mPath, sizeof(mPath) / sizeof(*mPath), path);
 }
 
-bool MFX::PluginModule::Create( mfxPluginUID uid, mfxPlugin& plg) 
+bool MFX::PluginModule::Create( mfxPluginUID uid, mfxPlugin& plg)
 {
     bool result = false;
-    if (mCreatePluginPtr) 
+    if (mCreatePluginPtr)
     {
         mfxStatus mfxResult = mCreatePluginPtr(uid, &plg);
         result = (MFX_ERR_NONE == mfxResult);
@@ -105,11 +105,13 @@ void MFX::PluginModule::Tidy()
     mHmodule = NULL;
 }
 
-MFX::PluginModule::~PluginModule(void) 
+MFX::PluginModule::~PluginModule(void)
 {
     Tidy();
 }
 
+#if !defined(MEDIASDK_UWP_PROCTABLE)
+
 bool MFX::MFXPluginFactory::RunVerification( const mfxPlugin & plg, const PluginDescriptionRecord &dsc, mfxPluginParam &pluginParams)
 {
     if (plg.PluginInit == 0)
@@ -117,23 +119,23 @@ bool MFX::MFXPluginFactory::RunVerification( const mfxPlugin & plg, const Plugin
         TRACE_PLUGIN_ERROR("plg->PluginInit = 0\n", 0);
         return false;
     }
-    if (plg.PluginClose == 0) 
+    if (plg.PluginClose == 0)
     {
         TRACE_PLUGIN_ERROR("plg->PluginClose = 0\n", 0);
         return false;
     }
-    if (plg.GetPluginParam == 0) 
+    if (plg.GetPluginParam == 0)
     {
         TRACE_PLUGIN_ERROR("plg->GetPluginParam = 0\n", 0);
         return false;
     }
-    
-    if (plg.Execute == 0) 
+
+    if (plg.Execute == 0)
     {
         TRACE_PLUGIN_ERROR("plg->Execute = 0\n", 0);
         return false;
     }
-    if (plg.FreeResources == 0) 
+    if (plg.FreeResources == 0)
     {
         TRACE_PLUGIN_ERROR("plg->FreeResources = 0\n", 0);
         return false;
@@ -158,27 +160,27 @@ bool MFX::MFXPluginFactory::RunVerification( const mfxPlugin & plg, const Plugin
     }
     else
     {
-        if (!dsc.onlyVersionRegistered && pluginParams.CodecId != dsc.CodecId) 
+        if (!dsc.onlyVersionRegistered && pluginParams.CodecId != dsc.CodecId)
         {
-            TRACE_PLUGIN_ERROR("plg->GetPluginParam() returned CodecId="MFXFOURCCTYPE()", but registration has CodecId="MFXFOURCCTYPE()"\n"
+            TRACE_PLUGIN_ERROR("plg->GetPluginParam() returned CodecId=" MFXFOURCCTYPE()", but registration has CodecId=" MFXFOURCCTYPE()"\n"
                 , MFXU32TOFOURCC(pluginParams.CodecId), MFXU32TOFOURCC(dsc.CodecId));
             return false;
         }
 
-        if (!dsc.onlyVersionRegistered && pluginParams.Type != dsc.Type) 
+        if (!dsc.onlyVersionRegistered && pluginParams.Type != dsc.Type)
         {
             TRACE_PLUGIN_ERROR("plg->GetPluginParam() returned Type=%d, but registration has Type=%d\n", pluginParams.Type, dsc.Type);
             return false;
         }
 
-        if (pluginParams.PluginUID !=  dsc.PluginUID) 
+        if (pluginParams.PluginUID !=  dsc.PluginUID)
         {
-            TRACE_PLUGIN_ERROR("plg->GetPluginParam() returned UID="MFXGUIDTYPE()", but registration has UID="MFXGUIDTYPE()"\n"
+            TRACE_PLUGIN_ERROR("plg->GetPluginParam() returned UID=" MFXGUIDTYPE()", but registration has UID=" MFXGUIDTYPE()"\n"
                 , MFXGUIDTOHEX(&pluginParams.PluginUID), MFXGUIDTOHEX(&dsc.PluginUID));
             return false;
         }
 
-        if (pluginParams.PluginVersion != dsc.PluginVersion) 
+        if (pluginParams.PluginVersion != dsc.PluginVersion)
         {
             TRACE_PLUGIN_ERROR("plg->GetPluginParam() returned PluginVersion=%d, but registration has PlgVer=%d\n", pluginParams.PluginVersion, dsc.PluginVersion);
             return false;
@@ -193,14 +195,14 @@ bool MFX::MFXPluginFactory::RunVerification( const mfxPlugin & plg, const Plugin
         }
     }
 
-    switch(pluginParams.Type) 
+    switch(pluginParams.Type)
     {
-        case MFX_PLUGINTYPE_VIDEO_DECODE: 
-        case MFX_PLUGINTYPE_VIDEO_ENCODE: 
-        case MFX_PLUGINTYPE_VIDEO_VPP: 
+        case MFX_PLUGINTYPE_VIDEO_DECODE:
+        case MFX_PLUGINTYPE_VIDEO_ENCODE:
+        case MFX_PLUGINTYPE_VIDEO_VPP:
         {
             TRACE_PLUGIN_INFO("plugin type= %d\n", pluginParams.Type);
-            if (plg.Video == 0) 
+            if (plg.Video == 0)
             {
                 TRACE_PLUGIN_ERROR("plg->Video = 0\n", 0);
                 return false;
@@ -212,21 +214,21 @@ bool MFX::MFXPluginFactory::RunVerification( const mfxPlugin & plg, const Plugin
         }
     }
 
-    switch(pluginParams.Type) 
+    switch(pluginParams.Type)
     {
-        case MFX_PLUGINTYPE_VIDEO_DECODE: 
+        case MFX_PLUGINTYPE_VIDEO_DECODE:
             return VerifyDecoder(*plg.Video);
-        case MFX_PLUGINTYPE_AUDIO_DECODE: 
+        case MFX_PLUGINTYPE_AUDIO_DECODE:
             return VerifyAudioDecoder(*plg.Audio);
-        case MFX_PLUGINTYPE_VIDEO_ENCODE:        
+        case MFX_PLUGINTYPE_VIDEO_ENCODE:
             return VerifyEncoder(*plg.Video);
-        case MFX_PLUGINTYPE_AUDIO_ENCODE:        
+        case MFX_PLUGINTYPE_AUDIO_ENCODE:
             return VerifyAudioEncoder(*plg.Audio);
-        case MFX_PLUGINTYPE_VIDEO_VPP: 
-            return VerifyVpp(*plg.Video); 
+        case MFX_PLUGINTYPE_VIDEO_VPP:
+            return VerifyVpp(*plg.Video);
         case MFX_PLUGINTYPE_VIDEO_ENC:
             return VerifyEnc(*plg.Video);
-        default: 
+        default:
         {
             TRACE_PLUGIN_ERROR("unsupported plugin type: %d\n", pluginParams.Type);
             return false;
@@ -234,7 +236,7 @@ bool MFX::MFXPluginFactory::RunVerification( const mfxPlugin & plg, const Plugin
     }
 }
 
-bool MFX::MFXPluginFactory::VerifyVpp( const mfxVideoCodecPlugin &vpp ) 
+bool MFX::MFXPluginFactory::VerifyVpp( const mfxVideoCodecPlugin &vpp )
 {
     if (vpp.VPPFrameSubmit == 0)
     {
@@ -253,7 +255,7 @@ bool MFX::MFXPluginFactory::VerifyEncoder( const mfxVideoCodecPlugin &encoder )
         TRACE_PLUGIN_ERROR("plg->Video->EncodeFrameSubmit = 0\n", 0);
         return false;
     }
-    
+
     return true;
 }
 
@@ -264,7 +266,7 @@ bool MFX::MFXPluginFactory::VerifyAudioEncoder( const mfxAudioCodecPlugin &encod
         TRACE_PLUGIN_ERROR("plg->Audio->EncodeFrameSubmit = 0\n", 0);
         return false;
     }
-    
+
     return true;
 }
 
@@ -281,7 +283,7 @@ bool MFX::MFXPluginFactory::VerifyEnc( const mfxVideoCodecPlugin &videoEnc )
 
 bool MFX::MFXPluginFactory::VerifyDecoder( const mfxVideoCodecPlugin &decoder )
 {
-    if (decoder.DecodeHeader == 0) 
+    if (decoder.DecodeHeader == 0)
     {
         TRACE_PLUGIN_ERROR("plg->Video->DecodeHeader = 0\n", 0);
         return false;
@@ -302,7 +304,7 @@ bool MFX::MFXPluginFactory::VerifyDecoder( const mfxVideoCodecPlugin &decoder )
 
 bool MFX::MFXPluginFactory::VerifyAudioDecoder( const mfxAudioCodecPlugin &decoder )
 {
-    if (decoder.DecodeHeader == 0) 
+    if (decoder.DecodeHeader == 0)
     {
         TRACE_PLUGIN_ERROR("plg->Audio->DecodeHeader = 0\n", 0);
         return false;
@@ -344,12 +346,12 @@ bool MFX::MFXPluginFactory::VerifyCodecCommon( const mfxVideoCodecPlugin & video
         TRACE_PLUGIN_ERROR("plg->Video->Init = 0\n", 0);
         return false;
     }
-    if (videoCodec.Reset == 0) 
+    if (videoCodec.Reset == 0)
     {
         TRACE_PLUGIN_ERROR("plg->Video->Reset = 0\n", 0);
         return false;
     }
-    if (videoCodec.Close == 0) 
+    if (videoCodec.Close == 0)
     {
         TRACE_PLUGIN_ERROR("plg->Video->Close = 0\n", 0);
         return false;
@@ -368,24 +370,24 @@ mfxStatus MFX::MFXPluginFactory::Create(const PluginDescriptionRecord & rec)
     PluginModule plgModule(rec.sPath);
     mfxPlugin plg = {};
     mfxPluginParam plgParams;
-    
-    if (!plgModule.Create(rec.PluginUID, plg)) 
+
+    if (!plgModule.Create(rec.PluginUID, plg))
     {
         return MFX_ERR_UNKNOWN;
     }
-    
-    if (!RunVerification(plg, rec, plgParams)) 
+
+    if (!RunVerification(plg, rec, plgParams))
     {
         //will do not call plugin close since it is not safe to do that until structure is corrected
         return MFX_ERR_UNKNOWN;
     }
 
-   
+
     if (rec.Type == MFX_PLUGINTYPE_AUDIO_DECODE ||
         rec.Type == MFX_PLUGINTYPE_AUDIO_ENCODE)
     {
         mfxStatus sts = MFXAudioUSER_Register(mSession, plgParams.Type, &plg);
-        if (MFX_ERR_NONE != sts) 
+        if (MFX_ERR_NONE != sts)
         {
             TRACE_PLUGIN_ERROR(" MFXAudioUSER_Register returned %d\n", sts);
             return sts;
@@ -394,33 +396,34 @@ mfxStatus MFX::MFXPluginFactory::Create(const PluginDescriptionRecord & rec)
     else
     {
         mfxStatus sts = MFXVideoUSER_Register(mSession, plgParams.Type, &plg);
-        if (MFX_ERR_NONE != sts) 
+        if (MFX_ERR_NONE != sts)
         {
             TRACE_PLUGIN_ERROR(" MFXVideoUSER_Register returned %d\n", sts);
             return sts;
         }
     }
-    
+
     mPlugins.push_back(FactoryRecord(plgParams, plgModule, plg));
 
     return MFX_ERR_NONE;
 }
 
-MFX::MFXPluginFactory::~MFXPluginFactory() 
+MFX::MFXPluginFactory::~MFXPluginFactory()
 {
     Close();
 }
 
-MFX::MFXPluginFactory::MFXPluginFactory( mfxSession session ) 
+MFX::MFXPluginFactory::MFXPluginFactory( mfxSession session )
 {
     mSession = session;
+    nPlugins = 0;
 }
 
-bool MFX::MFXPluginFactory::Destroy( const mfxPluginUID & uidToDestroy) 
+bool MFX::MFXPluginFactory::Destroy( const mfxPluginUID & uidToDestroy)
 {
-    for (MFXVector<FactoryRecord >::iterator i = mPlugins.begin(); i!= mPlugins.end(); i++) 
+    for (MFXVector<FactoryRecord >::iterator i = mPlugins.begin(); i!= mPlugins.end(); i++)
     {
-        if (i->plgParams.PluginUID == uidToDestroy) 
+        if (i->plgParams.PluginUID == uidToDestroy)
         {
             DestroyPlugin(*i);
             //dll unload should happen here
@@ -432,9 +435,9 @@ bool MFX::MFXPluginFactory::Destroy( const mfxPluginUID & uidToDestroy)
     return false;
 }
 
-void MFX::MFXPluginFactory::Close() 
+void MFX::MFXPluginFactory::Close()
 {
-    for (MFXVector<FactoryRecord>::iterator i = mPlugins.begin(); i!= mPlugins.end(); i++) 
+    for (MFXVector<FactoryRecord>::iterator i = mPlugins.begin(); i!= mPlugins.end(); i++)
     {
         DestroyPlugin(*i);
     }
@@ -455,4 +458,6 @@ void MFX::MFXPluginFactory::DestroyPlugin( FactoryRecord & record)
         sts = MFXVideoUSER_Unregister(mSession, record.plgParams.Type);
         TRACE_PLUGIN_INFO(" MFXVideoUSER_Unregister for Type=%d, returned %d\n", record.plgParams.Type, sts);
     }
-}
+}
+
+#endif //!defined(MEDIASDK_UWP_PROCTABLE)

+ 14 - 4
plugins/obs-qsv11/libmfx/src/mfx_plugin_hive.cpp

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2013-2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2013-2018 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -36,9 +36,9 @@ File Name: mfx_plugin_hive.cpp
 #include "mfx_dispatcher_log.h"
 #include "mfx_load_dll.h"
 
-#define TRACE_HIVE_ERROR(str, ...) DISPATCHER_LOG_ERROR((("[HIVE]: "str), __VA_ARGS__))
-#define TRACE_HIVE_INFO(str, ...) DISPATCHER_LOG_INFO((("[HIVE]: "str), __VA_ARGS__))
-#define TRACE_HIVE_WRN(str, ...) DISPATCHER_LOG_WRN((("[HIVE]: "str), __VA_ARGS__))
+#define TRACE_HIVE_ERROR(str, ...) DISPATCHER_LOG_ERROR((("[HIVE]: " str), __VA_ARGS__))
+#define TRACE_HIVE_INFO(str, ...) DISPATCHER_LOG_INFO((("[HIVE]: " str), __VA_ARGS__))
+#define TRACE_HIVE_WRN(str, ...) DISPATCHER_LOG_WRN((("[HIVE]: " str), __VA_ARGS__))
 
 namespace 
 {
@@ -82,6 +82,7 @@ namespace
 MFX::MFXPluginsInHive::MFXPluginsInHive(int mfxStorageID, const msdk_disp_char *msdkLibSubKey, mfxVersion currentAPIVersion)
     : MFXPluginStorageBase(currentAPIVersion)
 {
+#if defined(MEDIASDK_USE_REGISTRY) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
     HKEY rootHKey;
     bool bRes;
     WinRegKey regKey;
@@ -222,8 +223,16 @@ MFX::MFXPluginsInHive::MFXPluginsInHive(int mfxStorageID, const msdk_disp_char *
             TRACE_HIVE_ERROR("operator[](%d) = descriptionRecord; - threw exception \n", index);
         }
     }
+#else
+
+    (void)mfxStorageID;
+    (void)msdkLibSubKey;
+    (void)currentAPIVersion;
+
+#endif //#if defined(MEDIASDK_USE_REGISTRY) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
 }
 
+#if defined(MEDIASDK_USE_CFGFILES) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
 MFX::MFXPluginsInFS::MFXPluginsInFS( mfxVersion currentAPIVersion ) 
     : MFXPluginStorageBase(currentAPIVersion)
     , mIsVersionParsed()
@@ -453,6 +462,7 @@ bool MFX::MFXPluginsInFS::ParseKVPair( msdk_disp_char * key, msdk_disp_char* val
 
     return true;
 }
+#endif //#if defined(MEDIASDK_USE_CFGFILES) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
 
 MFX::MFXDefaultPlugins::MFXDefaultPlugins(mfxVersion currentAPIVersion, MFX_DISP_HANDLE * hdl, int implType)
     : MFXPluginStorageBase(currentAPIVersion)

+ 2 - 2
plugins/obs-qsv11/libmfx/src/mfx_win_reg_key.cpp

@@ -1,6 +1,6 @@
 /* ****************************************************************************** *\
 
-Copyright (C) 2012-2014 Intel Corporation.  All rights reserved.
+Copyright (C) 2012-2017 Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -33,7 +33,7 @@ File Name: mfx_win_reg_key.cpp
 #include "mfx_win_reg_key.h"
 #include "mfx_dispatcher_log.h"
 
-#define TRACE_WINREG_ERROR(str, ...) DISPATCHER_LOG_ERROR((("[WINREG]: "str), __VA_ARGS__))
+#define TRACE_WINREG_ERROR(str, ...) DISPATCHER_LOG_ERROR((("[WINREG]: " str), __VA_ARGS__))
 
 namespace MFX
 {