Просмотр исходного кода

obs-qsv11: Update Intel Media SDK to 2021 R1

Verified my Rocket Lake CPU works now.
jpark37 4 лет назад
Родитель
Сommit
998884a8e6
44 измененных файлов с 2729 добавлено и 1938 удалено
  1. 3 0
      plugins/obs-qsv11/CMakeLists.txt
  2. 19 29
      plugins/obs-qsv11/libmfx/include/mfx_critical_section.h
  3. 39 36
      plugins/obs-qsv11/libmfx/include/mfx_dispatcher.h
  4. 28 69
      plugins/obs-qsv11/libmfx/include/mfx_dispatcher_defs.h
  5. 24 44
      plugins/obs-qsv11/libmfx/include/mfx_dispatcher_log.h
  6. 65 0
      plugins/obs-qsv11/libmfx/include/mfx_driver_store_loader.h
  7. 20 40
      plugins/obs-qsv11/libmfx/include/mfx_dxva2_device.h
  8. 19 29
      plugins/obs-qsv11/libmfx/include/mfx_exposed_functions_list.h
  9. 51 93
      plugins/obs-qsv11/libmfx/include/mfx_library_iterator.h
  10. 28 35
      plugins/obs-qsv11/libmfx/include/mfx_load_dll.h
  11. 22 32
      plugins/obs-qsv11/libmfx/include/mfx_load_plugin.h
  12. 26 34
      plugins/obs-qsv11/libmfx/include/mfx_plugin_hive.h
  13. 58 61
      plugins/obs-qsv11/libmfx/include/mfx_vector.h
  14. 21 33
      plugins/obs-qsv11/libmfx/include/mfx_win_reg_key.h
  15. 19 29
      plugins/obs-qsv11/libmfx/include/mfxaudio_exposed_functions_list.h
  16. 40 0
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxadapter.h
  17. 27 29
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxastructures.h
  18. 19 31
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxaudio++.h
  19. 35 45
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxaudio.h
  20. 63 31
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxcommon.h
  21. 132 41
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxdefs.h
  22. 34 42
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxenc.h
  23. 23 29
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxjpeg.h
  24. 27 30
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxmvc.h
  25. 32 38
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxpak.h
  26. 20 35
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxplugin++.h
  27. 94 78
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxplugin.h
  28. 20 30
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxsession.h
  29. 313 49
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxstructures.h
  30. 20 31
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxvideo++.h
  31. 25 31
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxvideo.h
  32. 19 29
      plugins/obs-qsv11/libmfx/include/msdk/include/mfxvstructures.h
  33. 249 137
      plugins/obs-qsv11/libmfx/src/main.cpp
  34. 19 33
      plugins/obs-qsv11/libmfx/src/mfx_critical_section.cpp
  35. 369 55
      plugins/obs-qsv11/libmfx/src/mfx_dispatcher.cpp
  36. 19 31
      plugins/obs-qsv11/libmfx/src/mfx_dispatcher_log.cpp
  37. 218 0
      plugins/obs-qsv11/libmfx/src/mfx_driver_store_loader.cpp
  38. 88 97
      plugins/obs-qsv11/libmfx/src/mfx_dxva2_device.cpp
  39. 27 37
      plugins/obs-qsv11/libmfx/src/mfx_function_table.cpp
  40. 141 114
      plugins/obs-qsv11/libmfx/src/mfx_library_iterator.cpp
  41. 65 83
      plugins/obs-qsv11/libmfx/src/mfx_load_dll.cpp
  42. 31 40
      plugins/obs-qsv11/libmfx/src/mfx_load_plugin.cpp
  43. 96 115
      plugins/obs-qsv11/libmfx/src/mfx_plugin_hive.cpp
  44. 22 33
      plugins/obs-qsv11/libmfx/src/mfx_win_reg_key.cpp

+ 3 - 0
plugins/obs-qsv11/CMakeLists.txt

@@ -8,6 +8,7 @@ set(obs-qsv11_libmfx_SOURCES
 	libmfx/src/mfx_critical_section.cpp
 	libmfx/src/mfx_dispatcher.cpp
 	libmfx/src/mfx_dispatcher_log.cpp
+	libmfx/src/mfx_driver_store_loader.cpp
 	libmfx/src/mfx_dxva2_device.cpp
 	libmfx/src/mfx_function_table.cpp
 	libmfx/src/mfx_library_iterator.cpp
@@ -18,6 +19,7 @@ set(obs-qsv11_libmfx_SOURCES
 	)
 
 set(obs-qsv11_libmfx_HEADERS
+	libmfx/include/msdk/include/mfxadapter.h
 	libmfx/include/msdk/include/mfxastructures.h
 	libmfx/include/msdk/include/mfxaudio.h
 	libmfx/include/msdk/include/mfxaudio++.h
@@ -36,6 +38,7 @@ set(obs-qsv11_libmfx_HEADERS
 	libmfx/include/mfx_dispatcher.h
 	libmfx/include/mfx_dispatcher_defs.h
 	libmfx/include/mfx_dispatcher_log.h
+	libmfx/include/mfx_driver_store_loader.h
 	libmfx/include/mfx_dxva2_device.h
 	libmfx/include/mfx_exposed_functions_list.h
 	libmfx/include/mfx_library_iterator.h

+ 19 - 29
plugins/obs-qsv11/libmfx/include/mfx_critical_section.h

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-Copyright (C) 2012-2013 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_critical_section.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #if !defined(__MFX_CRITICAL_SECTION_H)
 #define __MFX_CRITICAL_SECTION_H

+ 39 - 36
plugins/obs-qsv11/libmfx/include/mfx_dispatcher.h

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_dispatcher.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2020 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #if !defined(__MFX_DISPATCHER_H)
 #define __MFX_DISPATCHER_H
@@ -44,6 +34,8 @@ File Name: mfx_dispatcher.h
 
 mfxStatus MFXQueryVersion(mfxSession session, mfxVersion *version);
 
+
+
 enum
 {
     // to avoid code changing versions are just inherited
@@ -119,7 +111,7 @@ enum eMfxImplType
 enum
 {
     MFX_DISPATCHER_VERSION_MAJOR = 1,
-    MFX_DISPATCHER_VERSION_MINOR = 2
+    MFX_DISPATCHER_VERSION_MINOR = 3
 };
 
 struct _mfxSession
@@ -144,7 +136,7 @@ struct MFX_DISP_HANDLE : public _mfxSession
     ~MFX_DISP_HANDLE(void);
 
     // Load the library's module
-    mfxStatus LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImplType implType, mfxIMPL impl, mfxIMPL implInterface, mfxInitParam &par);
+    mfxStatus LoadSelectedDLL(const wchar_t *pPath, eMfxImplType implType, mfxIMPL impl, mfxIMPL implInterface, mfxInitParam &par);
     // Unload the library's module
     mfxStatus UnLoadSelectedDLL(void);
 
@@ -169,7 +161,7 @@ struct MFX_DISP_HANDLE : public _mfxSession
     // Status of loaded dll
     mfxStatus loadStatus;
     // Resgistry subkey name for windows version
-    msdk_disp_char subkeyName[MFX_MAX_REGISTRY_KEY_NAME];
+    wchar_t subkeyName[MFX_MAX_REGISTRY_KEY_NAME];
     // Storage ID for windows version
     int storageID;
 
@@ -186,26 +178,37 @@ private:
 
 };
 
+// This struct extends MFX_DISP_HANDLE, we cannot extend MFX_DISP_HANDLE itself due to possible compatibility issues
+// This struct was added in dispatcher version 1.3
+// Check dispatcher handle's version when you cast session struct which came from outside of MSDK API function to this
+struct MFX_DISP_HANDLE_EX : public MFX_DISP_HANDLE
+{
+    MFX_DISP_HANDLE_EX(const mfxVersion requiredVersion);
+
+    mfxU16 mediaAdapterType;
+    mfxU16 reserved[10];
+};
+
 // declare comparison operator
 inline
 bool operator == (const mfxVersion &one, const mfxVersion &two)
 {
     return (one.Version == two.Version);
 
-} // bool operator == (const mfxVersion &one, const mfxVersion &two)
+}
 
 inline
 bool operator < (const mfxVersion &one, const mfxVersion &two)
 {
-    return (one.Major == two.Major) && (one.Minor < two.Minor);
+    return (one.Major < two.Major) || ((one.Major == two.Major) && (one.Minor < two.Minor));
 
-} // bool operator < (const mfxVersion &one, const mfxVersion &two)
+}
 
 inline
 bool operator <= (const mfxVersion &one, const mfxVersion &two)
 {
     return (one == two) || (one < two);
-} // bool operator <= (const mfxVersion &one, const mfxVersion &two)
+}
 
 
 //

+ 28 - 69
plugins/obs-qsv11/libmfx/include/mfx_dispatcher_defs.h

@@ -1,36 +1,27 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_dispatcher_defs.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2013-2020 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #pragma once
 #include "mfxdefs.h"
 #include <cstring>
+#include <cstdio>
 
 #if defined(MFX_DISPATCHER_LOG)
 #include <string>
@@ -40,49 +31,17 @@ File Name: mfx_dispatcher_defs.h
 #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
-
-#if _MSC_VER >= 1400
-    #define msdk_disp_char_cpy_s(to, to_size, from) wcscpy_s(to,to_size, from)
-#else
-    #define msdk_disp_char_cpy_s(to, to_size, from) wcscpy(to, from)
-#endif
-
-#else
-typedef char msdk_disp_char;
-//#define msdk_disp_char_cpy_s(to, to_size, from) strcpy(to, from)
-
-inline void msdk_disp_char_cpy_s(char * to, size_t to_size, const char * from)
-{
-    size_t source_len = strlen(from);
-    size_t num_chars = (to_size - 1) < source_len ? (to_size - 1) : source_len;
-    strncpy(to, from, num_chars);
-    to[num_chars] = 0;
-}
-
-#if defined(MFX_DISPATCHER_LOG)
-#define MSDK2WIDE(x) getWideString(x).c_str()
-
-inline std::wstring getWideString(const char * string)
-{
-    size_t len = strlen(string);
-    return std::wstring(string, string + len);
-}
-#else
-    #define MSDK2WIDE(x) x  
-#endif
-
+#if _MSC_VER < 1400
+#define wcscpy_s(to,to_size, from) wcscpy(to, from)
+#define wcscat_s(to,to_size, from) wcscat(to, from)
 #endif
 
-#if defined(__GNUC__) && !defined(_WIN32) && !defined(_WIN64)
-#define  sscanf_s  sscanf
-#define  swscanf_s swscanf
-#endif
-
-
 // declare library module's handle
 typedef void * mfxModuleHandle;
 
 typedef void (MFX_CDECL * mfxFunctionPointer)(void);
+
+// Tracer uses lib loading from Program Files logic (via Dispatch reg key) to make dispatcher load tracer dll.
+// With DriverStore loading put at 1st place, dispatcher loads real lib before it finds tracer dll.
+// This workaround explicitly checks tracer presence in Dispatch reg key and loads tracer dll before the search for lib in all other places.
+#define MFX_TRACER_WA_FOR_DS 1

+ 24 - 44
plugins/obs-qsv11/libmfx/include/mfx_dispatcher_log.h

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-Copyright (C) 2012-2014 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_dispatcher_log.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2020 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #if !defined(__MFX_DISPATCHER_LOG_H)
 #define __MFX_DISPATCHER_LOG_H
@@ -91,7 +81,6 @@ enum
 //is a vital if mediasdk wont use
 #define DISPATCHER_LOG_HEAP_SINGLETONES
 
-#if defined(_WIN32) || defined(_WIN64)
 // guid for all dispatcher events
 #define DISPATCHER_LOG_EVENT_GUID L"{EB0538CC-4FEE-484d-ACEE-1182E9F37A57}"
 
@@ -102,8 +91,6 @@ enum
 //#define DISPATCHER_LOG_REGISTER_FILE_WRITER
 #define DISPACTHER_LOG_FW_PATH "c:\\dispatcher.log"
 
-#endif // #if defined(_WIN32) || defined(_WIN64)
-
 #include <stdio.h>
 #include <stdarg.h>
 
@@ -115,7 +102,6 @@ public:
     virtual void Write(int level, int opcode, const char * msg, va_list argptr) = 0;
 };
 
-#if defined(_WIN32) || defined(_WIN64)
 #if  DISPATCHER_LOG_USE_FORMATING
 
     #define DISPATCHER_LOG(lvl, opcode, str)\
@@ -135,10 +121,6 @@ public:
 #endif//DISPATCHER_LOG_USE_FORMATING
 
 #define DISPATCHER_LOG_OPERATION(operation) operation
-#else
-#define DISPATCHER_LOG(lvl, opcode, str)
-#define DISPATCHER_LOG_OPERATION(operation)
-#endif
 
 #define __name_from_line( name, line ) name ## line
 #define _name_from_line( name , line) __name_from_line( name, line ) 
@@ -182,7 +164,7 @@ private:
     //if obj != NULL then it store obj
     inline static T * store_or_load(T * obj = NULL)
     {
-        static std::auto_ptr<T> instance;
+        static std::unique_ptr<T> instance;
         if (NULL != obj)
         {
             instance.reset(obj);
@@ -237,7 +219,6 @@ struct DispatchLogBlockHelper
 };
 
 //----utility sinks-----
-#if defined(_WIN32) || defined(_WIN64)
 #if defined(DISPATCHER_LOG_REGISTER_EVENT_PROVIDER)
 class ETWHandlerFactory
     : public DSSingleTone<ETWHandlerFactory>
@@ -254,7 +235,6 @@ protected:
     ETWHandlerFactory(){}
 };
 #endif
-#endif // #if defined(_WIN32) || defined(_WIN64)
 
 #if defined(DISPATCHER_LOG_REGISTER_FILE_WRITER)
 class FileSink 
@@ -264,6 +244,10 @@ class FileSink
     friend class DSSingleTone<FileSink>;
 public:
     virtual void Write(int level, int opcode, const char * msg, va_list argptr);
+    FileSink()
+        : m_hdl(NULL)
+    {
+    }
     ~FileSink()
     {
         if (NULL != m_hdl)
@@ -273,11 +257,7 @@ private:
     FILE * m_hdl;
     FileSink(const std::string & log_file)
     {
-#if defined(_WIN32) || defined(_WIN64)
         fopen_s(&m_hdl, log_file.c_str(), "a");
-#else
-        m_hdl = fopen(log_file.c_str(), "a");
-#endif
     }
     
 };

+ 65 - 0
plugins/obs-qsv11/libmfx/include/mfx_driver_store_loader.h

@@ -0,0 +1,65 @@
+// Copyright (c) 2019-2020 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#if !defined(__MFX_DRIVER_STORE_LOADER_H)
+#define __MFX_DRIVER_STORE_LOADER_H
+
+#include <windows.h>
+#include <cfgmgr32.h>
+#include <devguid.h>
+
+#include "mfx_dispatcher_defs.h"
+
+namespace MFX
+{
+
+typedef CONFIGRET(WINAPI *Func_CM_Get_Device_ID_List_SizeW)(PULONG pulLen, PCWSTR pszFilter, ULONG ulFlags);
+typedef CONFIGRET(WINAPI *Func_CM_Get_Device_ID_ListW)(PCWSTR pszFilter, PZZWSTR Buffer, ULONG BufferLen, ULONG ulFlags);
+typedef CONFIGRET(WINAPI *Func_CM_Locate_DevNodeW)(PDEVINST pdnDevInst, DEVINSTID_W pDeviceID, ULONG ulFlags);
+typedef CONFIGRET(WINAPI *Func_CM_Open_DevNode_Key)(DEVINST dnDevNode, REGSAM samDesired, ULONG ulHardwareProfile, REGDISPOSITION Disposition, PHKEY phkDevice, ULONG ulFlags);
+
+class DriverStoreLoader
+{
+public:
+    DriverStoreLoader(void);
+    ~DriverStoreLoader(void);
+
+    bool GetDriverStorePath(wchar_t *path, DWORD dwPathSize, mfxU32 deviceID);
+
+protected:
+    bool LoadCfgMgr();
+    bool LoadCmFuncs();
+
+    mfxModuleHandle                  m_moduleCfgMgr;
+    Func_CM_Get_Device_ID_List_SizeW m_pCM_Get_Device_ID_List_Size;
+    Func_CM_Get_Device_ID_ListW      m_pCM_Get_Device_ID_List;
+    Func_CM_Locate_DevNodeW          m_pCM_Locate_DevNode;
+    Func_CM_Open_DevNode_Key         m_pCM_Open_DevNode_Key;
+
+private:
+    // unimplemented by intent to make this class non-copyable
+    DriverStoreLoader(const DriverStoreLoader &);
+    void operator=(const DriverStoreLoader &);
+
+};
+
+} // namespace MFX
+
+#endif // __MFX_DRIVER_STORE_LOADER_H

+ 20 - 40
plugins/obs-qsv11/libmfx/include/mfx_dxva2_device.h

@@ -1,46 +1,34 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_dxva2_device.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #if !defined(__MFX_DXVA2_DEVICE_H)
 #define __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(MEDIASDK_UWP_DISPATCHER)
     #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)
@@ -51,8 +39,6 @@ File Name: mfx_dxva2_device.h
     #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>
 
 #ifdef DXVA2DEVICE_LOG
@@ -101,10 +87,8 @@ protected:
     // Free DLL module
     void UnloadDLLModule(void);
 
-#if defined(_WIN32) || defined(_WIN64)
     // Handle to the DLL library
     HMODULE m_hModule;
-#endif // #if defined(_WIN32) || defined(_WIN64)
 
     // Number of adapters available
     mfxU32 m_numAdapters;
@@ -124,9 +108,6 @@ private:
     void operator=(const DXDevice &);
 };
 
-
-#if defined(_WIN32) || defined(_WIN64)
-
 #ifdef MFX_D3D9_ENABLED
 class D3D9Device : public DXDevice
 {
@@ -180,7 +161,6 @@ protected:
     void *m_pDXGIAdapter1;
 
 };
-#endif // #if defined(_WIN32) || defined(_WIN64)
 
 class DXVA2Device
 {

+ 19 - 29
plugins/obs-qsv11/libmfx/include/mfx_exposed_functions_list.h

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_exposed_functions_list.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 //
 // WARNING:

+ 51 - 93
plugins/obs-qsv11/libmfx/include/mfx_library_iterator.h

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_library_iterator.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2020 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #if !defined(__MFX_LIBRARY_ITERATOR_H)
 #define __MFX_LIBRARY_ITERATOR_H
@@ -34,68 +24,41 @@ File Name: mfx_library_iterator.h
 
 #include <mfxvideo.h>
 
-#if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+#if !defined(MEDIASDK_UWP_DISPATCHER)
 #include "mfx_win_reg_key.h"
 #endif
 
-#include "mfx_dispatcher.h"
-
-#if !defined(_WIN32) && !defined(_WIN64)
-struct mfx_disp_adapters
-{
-    mfxU32 vendor_id;
-    mfxU32 device_id;
-};
+#include "mfx_driver_store_loader.h"
 
-#ifndef __APPLE__
-#define MFX_SO_BASE_NAME_LEN 15 // sizeof("libmfxhw32-p.so") = 15
-#else
-
-#define MFX_SO_BASE_NAME_LEN 16 // sizeof("libmfxhw64.dylib") = 16
-#endif
-
-#define MFX_MIN_REAL_LIBNAME MFX_SO_BASE_NAME_LEN + 4 // sizeof("libmfxhw32-p.so.0.0") >= 19
-#define MFX_MAX_REAL_LIBNAME MFX_MIN_REAL_LIBNAME + 8 // sizeof("libmfxhw32-p.so.<mj>.<mn>") <= 27, max(sizeof(<mj>))=sizeof(0xFFFF) = sizeof(65535) = 5
-
-struct mfx_libs
-{
-    char name[MFX_MAX_REAL_LIBNAME+1];
-    mfxVersion version;
-};
-#endif
+#include "mfx_dispatcher.h"
 
 namespace MFX
 {
 
 // declare desired storage ID
-#if defined(_WIN32) || defined(_WIN64)
 enum
 {
+#if defined (MFX_TRACER_WA_FOR_DS)
     MFX_UNKNOWN_KEY             = -1,
-    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_PATH_MSDK_FOLDER
-#else
-    MFX_PATH_MSDK_FOLDER = 3,
-    MFX_STORAGE_ID_FIRST = MFX_PATH_MSDK_FOLDER,
+    MFX_TRACER                  = 0,
+    MFX_DRIVER_STORE            = 1,
+    MFX_CURRENT_USER_KEY        = 2,
+    MFX_LOCAL_MACHINE_KEY       = 3,
+    MFX_APP_FOLDER              = 4,
+    MFX_PATH_MSDK_FOLDER        = 5,
+    MFX_STORAGE_ID_FIRST = MFX_TRACER,
     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: MFX_MODULES_DIR
-    MFX_APP_FOLDER      = 1,
-
-    MFX_STORAGE_ID_FIRST   =  MFX_STORAGE_ID_OPT,
-    MFX_STORAGE_ID_LAST    = MFX_STORAGE_ID_OPT
-};
+    MFX_UNKNOWN_KEY             = -1,
+    MFX_DRIVER_STORE            = 0,
+    MFX_CURRENT_USER_KEY        = 1,
+    MFX_LOCAL_MACHINE_KEY       = 2,
+    MFX_APP_FOLDER              = 3,
+    MFX_PATH_MSDK_FOLDER        = 4,
+    MFX_STORAGE_ID_FIRST    = MFX_DRIVER_STORE,
+    MFX_STORAGE_ID_LAST     = MFX_PATH_MSDK_FOLDER
 #endif
+};
 
 // Try to initialize using given implementation type. Select appropriate type automatically in case of MFX_IMPL_VIA_ANY.
 // Params: adapterNum - in, pImplInterface - in/out, pVendorID - out, pDeviceID - out
@@ -115,14 +78,14 @@ 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(wchar_t *pPath, size_t pathSize,
                                eMfxImplType *pImplType, mfxVersion minVersion);
 
     // Return interface type on which Intel adapter was found (if any): D3D9 or D3D11
     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;
+    bool GetSubKeyName(wchar_t *subKeyName, size_t length) const;
 
     int  GetStorageID() const { return m_StorageID; }
 protected:
@@ -131,9 +94,13 @@ protected:
     void Release(void);
 
     // Initialize the registry iterator
-    mfxStatus InitRegistry(eMfxImplType implType, mfxIMPL implInterface, const mfxU32 adapterNum, int storageID);
-    // Initialize the app folder iterator
-    mfxStatus InitFolder(eMfxImplType implType, mfxIMPL implInterface, const mfxU32 adapterNum, const msdk_disp_char * path);
+    mfxStatus InitRegistry(int storageID);
+#if defined(MFX_TRACER_WA_FOR_DS)
+    // Initialize the registry iterator for searching for tracer
+    mfxStatus InitRegistryTracer();
+#endif
+    // Initialize the app/module folder iterator
+    mfxStatus InitFolder(eMfxImplType implType, const wchar_t * path, const int storageID);
 
 
     eMfxImplType m_implType;                                    // Required library implementation
@@ -145,25 +112,16 @@ protected:
     wchar_t m_SubKeyName[MFX_MAX_REGISTRY_KEY_NAME];            // registry subkey for selected module loaded
     int    m_StorageID;
 
-#if defined(_WIN32) || defined(_WIN64)
-
-#if defined(MEDIASDK_USE_REGISTRY) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
+#if !defined(MEDIASDK_UWP_DISPATCHER)
     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
-#else
-    int                       m_lastLibIndex;                   // (mfxU32) index of previously returned library
 
-    mfxU32                    m_adapters_num;
-    struct mfx_disp_adapters* m_adapters;
-    int                       m_selected_adapter;
-    mfxU32                    m_libs_num;
-    struct mfx_libs*          m_libs;
-#endif // #if defined(_WIN32) || defined(_WIN64)
+    wchar_t  m_path[msdk_disp_path_len];
 
-    msdk_disp_char  m_path[msdk_disp_path_len];
+    DriverStoreLoader m_driverStoreLoader;                      // for loading MediaSDK from DriverStore
 
 private:
     // unimplemented by intent to make this class non-copyable

+ 28 - 35
plugins/obs-qsv11/libmfx/include/mfx_load_dll.h

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-Copyright (C) 2012-2014 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_load_dll.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #if !defined(__MFX_LOAD_DLL_H)
 #define __MFX_LOAD_DLL_H
@@ -41,16 +31,19 @@ namespace MFX
     // declare DLL loading routines
     //
 
-    mfxStatus mfx_get_rt_dll_name(msdk_disp_char *pPath, size_t pathSize);
-    mfxStatus mfx_get_default_dll_name(msdk_disp_char *pPath, size_t pathSize, eMfxImplType implType);
-    mfxStatus mfx_get_default_plugin_name(msdk_disp_char *pPath, size_t pathSize, eMfxImplType implType);
+    mfxStatus mfx_get_rt_dll_name(wchar_t *pPath, size_t pathSize);
+    mfxStatus mfx_get_default_dll_name(wchar_t *pPath, size_t pathSize, eMfxImplType implType);
+    mfxStatus mfx_get_default_plugin_name(wchar_t *pPath, size_t pathSize, eMfxImplType implType);
+#if defined(MEDIASDK_UWP_DISPATCHER)
+    mfxStatus mfx_get_default_intel_gfx_api_dll_name(wchar_t *pPath, size_t pathSize);
+#endif
 
-    mfxStatus mfx_get_default_audio_dll_name(msdk_disp_char *pPath, size_t pathSize, eMfxImplType implType);
+    mfxStatus mfx_get_default_audio_dll_name(wchar_t *pPath, size_t pathSize, eMfxImplType implType);
     
 
-    mfxModuleHandle mfx_dll_load(const msdk_disp_char *file_name);
+    mfxModuleHandle mfx_dll_load(const wchar_t *file_name);
     //increments reference counter
-    mfxModuleHandle mfx_get_dll_handle(const msdk_disp_char *file_name);
+    mfxModuleHandle mfx_get_dll_handle(const wchar_t *file_name);
     mfxFunctionPointer mfx_dll_get_addr(mfxModuleHandle handle, const char *func_name);
     bool mfx_dll_free(mfxModuleHandle handle);
 

+ 22 - 32
plugins/obs-qsv11/libmfx/include/mfx_load_plugin.h

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_load_plugin.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2013-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #pragma once
 #include "mfxplugin.h"
@@ -41,11 +31,11 @@ namespace MFX
     {
         mfxModuleHandle mHmodule;
         CreatePluginPtr_t mCreatePluginPtr;
-        msdk_disp_char mPath[MAX_PLUGIN_PATH];
+        wchar_t mPath[MAX_PLUGIN_PATH];
         
     public:
         PluginModule();
-        PluginModule(const msdk_disp_char * path);
+        PluginModule(const wchar_t * path);
         PluginModule(const PluginModule & that) ;
         PluginModule & operator = (const PluginModule & that);
         bool Create(mfxPluginUID guid, mfxPlugin&);
@@ -61,7 +51,7 @@ namespace MFX
             PluginModule module;
             mfxPlugin plugin;
             FactoryRecord ()
-                : plugin()
+                : plgParams(), plugin()
             {}
             FactoryRecord(const mfxPluginParam &plgParams,
                           PluginModule &module,

+ 26 - 34
plugins/obs-qsv11/libmfx/include/mfx_plugin_hive.h

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_plugin_hive.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2013-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #pragma once
 
@@ -58,7 +48,7 @@ namespace MFX {
     class PluginDescriptionRecord :  public mfxPluginParam 
     {
     public:
-        msdk_disp_char sPath[MAX_PLUGIN_PATH];
+        wchar_t sPath[MAX_PLUGIN_PATH];
         char sName[MAX_PLUGIN_NAME];
         //used for FS plugins that has poor description
         bool onlyVersionRegistered;
@@ -91,14 +81,15 @@ namespace MFX {
         }
     };
 
+#if !defined(MEDIASDK_UWP_DISPATCHER)
+
     //populated from registry
     class MFXPluginsInHive : public MFXPluginStorageBase
     {
     public:
-        MFXPluginsInHive(int mfxStorageID, const msdk_disp_char *msdkLibSubKey, mfxVersion currentAPIVersion);
+        MFXPluginsInHive(int mfxStorageID, const wchar_t *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
     {
@@ -108,9 +99,10 @@ namespace MFX {
         MFXPluginsInFS(mfxVersion currentAPIVersion);
     private:
         bool ParseFile(FILE * f, PluginDescriptionRecord & des);
-        bool ParseKVPair( msdk_disp_char *key, msdk_disp_char * value, PluginDescriptionRecord & des);
+        bool ParseKVPair( wchar_t *key, wchar_t * value, PluginDescriptionRecord & des);
     };
-#endif //#if defined(MEDIASDK_USE_CFGFILES) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
+
+#endif //#if !defined(MEDIASDK_UWP_DISPATCHER)
 
     //plugins are loaded from FS close to Runtime library
     class MFXDefaultPlugins : public MFXPluginStorageBase

+ 58 - 61
plugins/obs-qsv11/libmfx/include/mfx_vector.h

@@ -1,81 +1,71 @@
-/* ****************************************************************************** *\
-
-Copyright (C) 2013-2014 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_vector.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2013-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #pragma once
 #include "mfxstructures.h"
 #include <exception>
 
-namespace MFX 
+namespace MFX
 {
     template <class T>
-    class iterator_tmpl 
+    class iterator_tmpl
     {
         template <class U> friend class MFXVector;
         mfxU32 mIndex;
         T* mRecords;
-        iterator_tmpl(mfxU32 index , T * records) 
+        iterator_tmpl(mfxU32 index , T * records)
             : mIndex (index)
             , mRecords(records)
         {}
     public:
-        iterator_tmpl() 
+        iterator_tmpl()
             : mIndex ()
-            , mRecords() 
+            , mRecords()
         {}
-        bool  operator ==(const iterator_tmpl<T> & that )const 
+        bool  operator ==(const iterator_tmpl<T> & that )const
         {
             return mIndex == that.mIndex;
         }
-        bool  operator !=(const iterator_tmpl<T> & that )const 
+        bool  operator !=(const iterator_tmpl<T> & that )const
         {
             return mIndex != that.mIndex;
         }
-        mfxU32 operator - (const iterator_tmpl<T> &that) const 
+        mfxU32 operator - (const iterator_tmpl<T> &that) const
         {
             return mIndex - that.mIndex;
         }
-        iterator_tmpl<T> & operator ++() 
+        iterator_tmpl<T> & operator ++()
         {
             mIndex++;
             return * this;
         }
-        iterator_tmpl<T> & operator ++(int) 
+        iterator_tmpl<T> & operator ++(int)
         {
             mIndex++;
             return * this;
         }
-        T & operator *() 
+        T & operator *()
         {
             return mRecords[mIndex];
         }
-        T * operator ->() 
+        T * operator ->()
         {
             return mRecords + mIndex;
         }
@@ -86,7 +76,7 @@ namespace MFX
     };
 
     template <class T>
-    class MFXVector  
+    class MFXVector
     {
         T*      mRecords;
         mfxU32  mNrecords;
@@ -103,7 +93,7 @@ namespace MFX
         }
         MFXVector & operator = (const MFXVector & rhs)
         {
-            if (this != &rhs) 
+            if (this != &rhs)
             {
                 clear();
                 insert(end(), rhs.begin(), rhs.end());
@@ -116,15 +106,15 @@ namespace MFX
         }
         typedef iterator_tmpl<T> iterator;
 
-        iterator begin() const 
+        iterator begin() const
         {
             return iterator(0u, mRecords);
         }
-        iterator end() const 
+        iterator end() const
         {
             return iterator(mNrecords, mRecords);
         }
-        void insert(iterator where, iterator beg_iter, iterator end_iter) 
+        void insert(iterator where, iterator beg_iter, iterator end_iter)
         {
             mfxU32 elementsToInsert = (end_iter - beg_iter);
             if (!elementsToInsert)
@@ -138,20 +128,20 @@ namespace MFX
 
             T *newRecords = new T[mNrecords + elementsToInsert]();
             mfxU32 i = 0;
-            
+
             // save left
-            for (; i < where.mIndex; i++) 
+            for (; i < where.mIndex; i++)
             {
                 newRecords[i] = mRecords[i];
             }
             // insert
-            for (; beg_iter != end_iter; beg_iter++, i++) 
+            for (; beg_iter != end_iter; beg_iter++, i++)
             {
                 newRecords[i] = *beg_iter;
             }
-    
+
             //save right
-            for (; i < mNrecords + elementsToInsert; i++) 
+            for (; i < mNrecords + elementsToInsert; i++)
             {
                 newRecords[i] = mRecords[i - elementsToInsert];
             }
@@ -161,15 +151,15 @@ namespace MFX
             mRecords = newRecords;
             mNrecords = i;
         }
-        T& operator [] (mfxU32 idx) 
+        T& operator [] (mfxU32 idx)
         {
           return mRecords[idx];
         }
-        void push_back(const T& obj) 
+        void push_back(const T& obj)
         {
             T *newRecords = new T[mNrecords + 1]();
             mfxU32 i = 0;
-            for (; i <mNrecords; i++) 
+            for (; i <mNrecords; i++)
             {
                 newRecords[i] = mRecords[i];
             }
@@ -178,15 +168,14 @@ namespace MFX
 
             mRecords = newRecords;
             mNrecords = i + 1;
-            
         }
-        void erase (iterator at) 
+        void erase (iterator at)
         {
             if (at.mIndex >= mNrecords)
             {
                 throw MFXVectorRangeError();
             }
-            mNrecords--; 
+            mNrecords--;
             mfxU32 i = at.mIndex;
             for (; i != mNrecords; i++)
             {
@@ -195,10 +184,10 @@ namespace MFX
             //destroy last element
             mRecords[i] = T();
         }
-        void resize(mfxU32 nSize) 
+        void resize(mfxU32 nSize)
         {
             T * newRecords = new T[nSize]();
-            for (mfxU32 i = 0; i <mNrecords; i++) 
+            for (mfxU32 i = 0; i <mNrecords; i++)
             {
                 newRecords[i] = mRecords[i];
             }
@@ -206,15 +195,23 @@ namespace MFX
             mRecords = newRecords;
             mNrecords = nSize;
         }
-        mfxU32 size() const 
+        mfxU32 size() const
         {
             return mNrecords;
         }
-        void clear() 
+        void clear()
         {
             delete [] mRecords;
             mRecords = 0;
             mNrecords = 0;
         }
+        bool empty()
+        {
+            return !mRecords;
+        }
+        T * data() const
+        {
+            return mRecords;
+        }
     };
 }

+ 21 - 33
plugins/obs-qsv11/libmfx/include/mfx_win_reg_key.h

@@ -1,42 +1,31 @@
-/* ****************************************************************************** *\
-
-Copyright (C) 2012-2014 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_win_reg_key.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #if !defined(__MFX_WIN_REG_KEY_H)
 #define __MFX_WIN_REG_KEY_H
 
-#if defined(_WIN32) || defined(_WIN64)
-
 #include <windows.h>
 #include "mfxplugin.h"
 #include "mfx_dispatcher_log.h"
 
+#if !defined(MEDIASDK_UWP_DISPATCHER)
 namespace MFX {
 
 template<class T> struct RegKey{};
@@ -110,7 +99,6 @@ inline bool QueryKey<bool>(WinRegKey & key, const wchar_t *pValueName, bool &dat
 
 
 } // namespace MFX
-
-#endif // #if defined(_WIN32) || defined(_WIN64)
+#endif // #if !defined(MEDIASDK_UWP_DISPATCHER)
 
 #endif // __MFX_WIN_REG_KEY_H

+ 19 - 29
plugins/obs-qsv11/libmfx/include/mfxaudio_exposed_functions_list.h

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-Copyright (C) 2013-2014 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxaudio_exposed_function_list.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2013-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 //
 // WARNING:

+ 40 - 0
plugins/obs-qsv11/libmfx/include/msdk/include/mfxadapter.h

@@ -0,0 +1,40 @@
+// Copyright (c) 2019-2020 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "mfxdefs.h"
+#if (MFX_VERSION >= 1031)
+#ifndef __MFXADAPTER_H__
+#define __MFXADAPTER_H__
+
+#include "mfxstructures.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+mfxStatus MFX_CDECL MFXQueryAdapters(mfxComponentInfo* input_info, mfxAdaptersInfo* adapters);
+mfxStatus MFX_CDECL MFXQueryAdaptersDecode(mfxBitstream* bitstream, mfxU32 codec_id, mfxAdaptersInfo* adapters);
+mfxStatus MFX_CDECL MFXQueryAdaptersNumber(mfxU32* num_adapters);
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // __MFXADAPTER_H__
+#endif

+ 27 - 29
plugins/obs-qsv11/libmfx/include/msdk/include/mfxastructures.h

@@ -1,32 +1,22 @@
-/*******************************************************************************
-
-Copyright (C) 2013 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxastructures.h
-
-*******************************************************************************/
+// Copyright (c) 2017-2019 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 #ifndef __MFXASTRUCTURES_H__
 #define __MFXASTRUCTURES_H__
 #include "mfxcommon.h"
@@ -103,6 +93,7 @@ enum
     MFX_AUDIO_AAC_JOINT_STEREO=    3
 };
 
+MFX_PACK_BEGIN_USUAL_STRUCT()
 typedef struct {
     mfxU32                CodecId;
     mfxU16                CodecProfile;
@@ -129,7 +120,9 @@ typedef struct {
         };
     };
 } mfxAudioInfoMFX;
+MFX_PACK_END()
 
+MFX_PACK_BEGIN_STRUCT_W_PTR()
 typedef struct {
     mfxU16  AsyncDepth;
     mfxU16  Protected;
@@ -139,13 +132,17 @@ typedef struct {
     mfxExtBuffer**    ExtParam;
     mfxU16            NumExtParam;
 } mfxAudioParam;
+MFX_PACK_END()
 
+MFX_PACK_BEGIN_USUAL_STRUCT()
 typedef struct {
     mfxU32  SuggestedInputSize;
     mfxU32  SuggestedOutputSize;
     mfxU32  reserved[6];
 } mfxAudioAllocRequest;
+MFX_PACK_END()
 
+MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
 typedef struct {
     mfxU64  TimeStamp; /* 1/90KHz */
     mfxU16  Locked;
@@ -162,6 +159,7 @@ typedef struct {
     mfxU32  NumExtParam;
     mfxExtBuffer **ExtParam;
 } mfxAudioFrame;
+MFX_PACK_END()
 
 #ifdef __cplusplus
 }

+ 19 - 31
plugins/obs-qsv11/libmfx/include/msdk/include/mfxaudio++.h

@@ -1,34 +1,22 @@
-/*******************************************************************************
-
-Copyright (C) 2013 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-File Name: mfxaudio++.h
-
-
-*******************************************************************************/
+// Copyright (c) 2017 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 #ifndef __MFXAUDIOPLUSPLUS_H
 #define __MFXAUDIOPLUSPLUS_H
 

+ 35 - 45
plugins/obs-qsv11/libmfx/include/msdk/include/mfxaudio.h

@@ -1,32 +1,22 @@
-/*******************************************************************************
-
-Copyright (C) 2013 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxaudio.h
-
-*******************************************************************************/
+// Copyright (c) 2017 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #ifndef __MFXAUDIO_H__
 #define __MFXAUDIO_H__
@@ -42,26 +32,26 @@ extern "C"
 #endif
 
 /* AudioCORE */
-mfxStatus MFX_CDECL MFXAudioCORE_SyncOperation(mfxSession session, mfxSyncPoint syncp, mfxU32 wait);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioCORE_SyncOperation(mfxSession session, mfxSyncPoint syncp, mfxU32 wait);
 
 /* AudioENCODE */
-mfxStatus MFX_CDECL MFXAudioENCODE_Query(mfxSession session, mfxAudioParam *in, mfxAudioParam *out);
-mfxStatus MFX_CDECL MFXAudioENCODE_QueryIOSize(mfxSession session, mfxAudioParam *par, mfxAudioAllocRequest *request);
-mfxStatus MFX_CDECL MFXAudioENCODE_Init(mfxSession session, mfxAudioParam *par);
-mfxStatus MFX_CDECL MFXAudioENCODE_Reset(mfxSession session, mfxAudioParam *par);
-mfxStatus MFX_CDECL MFXAudioENCODE_Close(mfxSession session);
-mfxStatus MFX_CDECL MFXAudioENCODE_GetAudioParam(mfxSession session, mfxAudioParam *par);
-mfxStatus MFX_CDECL MFXAudioENCODE_EncodeFrameAsync(mfxSession session, mfxAudioFrame *frame, mfxBitstream *bs, mfxSyncPoint *syncp);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioENCODE_Query(mfxSession session, mfxAudioParam *in, mfxAudioParam *out);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioENCODE_QueryIOSize(mfxSession session, mfxAudioParam *par, mfxAudioAllocRequest *request);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioENCODE_Init(mfxSession session, mfxAudioParam *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioENCODE_Reset(mfxSession session, mfxAudioParam *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioENCODE_Close(mfxSession session);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioENCODE_GetAudioParam(mfxSession session, mfxAudioParam *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioENCODE_EncodeFrameAsync(mfxSession session, mfxAudioFrame *frame, mfxBitstream *bs, mfxSyncPoint *syncp);
 
 /* AudioDECODE */
-mfxStatus MFX_CDECL MFXAudioDECODE_Query(mfxSession session, mfxAudioParam *in, mfxAudioParam *out);
-mfxStatus MFX_CDECL MFXAudioDECODE_DecodeHeader(mfxSession session, mfxBitstream *bs, mfxAudioParam* par);
-mfxStatus MFX_CDECL MFXAudioDECODE_Init(mfxSession session, mfxAudioParam *par);
-mfxStatus MFX_CDECL MFXAudioDECODE_Reset(mfxSession session, mfxAudioParam *par);
-mfxStatus MFX_CDECL MFXAudioDECODE_Close(mfxSession session);
-mfxStatus MFX_CDECL MFXAudioDECODE_QueryIOSize(mfxSession session, mfxAudioParam *par, mfxAudioAllocRequest *request);
-mfxStatus MFX_CDECL MFXAudioDECODE_GetAudioParam(mfxSession session, mfxAudioParam *par);
-mfxStatus MFX_CDECL MFXAudioDECODE_DecodeFrameAsync(mfxSession session, mfxBitstream *bs, mfxAudioFrame *frame, mfxSyncPoint *syncp);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioDECODE_Query(mfxSession session, mfxAudioParam *in, mfxAudioParam *out);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioDECODE_DecodeHeader(mfxSession session, mfxBitstream *bs, mfxAudioParam* par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioDECODE_Init(mfxSession session, mfxAudioParam *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioDECODE_Reset(mfxSession session, mfxAudioParam *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioDECODE_Close(mfxSession session);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioDECODE_QueryIOSize(mfxSession session, mfxAudioParam *par, mfxAudioAllocRequest *request);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioDECODE_GetAudioParam(mfxSession session, mfxAudioParam *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioDECODE_DecodeFrameAsync(mfxSession session, mfxBitstream *bs, mfxAudioFrame *frame, mfxSyncPoint *syncp);
 
 #ifdef __cplusplus
 } // extern "C"

+ 63 - 31
plugins/obs-qsv11/libmfx/include/msdk/include/mfxcommon.h

@@ -1,32 +1,22 @@
-/*******************************************************************************
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxcommon.h
-
-*******************************************************************************/
+// Copyright (c) 2018-2020 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 #ifndef __MFXCOMMON_H__
 #define __MFXCOMMON_H__
 #include "mfxdefs.h"
@@ -43,10 +33,12 @@ extern "C"
 #define MFX_MAKEFOURCC(A,B,C,D)    ((((int)A))+(((int)B)<<8)+(((int)C)<<16)+(((int)D)<<24))
 
 /* Extended Configuration Header Structure */
+MFX_PACK_BEGIN_USUAL_STRUCT()
 typedef struct {
     mfxU32  BufferId;
     mfxU32  BufferSz;
 } mfxExtBuffer;
+MFX_PACK_END()
 
 /* Library initialization and deinitialization */
 typedef mfxI32 mfxIMPL;
@@ -62,17 +54,24 @@ enum  {
     MFX_IMPL_HARDWARE3    = 0x0006,  /* Hardware accelerated implementation (3rd device) */
     MFX_IMPL_HARDWARE4    = 0x0007,  /* Hardware accelerated implementation (4th device) */
     MFX_IMPL_RUNTIME      = 0x0008,
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+    MFX_IMPL_SINGLE_THREAD= 0x0009,
+#endif
     MFX_IMPL_VIA_ANY      = 0x0100,
     MFX_IMPL_VIA_D3D9     = 0x0200,
     MFX_IMPL_VIA_D3D11    = 0x0300,
     MFX_IMPL_VIA_VAAPI    = 0x0400,
 
     MFX_IMPL_AUDIO                     = 0x8000,
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+    MFX_IMPL_EXTERNAL_THREADING        = 0x10000,
+#endif
 
     MFX_IMPL_UNSUPPORTED  = 0x0000  /* One of the MFXQueryIMPL returns */
 };
 
 /* Version Info */
+MFX_PACK_BEGIN_USUAL_STRUCT()
 typedef union {
     struct {
         mfxU16  Minor;
@@ -80,6 +79,7 @@ typedef union {
     };
     mfxU32  Version;
 } mfxVersion;
+MFX_PACK_END()
 
 /* session priority */
 typedef enum
@@ -91,6 +91,7 @@ typedef enum
 } mfxPriority;
 
 typedef struct _mfxEncryptedData mfxEncryptedData;
+MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
 typedef struct {
      union {
         struct {
@@ -100,7 +101,7 @@ typedef struct {
         };
          mfxU32  reserved[6];
      };
-    mfxI64  DecodeTimeStamp; 
+    mfxI64  DecodeTimeStamp;
     mfxU64  TimeStamp;
     mfxU8*  Data;
     mfxU32  DataOffset;
@@ -112,6 +113,7 @@ typedef struct {
     mfxU16  DataFlag;
     mfxU16  reserved2;
 } mfxBitstream;
+MFX_PACK_END()
 
 typedef struct _mfxSyncPoint *mfxSyncPoint;
 
@@ -122,6 +124,7 @@ enum {
     MFX_GPUCOPY_OFF     = 2
 };
 
+MFX_PACK_BEGIN_STRUCT_W_PTR()
 typedef struct {
     mfxIMPL     Implementation;
     mfxVersion  Version;
@@ -136,11 +139,13 @@ typedef struct {
     mfxU16      GPUCopy;
     mfxU16      reserved[21];
 } mfxInitParam;
+MFX_PACK_END()
 
 enum {
     MFX_EXTBUFF_THREADS_PARAM = MFX_MAKEFOURCC('T','H','D','P')
 };
 
+MFX_PACK_BEGIN_USUAL_STRUCT()
 typedef struct {
     mfxExtBuffer Header;
 
@@ -149,6 +154,7 @@ typedef struct {
     mfxI32       Priority;
     mfxU16       reserved[55];
 } mfxExtThreadsParam;
+MFX_PACK_END()
 
 /* PlatformCodeName */
 enum {
@@ -162,17 +168,43 @@ enum {
     MFX_PLATFORM_SKYLAKE        = 7,
     MFX_PLATFORM_APOLLOLAKE     = 8,
     MFX_PLATFORM_KABYLAKE       = 9,
+#if (MFX_VERSION >= 1025)
     MFX_PLATFORM_GEMINILAKE     = 10,
     MFX_PLATFORM_COFFEELAKE     = 11,
     MFX_PLATFORM_CANNONLAKE     = 20,
-    MFX_PLATFORM_ICELAKE = 30,
+#endif
+#if (MFX_VERSION >= 1027)
+    MFX_PLATFORM_ICELAKE        = 30,
+#endif
+    MFX_PLATFORM_JASPERLAKE     = 32,
+    MFX_PLATFORM_ELKHARTLAKE    = 33,
+    MFX_PLATFORM_TIGERLAKE      = 40,
+    MFX_PLATFORM_ROCKETLAKE     = 42,
+    MFX_PLATFORM_ALDERLAKE_S    = 43,
+    MFX_PLATFORM_KEEMBAY        = 50,
 };
 
+#if (MFX_VERSION >= 1031)
+typedef enum
+{
+    MFX_MEDIA_UNKNOWN           = 0xffff,
+    MFX_MEDIA_INTEGRATED        = 0,
+    MFX_MEDIA_DISCRETE          = 1
+} mfxMediaAdapterType;
+#endif
+
+MFX_PACK_BEGIN_USUAL_STRUCT()
 typedef struct {
     mfxU16 CodeName;
     mfxU16 DeviceId;
+#if (MFX_VERSION >= 1031)
+    mfxU16 MediaAdapterType;
+    mfxU16 reserved[13];
+#else
     mfxU16 reserved[14];
+#endif
 } mfxPlatform;
+MFX_PACK_END()
 
 #ifdef __cplusplus
 }

+ 132 - 41
plugins/obs-qsv11/libmfx/include/msdk/include/mfxdefs.h

@@ -1,68 +1,154 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxdefs.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2019-2020 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 #ifndef __MFXDEFS_H__
 #define __MFXDEFS_H__
 
 #define MFX_VERSION_MAJOR 1
-#define MFX_VERSION_MINOR 27
+#define MFX_VERSION_MINOR 35
 
-#define MFX_VERSION_NEXT 1028
+// MFX_VERSION_NEXT is always +1 from last public release
+// may be enforced by MFX_VERSION_USE_LATEST define
+// if MFX_VERSION_USE_LATEST is defined  MFX_VERSION is ignored
 
-#ifndef MFX_VERSION
-#define MFX_VERSION (MFX_VERSION_MAJOR * 1000 + MFX_VERSION_MINOR)
+#define MFX_VERSION_NEXT (MFX_VERSION_MAJOR * 1000 + MFX_VERSION_MINOR + 1)
+
+// MFX_VERSION - version of API that 'assumed' by build may be provided externally
+// if it omitted then latest stable API derived from Major.Minor is assumed
+
+
+#if !defined(MFX_VERSION)
+  #if defined(MFX_VERSION_USE_LATEST)
+    #define MFX_VERSION MFX_VERSION_NEXT
+  #else
+    #define MFX_VERSION (MFX_VERSION_MAJOR * 1000 + MFX_VERSION_MINOR)
+  #endif
+#else
+  #undef MFX_VERSION_MINOR
+  #define MFX_VERSION_MINOR ((MFX_VERSION) % 1000)
 #endif
 
+
 #ifdef __cplusplus
 extern "C"
 {
 #endif /* __cplusplus */
 
+/* In preprocessor syntax # symbol has stringize meaning,
+   so to expand some macro to preprocessor pragma we need to use
+   special compiler dependent construction */
+
+#if defined(_MSC_VER)
+    #define MFX_PRAGMA_IMPL(x) __pragma(x)
+#else
+    #define MFX_PRAGMA_IMPL(x) _Pragma(#x)
+#endif
+
+#define MFX_PACK_BEGIN_X(x) MFX_PRAGMA_IMPL(pack(push, x))
+#define MFX_PACK_END()      MFX_PRAGMA_IMPL(pack(pop))
+
+/* The general rule for alignment is following:
+   - structures with pointers have 4/8 bytes alignment on 32/64 bit systems
+   - structures with fields of type mfxU64/mfxF64 (unsigned long long / double)
+     have alignment 8 bytes on 64 bit and 32 bit Windows, on Linux alignment is 4 bytes
+   - all the rest structures are 4 bytes aligned
+   - there are several exceptions: some structs which had 4-byte alignment were extended
+     with pointer / long type fields; such structs have 4-byte alignment to keep binary
+     compatibility with previously release API */
+
+#define MFX_PACK_BEGIN_USUAL_STRUCT()        MFX_PACK_BEGIN_X(4)
 
-#if (defined( _WIN32 ) || defined ( _WIN64 )) && !defined (__GNUC__)
-  #define __INT64   __int64
-  #define __UINT64  unsigned __int64
+/* 64-bit LP64 data model */
+#if defined(_WIN64) || defined(__LP64__)
+    #define MFX_PACK_BEGIN_STRUCT_W_PTR()    MFX_PACK_BEGIN_X(8)
+    #define MFX_PACK_BEGIN_STRUCT_W_L_TYPE() MFX_PACK_BEGIN_X(8)
+/* 32-bit ILP32 data model Windows (Intel architecture) */
+#elif defined(_WIN32) || defined(_M_IX86) && !defined(__linux__)
+    #define MFX_PACK_BEGIN_STRUCT_W_PTR()    MFX_PACK_BEGIN_X(4)
+    #define MFX_PACK_BEGIN_STRUCT_W_L_TYPE() MFX_PACK_BEGIN_X(8)
+/* 32-bit ILP32 data model Linux */
+#elif defined(__ILP32__)
+    #define MFX_PACK_BEGIN_STRUCT_W_PTR()    MFX_PACK_BEGIN_X(4)
+    #define MFX_PACK_BEGIN_STRUCT_W_L_TYPE() MFX_PACK_BEGIN_X(4)
 #else
+    #error Unknown packing
+#endif
+
   #define __INT64   long long
   #define __UINT64  unsigned long long
-#endif
 
 #ifdef _WIN32
-    #define MFX_CDECL __cdecl
-    #define MFX_STDCALL __stdcall
+  #define MFX_CDECL __cdecl
+  #define MFX_STDCALL __stdcall
 #else
-    #define MFX_CDECL
-    #define MFX_STDCALL
+  #define MFX_CDECL
+  #define MFX_STDCALL
 #endif /* _WIN32 */
 
 #define MFX_INFINITE 0xFFFFFFFF
 
+#if !defined(MFX_DEPRECATED_OFF) && (MFX_VERSION >= 1034)
+#define MFX_DEPRECATED_OFF
+#endif
+
+#ifndef MFX_DEPRECATED_OFF
+  #if defined(__cplusplus) && __cplusplus >= 201402L
+    #define MFX_DEPRECATED [[deprecated]]
+    #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg [[deprecated]]
+    #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg)
+  #elif defined(__clang__)
+    #define MFX_DEPRECATED __attribute__((deprecated))
+    #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg __attribute__((deprecated))
+    #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg)
+  #elif defined(__INTEL_COMPILER)
+    #if (defined(_WIN32) || defined(_WIN64))
+      #define MFX_DEPRECATED __declspec(deprecated)
+      #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg
+      #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg) __pragma(deprecated(arg))
+    #elif defined(__linux__)
+      #define MFX_DEPRECATED __attribute__((deprecated))
+      #if defined(__cplusplus)
+        #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg __attribute__((deprecated))
+      #else
+        #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg
+      #endif
+      #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg)
+    #endif
+  #elif defined(_MSC_VER) && _MSC_VER > 1200 // VS 6 doesn't support deprecation
+    #define MFX_DEPRECATED __declspec(deprecated)
+    #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg
+    #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg) __pragma(deprecated(arg))
+  #elif defined(__GNUC__)
+    #define MFX_DEPRECATED __attribute__((deprecated))
+    #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg __attribute__((deprecated))
+    #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg)
+  #else
+    #define MFX_DEPRECATED
+    #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg
+    #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg)
+  #endif
+#else
+  #define MFX_DEPRECATED
+  #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg
+  #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg)
+#endif
+
 typedef unsigned char       mfxU8;
 typedef char                mfxI8;
 typedef short               mfxI16;
@@ -141,6 +227,11 @@ typedef enum
     MFX_WRN_FILTER_SKIPPED              = 10,   /* one of requested filters has been skipped */
     MFX_WRN_INCOMPATIBLE_AUDIO_PARAM    = 11,   /* incompatible audio parameters */
 
+#if MFX_VERSION >= 1031
+    /* low-delay partial output */
+    MFX_ERR_NONE_PARTIAL_OUTPUT         = 12,   /* frame is not ready, but bitstream contains partial output */
+#endif
+
     /* threading statuses */
     MFX_TASK_DONE = MFX_ERR_NONE,               /* task has been completed */
     MFX_TASK_WORKING                    = 8,    /* there is some more work to do */

+ 34 - 42
plugins/obs-qsv11/libmfx/include/msdk/include/mfxenc.h

@@ -1,32 +1,22 @@
-/******************************************************************************* *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxenc.h
-
-*******************************************************************************/
+// Copyright (c) 2017-2019 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 #ifndef __MFXENC_H__
 #define __MFXENC_H__
 #include "mfxdefs.h"
@@ -37,8 +27,8 @@ extern "C"
 {
 #endif /* __cplusplus */
 
-typedef struct _mfxENCInput mfxENCInput;
-struct _mfxENCInput{
+MFX_PACK_BEGIN_STRUCT_W_PTR()
+MFX_DEPRECATED typedef struct _mfxENCInput{
     mfxU32  reserved[32];
 
     mfxFrameSurface1 *InSurface;
@@ -50,28 +40,30 @@ struct _mfxENCInput{
 
     mfxU16  NumExtParam;
     mfxExtBuffer    **ExtParam;
-} ;
+} mfxENCInput;
+MFX_PACK_END()
 
-typedef struct _mfxENCOutput mfxENCOutput;
-struct _mfxENCOutput{
+MFX_PACK_BEGIN_STRUCT_W_PTR()
+MFX_DEPRECATED typedef struct _mfxENCOutput{
     mfxU32  reserved[32];
 
     mfxFrameSurface1 *OutSurface;
 
     mfxU16  NumExtParam;
     mfxExtBuffer    **ExtParam;
-} ;
+} mfxENCOutput;
+MFX_PACK_END()
 
 
-mfxStatus MFX_CDECL MFXVideoENC_Query(mfxSession session, mfxVideoParam *in, mfxVideoParam *out);
-mfxStatus MFX_CDECL MFXVideoENC_QueryIOSurf(mfxSession session, mfxVideoParam *par, mfxFrameAllocRequest *request);
-mfxStatus MFX_CDECL MFXVideoENC_Init(mfxSession session, mfxVideoParam *par);
-mfxStatus MFX_CDECL MFXVideoENC_Reset(mfxSession session, mfxVideoParam *par);
-mfxStatus MFX_CDECL MFXVideoENC_Close(mfxSession session);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoENC_Query(mfxSession session, mfxVideoParam *in, mfxVideoParam *out);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoENC_QueryIOSurf(mfxSession session, mfxVideoParam *par, mfxFrameAllocRequest *request);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoENC_Init(mfxSession session, mfxVideoParam *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoENC_Reset(mfxSession session, mfxVideoParam *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoENC_Close(mfxSession session);
 
-mfxStatus MFX_CDECL MFXVideoENC_ProcessFrameAsync(mfxSession session, mfxENCInput *in, mfxENCOutput *out, mfxSyncPoint *syncp);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoENC_ProcessFrameAsync(mfxSession session, mfxENCInput *in, mfxENCOutput *out, mfxSyncPoint *syncp);
 
-mfxStatus MFX_CDECL MFXVideoENC_GetVideoParam(mfxSession session, mfxVideoParam *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoENC_GetVideoParam(mfxSession session, mfxVideoParam *par);
 
 #ifdef __cplusplus
 } // extern "C"

+ 23 - 29
plugins/obs-qsv11/libmfx/include/msdk/include/mfxjpeg.h

@@ -1,32 +1,22 @@
-/******************************************************************************* *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxjpeg.h
-
-*******************************************************************************/
+// Copyright (c) 2017-2019 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 #ifndef __MFX_JPEG_H__
 #define __MFX_JPEG_H__
 
@@ -77,6 +67,7 @@ enum {
     MFX_CHROMAFORMAT_JPEG_SAMPLING = 6
 };
 
+MFX_PACK_BEGIN_USUAL_STRUCT()
 typedef struct {
     mfxExtBuffer    Header;
 
@@ -85,7 +76,9 @@ typedef struct {
 
     mfxU16    Qm[4][64];
 } mfxExtJPEGQuantTables;
+MFX_PACK_END()
 
+MFX_PACK_BEGIN_USUAL_STRUCT()
 typedef struct {
     mfxExtBuffer    Header;
 
@@ -103,6 +96,7 @@ typedef struct {
         mfxU8   Values[162];
     } ACTables[4];
 } mfxExtJPEGHuffmanTables;
+MFX_PACK_END()
 
 #ifdef __cplusplus
 } // extern "C"

+ 27 - 30
plugins/obs-qsv11/libmfx/include/msdk/include/mfxmvc.h

@@ -1,32 +1,22 @@
-/******************************************************************************* *\
-
-Copyright (C) 2010-2013 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxmvc.h
-
-*******************************************************************************/
+// Copyright (c) 2017-2019 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 #ifndef __MFXMVC_H__
 #define __MFXMVC_H__
 
@@ -49,6 +39,7 @@ enum {
     MFX_EXTBUFF_MVC_TARGET_VIEWS    =   MFX_MAKEFOURCC('M','V','C','T')
 };
 
+MFX_PACK_BEGIN_USUAL_STRUCT()
 typedef struct  {
     mfxU16 ViewId;
 
@@ -62,7 +53,9 @@ typedef struct  {
     mfxU16 NonAnchorRefL0[16];
     mfxU16 NonAnchorRefL1[16];
 } mfxMVCViewDependency;
+MFX_PACK_END()
 
+MFX_PACK_BEGIN_STRUCT_W_PTR()
 typedef struct {
     mfxU16 TemporalId;
     mfxU16 LevelIdc;
@@ -71,7 +64,9 @@ typedef struct {
     mfxU16 NumTargetViews;
     mfxU16 *TargetViewId;
 } mfxMVCOperationPoint;
+MFX_PACK_END()
 
+MFX_PACK_BEGIN_STRUCT_W_PTR()
 typedef struct  {
     mfxExtBuffer Header;
 
@@ -91,7 +86,9 @@ typedef struct  {
     mfxU32 Reserved[16];
 
 } mfxExtMVCSeqDesc;
+MFX_PACK_END()
 
+MFX_PACK_BEGIN_USUAL_STRUCT()
 typedef struct {
     mfxExtBuffer    Header;
 
@@ -99,7 +96,7 @@ typedef struct {
     mfxU32 NumView;
     mfxU16 ViewId[1024];
 } mfxExtMVCTargetViews ;
-
+MFX_PACK_END()
 
 #ifdef __cplusplus
 } // extern "C"

+ 32 - 38
plugins/obs-qsv11/libmfx/include/msdk/include/mfxpak.h

@@ -1,32 +1,22 @@
-/******************************************************************************* *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxpak.h
-
-*******************************************************************************/
+// Copyright (c) 2017-2019 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 #ifndef __MFXPAK_H__
 #define __MFXPAK_H__
 #include "mfxdefs.h"
@@ -37,7 +27,8 @@ extern "C"
 {
 #endif /* __cplusplus */
 
-typedef struct {
+MFX_PACK_BEGIN_STRUCT_W_PTR()
+MFX_DEPRECATED typedef struct {
     mfxU16 reserved[32];
 
     mfxFrameSurface1 *InSurface;
@@ -53,8 +44,10 @@ typedef struct {
     mfxU16 NumPayload;
     mfxPayload      **Payload;
 } mfxPAKInput;
+MFX_PACK_END()
 
-typedef struct {
+MFX_PACK_BEGIN_STRUCT_W_PTR()
+MFX_DEPRECATED typedef struct {
     mfxU16  reserved[32];
 
     mfxBitstream     *Bs;
@@ -64,17 +57,18 @@ typedef struct {
     mfxU16            NumExtParam;
     mfxExtBuffer    **ExtParam;
 } mfxPAKOutput;
+MFX_PACK_END()
 
 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[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);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoPAK_Query(mfxSession session, mfxVideoParam *in, mfxVideoParam *out);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoPAK_QueryIOSurf(mfxSession session, mfxVideoParam *par, mfxFrameAllocRequest request[2]);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoPAK_Init(mfxSession session, mfxVideoParam *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoPAK_Reset(mfxSession session, mfxVideoParam *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoPAK_Close(mfxSession session);
 
-mfxStatus MFX_CDECL MFXVideoPAK_ProcessFrameAsync(mfxSession session, mfxPAKInput *in, mfxPAKOutput *out,  mfxSyncPoint *syncp);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoPAK_ProcessFrameAsync(mfxSession session, mfxPAKInput *in, mfxPAKOutput *out,  mfxSyncPoint *syncp);
 
-mfxStatus MFX_CDECL MFXVideoPAK_GetVideoParam(mfxSession session, mfxVideoParam *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoPAK_GetVideoParam(mfxSession session, mfxVideoParam *par);
 
 #ifdef __cplusplus
 } // extern "C"

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

@@ -1,33 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-File Name: mfxplugin++.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2017-2020 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #ifndef __MFXPLUGINPLUSPLUS_H
 #define __MFXPLUGINPLUSPLUS_H
@@ -41,7 +30,7 @@ public:
     explicit MFXBaseUSER(mfxSession session = NULL)
         : m_session(session){}
 
-    virtual ~MFXBaseUSER() {};
+    virtual ~MFXBaseUSER() {}
 
     virtual mfxStatus Register(mfxU32 type, const mfxPlugin *par) = 0;
     virtual mfxStatus Unregister(mfxU32 type) = 0;
@@ -574,15 +563,11 @@ namespace detail
     private:
         void SetupCallbacks() {
             m_codecPlg.DecodeHeader = _DecodeHeader;
-//            m_codecPlg.GetPayload = _GetPayload;
             m_codecPlg.DecodeFrameSubmit = _DecodeFrameSubmit;
         }
         static mfxStatus _DecodeHeader(mfxHDL pthis, mfxBitstream *bs, mfxAudioParam *par) {
             return reinterpret_cast<MFXAudioDecoderPlugin*>(pthis)->DecodeHeader(bs, par);
         }
-//        static mfxStatus _GetPayload(mfxHDL pthis, mfxU64 *ts, mfxPayload *payload) {
-  //          return reinterpret_cast<MFXAudioDecoderPlugin*>(pthis)->GetPayload(ts, payload);
-    //    }
         static mfxStatus _DecodeFrameSubmit(mfxHDL pthis, mfxBitstream *in, mfxAudioFrame *out, mfxThreadTask *task) {
             return reinterpret_cast<MFXAudioDecoderPlugin*>(pthis)->DecodeFrameSubmit(in, out, task);
         }

+ 94 - 78
plugins/obs-qsv11/libmfx/include/msdk/include/mfxplugin.h

@@ -1,32 +1,22 @@
-/******************************************************************************* *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxplugin.h
-
-*******************************************************************************/
+// Copyright (c) 2018-2019 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 #ifndef __MFXPLUGIN_H__
 #define __MFXPLUGIN_H__
 #include "mfxvideo.h"
@@ -37,46 +27,62 @@ extern "C"
 {
 #endif /* __cplusplus */
 
+MFX_PACK_BEGIN_USUAL_STRUCT()
 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_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}};
+MFX_PACK_END()
+
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_HEVCD_SW        = {{0x15, 0xdd, 0x93, 0x68, 0x25, 0xad, 0x47, 0x5e, 0xa3, 0x4e, 0x35, 0xf3, 0xf5, 0x42, 0x17, 0xa6}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_HEVCD_HW        = {{0x33, 0xa6, 0x1c, 0x0b, 0x4c, 0x27, 0x45, 0x4c, 0xa8, 0xd8, 0x5d, 0xde, 0x75, 0x7c, 0x6f, 0x8e}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_HEVCE_SW        = {{0x2f, 0xca, 0x99, 0x74, 0x9f, 0xdb, 0x49, 0xae, 0xb1, 0x21, 0xa5, 0xb6, 0x3e, 0xf5, 0x68, 0xf7}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_HEVCE_GACC      = {{0xe5, 0x40, 0x0a, 0x06, 0xc7, 0x4d, 0x41, 0xf5, 0xb1, 0x2d, 0x43, 0x0b, 0xba, 0xa2, 0x3d, 0x0b}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_HEVCE_DP_GACC   = {{0x2b, 0xad, 0x6f, 0x9d, 0x77, 0x54, 0x41, 0x2d, 0xbf, 0x63, 0x03, 0xed, 0x4b, 0xb5, 0x09, 0x68}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_HEVCE_HW        = {{0x6f, 0xad, 0xc7, 0x91, 0xa0, 0xc2, 0xeb, 0x47, 0x9a, 0xb6, 0xdc, 0xd5, 0xea, 0x9d, 0xa3, 0x47}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_VP8D_HW         = {{0xf6, 0x22, 0x39, 0x4d, 0x8d, 0x87, 0x45, 0x2f, 0x87, 0x8c, 0x51, 0xf2, 0xfc, 0x9b, 0x41, 0x31}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_VP8E_HW         = {{0xbf, 0xfc, 0x51, 0x8c, 0xde, 0x13, 0x4d, 0xf9, 0x8a, 0x96, 0xf4, 0xcf, 0x81, 0x6c, 0x0f, 0xac}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_VP9E_HW         = {{0xce, 0x44, 0xef, 0x6f, 0x1a, 0x6d, 0x22, 0x46, 0xb4, 0x12, 0xbb, 0x38, 0xd6, 0xe4, 0x51, 0x82}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_VP9D_HW         = {{0xa9, 0x22, 0x39, 0x4d, 0x8d, 0x87, 0x45, 0x2f, 0x87, 0x8c, 0x51, 0xf2, 0xfc, 0x9b, 0x41, 0x31}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_CAMERA_HW       = {{0x54, 0x54, 0x26, 0x16, 0x24, 0x33, 0x41, 0xe6, 0x93, 0xae, 0x89, 0x99, 0x42, 0xce, 0x73, 0x55}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_CAPTURE_HW      = {{0x22, 0xd6, 0x2c, 0x07, 0xe6, 0x72, 0x40, 0x8f, 0xbb, 0x4c, 0xc2, 0x0e, 0xd7, 0xa0, 0x53, 0xe4}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_ITELECINE_HW    = {{0xe7, 0x44, 0x75, 0x3a, 0xcd, 0x74, 0x40, 0x2e, 0x89, 0xa2, 0xee, 0x06, 0x35, 0x49, 0x61, 0x79}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_H264LA_HW       = {{0x58, 0x8f, 0x11, 0x85, 0xd4, 0x7b, 0x42, 0x96, 0x8d, 0xea, 0x37, 0x7b, 0xb5, 0xd0, 0xdc, 0xb4}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_AACD            = {{0xe9, 0x34, 0x67, 0x25, 0xac, 0x2f, 0x4c, 0x93, 0xaa, 0x58, 0x5c, 0x11, 0xc7, 0x08, 0x7c, 0xf4}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_AACE            = {{0xb2, 0xa2, 0xa0, 0x5a, 0x4e, 0xac, 0x46, 0xbf, 0xa9, 0xde, 0x7e, 0x80, 0xc9, 0x8d, 0x2e, 0x18}};
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_HEVCE_FEI_HW    = {{0x87, 0xe0, 0xe8, 0x02, 0x07, 0x37, 0x52, 0x40, 0x85, 0x25, 0x15, 0xcf, 0x4a, 0x5e, 0xdd, 0xe6}};
+#if (MFX_VERSION >= 1027)
+MFX_DEPRECATED static const mfxPluginUID  MFX_PLUGINID_HEVC_FEI_ENCODE = {{0x54, 0x18, 0xa7, 0x06, 0x66, 0xf9, 0x4d, 0x5c, 0xb4, 0xf7, 0xb1, 0xca, 0xee, 0x86, 0x33, 0x9b}};
+#endif
 
 
 typedef enum {
-    MFX_PLUGINTYPE_VIDEO_GENERAL   = 0,
-    MFX_PLUGINTYPE_VIDEO_DECODE    = 1,
-    MFX_PLUGINTYPE_VIDEO_ENCODE    = 2,
-    MFX_PLUGINTYPE_VIDEO_VPP       = 3,
-    MFX_PLUGINTYPE_VIDEO_ENC       = 4,
-    MFX_PLUGINTYPE_AUDIO_DECODE    = 5,
-    MFX_PLUGINTYPE_AUDIO_ENCODE    = 6
+    MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLUGINTYPE_VIDEO_GENERAL)   = 0,
+    MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLUGINTYPE_VIDEO_DECODE)    = 1,
+    MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLUGINTYPE_VIDEO_ENCODE)    = 2,
+    MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLUGINTYPE_VIDEO_VPP)       = 3,
+    MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLUGINTYPE_VIDEO_ENC)       = 4,
+    MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLUGINTYPE_AUDIO_DECODE)    = 5,
+    MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_PLUGINTYPE_AUDIO_ENCODE)    = 6
 } mfxPluginType;
 
+MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(MFX_PLUGINTYPE_VIDEO_GENERAL);
+MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(MFX_PLUGINTYPE_VIDEO_DECODE);
+MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(MFX_PLUGINTYPE_VIDEO_ENCODE);
+MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(MFX_PLUGINTYPE_VIDEO_VPP);
+MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(MFX_PLUGINTYPE_VIDEO_ENC);
+MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(MFX_PLUGINTYPE_AUDIO_DECODE);
+MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(MFX_PLUGINTYPE_AUDIO_ENCODE);
+
 typedef enum {
-    MFX_THREADPOLICY_SERIAL    = 0,
-    MFX_THREADPOLICY_PARALLEL  = 1
+    MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_THREADPOLICY_SERIAL)    = 0,
+    MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_THREADPOLICY_PARALLEL)  = 1
 } mfxThreadPolicy;
 
-typedef struct mfxPluginParam {
+MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(MFX_THREADPOLICY_SERIAL);
+MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(MFX_THREADPOLICY_PARALLEL);
+
+MFX_PACK_BEGIN_USUAL_STRUCT()
+MFX_DEPRECATED typedef struct mfxPluginParam {
     mfxU32          reserved[6];
     mfxU16          reserved1;
     mfxU16          PluginVersion;
@@ -87,15 +93,19 @@ typedef struct mfxPluginParam {
     mfxThreadPolicy ThreadPolicy;
     mfxU32          MaxThreadNum;
 } mfxPluginParam;
+MFX_PACK_END()
 
-typedef struct mfxCoreParam{
+MFX_PACK_BEGIN_USUAL_STRUCT()
+MFX_DEPRECATED typedef struct mfxCoreParam{
     mfxU32     reserved[13];
     mfxIMPL    Impl;
     mfxVersion Version;
     mfxU32     NumWorkingThread;
 } mfxCoreParam;
+MFX_PACK_END()
 
-typedef struct mfxCoreInterface {
+MFX_PACK_BEGIN_STRUCT_W_PTR()
+MFX_DEPRECATED typedef struct mfxCoreInterface {
     mfxHDL pthis;
 
     mfxHDL reserved1[2];
@@ -121,11 +131,13 @@ typedef struct mfxCoreInterface {
 
     mfxHDL reserved4[1];
 } mfxCoreInterface;
+MFX_PACK_END()
 
+MFX_PACK_BEGIN_STRUCT_W_PTR()
 /* video codec plugin extension */
-typedef struct _mfxENCInput mfxENCInput;
-typedef struct _mfxENCOutput mfxENCOutput;
-typedef struct mfxVideoCodecPlugin{
+MFX_DEPRECATED typedef struct _mfxENCInput mfxENCInput;
+MFX_DEPRECATED typedef struct _mfxENCOutput mfxENCOutput;
+MFX_DEPRECATED 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 *Init)(mfxHDL pthis, mfxVideoParam *par);
@@ -147,8 +159,10 @@ typedef struct mfxVideoCodecPlugin{
     mfxHDL reserved1[3];
     mfxU32 reserved2[8];
 } mfxVideoCodecPlugin;
+MFX_PACK_END()
 
-typedef struct mfxAudioCodecPlugin{
+MFX_PACK_BEGIN_STRUCT_W_PTR()
+MFX_DEPRECATED 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 *Init)(mfxHDL pthis, mfxAudioParam *par);
@@ -165,8 +179,10 @@ typedef struct mfxAudioCodecPlugin{
     mfxHDL reserved1[6];
     mfxU32 reserved2[8];
 } mfxAudioCodecPlugin;
+MFX_PACK_END()
 
-typedef struct mfxPlugin{
+MFX_PACK_BEGIN_STRUCT_W_PTR()
+MFX_DEPRECATED typedef struct mfxPlugin{
     mfxHDL pthis;
 
     mfxStatus (MFX_CDECL *PluginInit) (mfxHDL pthis, mfxCoreInterface *core);
@@ -185,24 +201,24 @@ typedef struct mfxPlugin{
 
     mfxHDL reserved[8];
 } mfxPlugin;
+MFX_PACK_END()
 
 
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoUSER_Register(mfxSession session, mfxU32 type, const mfxPlugin *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoUSER_Unregister(mfxSession session, mfxU32 type);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoUSER_GetPlugin(mfxSession session, mfxU32 type, mfxPlugin *par);
+MFX_DEPRECATED 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_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);
-mfxStatus MFX_CDECL MFXVideoUSER_LoadByPath(mfxSession session, const mfxPluginUID *uid, mfxU32 version, const mfxChar *path, mfxU32 len);
-mfxStatus MFX_CDECL MFXVideoUSER_UnLoad(mfxSession session, const mfxPluginUID *uid);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32 version);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoUSER_LoadByPath(mfxSession session, const mfxPluginUID *uid, mfxU32 version, const mfxChar *path, mfxU32 len);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoUSER_UnLoad(mfxSession session, const mfxPluginUID *uid);
 
-mfxStatus MFX_CDECL MFXAudioUSER_Register(mfxSession session, mfxU32 type, const mfxPlugin *par);
-mfxStatus MFX_CDECL MFXAudioUSER_Unregister(mfxSession session, mfxU32 type);
-mfxStatus MFX_CDECL MFXAudioUSER_ProcessFrameAsync(mfxSession session, const mfxHDL *in, mfxU32 in_num, const mfxHDL *out, mfxU32 out_num, mfxSyncPoint *syncp);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioUSER_Register(mfxSession session, mfxU32 type, const mfxPlugin *par);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioUSER_Unregister(mfxSession session, mfxU32 type);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioUSER_ProcessFrameAsync(mfxSession session, const mfxHDL *in, mfxU32 in_num, const mfxHDL *out, mfxU32 out_num, mfxSyncPoint *syncp);
 
-mfxStatus MFX_CDECL MFXAudioUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32 version);
-mfxStatus MFX_CDECL MFXAudioUSER_UnLoad(mfxSession session, const mfxPluginUID *uid);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32 version);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXAudioUSER_UnLoad(mfxSession session, const mfxPluginUID *uid);
 
 #ifdef __cplusplus
 } // extern "C"

+ 20 - 30
plugins/obs-qsv11/libmfx/include/msdk/include/mfxsession.h

@@ -1,32 +1,22 @@
-/*******************************************************************************
-
-Copyright (C) 2013 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxsession.h
-
-*******************************************************************************/
+// Copyright (c) 2017 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 #ifndef __MFXSESSION_H__
 #define __MFXSESSION_H__
 #include "mfxcommon.h"
@@ -50,7 +40,7 @@ mfxStatus MFX_CDECL MFXDisjoinSession(mfxSession session);
 mfxStatus MFX_CDECL MFXCloneSession(mfxSession session, mfxSession *clone);
 mfxStatus MFX_CDECL MFXSetPriority(mfxSession session, mfxPriority priority);
 mfxStatus MFX_CDECL MFXGetPriority(mfxSession session, mfxPriority *priority);
-mfxStatus MFX_CDECL MFXDoWork(mfxSession session);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXDoWork(mfxSession session);
 
 #ifdef __cplusplus
 }

Разница между файлами не показана из-за своего большого размера
+ 313 - 49
plugins/obs-qsv11/libmfx/include/msdk/include/mfxstructures.h


+ 20 - 31
plugins/obs-qsv11/libmfx/include/msdk/include/mfxvideo++.h

@@ -1,33 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-File Name: mfxvideo++.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2017 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #ifndef __MFXVIDEOPLUSPLUS_H
 #define __MFXVIDEOPLUSPLUS_H
@@ -60,7 +49,7 @@ public:
     virtual mfxStatus SetPriority( mfxPriority priority) { return MFXSetPriority(m_session, priority);}
     virtual mfxStatus GetPriority( mfxPriority *priority) { return MFXGetPriority(m_session, priority);}
 
-    virtual mfxStatus SetBufferAllocator(mfxBufferAllocator *allocator) { return MFXVideoCORE_SetBufferAllocator(m_session, allocator); }
+    MFX_DEPRECATED virtual mfxStatus SetBufferAllocator(mfxBufferAllocator *allocator) { return MFXVideoCORE_SetBufferAllocator(m_session, allocator); }
     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); }

+ 25 - 31
plugins/obs-qsv11/libmfx/include/msdk/include/mfxvideo.h

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxvideo.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2017-2019 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 #ifndef __MFXVIDEO_H__
 #define __MFXVIDEO_H__
 #include "mfxsession.h"
@@ -38,6 +28,7 @@ extern "C"
 #endif
 
 /* MFXVideoCORE */
+MFX_PACK_BEGIN_STRUCT_W_PTR()
 typedef struct {
     mfxU32      reserved[4];
     mfxHDL      pthis;
@@ -46,7 +37,9 @@ typedef struct {
     mfxStatus  (MFX_CDECL *Unlock)   (mfxHDL pthis, mfxMemId mid);
     mfxStatus  (MFX_CDECL *Free)     (mfxHDL pthis, mfxMemId mid);
 } mfxBufferAllocator;
+MFX_PACK_END()
 
+MFX_PACK_BEGIN_STRUCT_W_PTR()
 typedef struct {
     mfxU32      reserved[4];
     mfxHDL      pthis;
@@ -57,9 +50,10 @@ typedef struct {
     mfxStatus  (MFX_CDECL  *GetHDL)   (mfxHDL pthis, mfxMemId mid, mfxHDL *handle);
     mfxStatus  (MFX_CDECL  *Free)     (mfxHDL pthis, mfxFrameAllocResponse *response);
 } mfxFrameAllocator;
+MFX_PACK_END()
 
 /* VideoCORE */
-mfxStatus MFX_CDECL MFXVideoCORE_SetBufferAllocator(mfxSession session, mfxBufferAllocator *allocator);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoCORE_SetBufferAllocator(mfxSession session, mfxBufferAllocator *allocator);
 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);
@@ -101,7 +95,7 @@ mfxStatus MFX_CDECL MFXVideoVPP_Close(mfxSession session);
 mfxStatus MFX_CDECL MFXVideoVPP_GetVideoParam(mfxSession session, mfxVideoParam *par);
 mfxStatus MFX_CDECL MFXVideoVPP_GetVPPStat(mfxSession session, mfxVPPStat *stat);
 mfxStatus MFX_CDECL MFXVideoVPP_RunFrameVPPAsync(mfxSession session, mfxFrameSurface1 *in, mfxFrameSurface1 *out, mfxExtVppAuxData *aux, mfxSyncPoint *syncp);
-mfxStatus MFX_CDECL MFXVideoVPP_RunFrameVPPAsyncEx(mfxSession session, mfxFrameSurface1 *in, mfxFrameSurface1 *surface_work, mfxFrameSurface1 **surface_out, mfxSyncPoint *syncp);
+MFX_DEPRECATED mfxStatus MFX_CDECL MFXVideoVPP_RunFrameVPPAsyncEx(mfxSession session, mfxFrameSurface1 *in, mfxFrameSurface1 *surface_work, mfxFrameSurface1 **surface_out, mfxSyncPoint *syncp);
 
 #ifdef __cplusplus
 } // extern "C"

+ 19 - 29
plugins/obs-qsv11/libmfx/include/msdk/include/mfxvstructures.h

@@ -1,32 +1,22 @@
-/*******************************************************************************
-
-Copyright (C) 2013 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfxvstructures.h
-
-*******************************************************************************/
+// Copyright (c) 2017 Intel Corporation
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 #include "mfxstructures.h"
 
 

+ 249 - 137
plugins/obs-qsv11/libmfx/src/main.cpp

@@ -1,32 +1,25 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: main.cpp
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2020 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include <windows.h>
+#include <stringapiset.h>
 
 #include <new>
 #include <memory>
@@ -37,6 +30,10 @@ File Name: main.cpp
 #include "mfx_library_iterator.h"
 #include "mfx_critical_section.h"
 
+#if defined(MEDIASDK_UWP_DISPATCHER)
+#include "mfx_dispatcher_uwp.h"
+#endif
+
 #include <string.h> /* for memset on Linux */
 
 #include <stdlib.h> /* for qsort on Linux */
@@ -70,6 +67,13 @@ namespace
         {MFX_LIB_HARDWARE, MFX_IMPL_HARDWARE4, 3},
         {MFX_LIB_SOFTWARE, MFX_IMPL_SOFTWARE,  0},
         {MFX_LIB_SOFTWARE, MFX_IMPL_SOFTWARE | MFX_IMPL_AUDIO,  0},
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+        //MFX_SINGLE_THREAD case
+        {MFX_LIB_HARDWARE, MFX_IMPL_HARDWARE | MFX_IMPL_EXTERNAL_THREADING, 0},
+        {MFX_LIB_HARDWARE, MFX_IMPL_HARDWARE2 | MFX_IMPL_EXTERNAL_THREADING, 1},
+        {MFX_LIB_HARDWARE, MFX_IMPL_HARDWARE3 | MFX_IMPL_EXTERNAL_THREADING, 2},
+        {MFX_LIB_HARDWARE, MFX_IMPL_HARDWARE4 | MFX_IMPL_EXTERNAL_THREADING, 3},
+#endif
     };
 
     const
@@ -91,7 +95,9 @@ namespace
         {4, 4},  // MFX_IMPL_HARDWARE3
         {5, 5},  // MFX_IMPL_HARDWARE4
         {2, 6},  // MFX_IMPL_RUNTIME, same as MFX_IMPL_HARDWARE_ANY
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
         {8, 11},  // MFX_SINGLE_THREAD,
+#endif
         {7, 7}   // MFX_IMPL_AUDIO
     };
 
@@ -101,34 +107,7 @@ 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)
+#if !defined(MEDIASDK_UWP_DISPATCHER)
 
 //
 // Implement DLL exposed functions. MFXInit and MFXClose have to do
@@ -136,7 +115,7 @@ extern "C" {
 // All other functions are implemented implicitly.
 //
 
-typedef MFXVector<MFX_DISP_HANDLE*> HandleVector;
+typedef MFXVector<MFX_DISP_HANDLE_EX*> HandleVector;
 typedef MFXVector<mfxStatus>        StatusVector;
 
 struct VectorHandleGuard
@@ -158,11 +137,32 @@ private:
 };
 
 
-int HandleSort (const void * plhs, const void * prhs)
+static 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;
+    const MFX_DISP_HANDLE_EX * lhs = *(const MFX_DISP_HANDLE_EX **)plhs;
+    const MFX_DISP_HANDLE_EX * rhs = *(const MFX_DISP_HANDLE_EX **)prhs;
 
+    // prefer HW implementation
+    if (lhs->implType != MFX_LIB_HARDWARE && rhs->implType == MFX_LIB_HARDWARE)
+    {
+        return 1;
+    }
+    if (lhs->implType == MFX_LIB_HARDWARE && rhs->implType != MFX_LIB_HARDWARE)
+    {
+        return -1;
+    }
+
+    // prefer integrated GPU
+    if (lhs->mediaAdapterType != MFX_MEDIA_INTEGRATED && rhs->mediaAdapterType == MFX_MEDIA_INTEGRATED)
+    {
+        return 1;
+    }
+    if (lhs->mediaAdapterType == MFX_MEDIA_INTEGRATED && rhs->mediaAdapterType != MFX_MEDIA_INTEGRATED)
+    {
+        return -1;
+    }
+
+    // prefer dll with lower API version
     if (lhs->actualApiVersion < rhs->actualApiVersion)
     {
         return -1;
@@ -185,9 +185,6 @@ int HandleSort (const void * plhs, const void * prhs)
     return 0;
 }
 
-// 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)
 {
     MFX::MFXAutomaticCriticalSection guard(&dispGuard);
@@ -199,24 +196,26 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
         , par.ExternalThreads
         , session));
 
-    mfxStatus mfxRes;
+    mfxStatus mfxRes = MFX_ERR_UNSUPPORTED;
     HandleVector allocatedHandle;
     VectorHandleGuard handleGuard(allocatedHandle);
 
-    MFX_DISP_HANDLE *pHandle;
-    msdk_disp_char dllName[MFX_MAX_DLL_PATH] = { 0 };
+    MFX_DISP_HANDLE_EX *pHandle;
+    wchar_t 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
-    mfxIMPL curImpl;
     // implementation method masked from the input parameter
     // special case for audio library
     const mfxIMPL implMethod = (par.Implementation & MFX_IMPL_AUDIO) ? (sizeof(implTypesRange) / sizeof(implTypesRange[0]) - 1) : (par.Implementation & (MFX_IMPL_VIA_ANY - 1));
 
     // implementation interface masked from the input parameter
     mfxIMPL implInterface = par.Implementation & -MFX_IMPL_VIA_ANY;
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+    bool isSingleThread = (implInterface & MFX_IMPL_EXTERNAL_THREADING) > 0;
+    implInterface &= ~MFX_IMPL_EXTERNAL_THREADING;
+#endif
     mfxIMPL implInterfaceOrig = implInterface;
     mfxVersion requiredVersion = {{MFX_VERSION_MINOR, MFX_VERSION_MAJOR}};
 
@@ -225,7 +224,12 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
     {
         return MFX_ERR_NULL_PTR;
     }
+
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+    if (((MFX_IMPL_AUTO > implMethod) || (MFX_IMPL_SINGLE_THREAD < implMethod)) && !(par.Implementation & MFX_IMPL_AUDIO))
+#else
     if (((MFX_IMPL_AUTO > implMethod) || (MFX_IMPL_RUNTIME < implMethod)) && !(par.Implementation & MFX_IMPL_AUDIO))
+#endif
     {
         return MFX_ERR_UNSUPPORTED;
     }
@@ -239,7 +243,7 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
         *session = 0;
 
         // allocate the dispatching handle and call-table
-        pHandle = new MFX_DISP_HANDLE(requiredVersion);
+        pHandle = new MFX_DISP_HANDLE_EX(requiredVersion);
     }
     catch(...)
     {
@@ -247,16 +251,30 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
     }
 
     DISPATCHER_LOG_INFO((("Required API version is %u.%u\n"), requiredVersion.Major, requiredVersion.Minor));
+    // particular implementation value
+    mfxIMPL curImpl;
 
     // Load HW library or RT from system location
     curImplIdx = implTypesRange[implMethod].minIndex;
     maxImplIdx = implTypesRange[implMethod].maxIndex;
     do
     {
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+        if (isSingleThread && implTypes[curImplIdx].implType != MFX_LIB_HARDWARE)
+            continue;
+#endif
+
         int currentStorage = MFX::MFX_STORAGE_ID_FIRST;
         implInterface = implInterfaceOrig;
         do
         {
+            // this storage will be checked below
+            if (currentStorage == MFX::MFX_APP_FOLDER)
+            {
+                currentStorage += 1;
+                continue;
+            }
+
             // initialize the library iterator
             mfxRes = libIterator.Init(implTypes[curImplIdx].implType,
                 implInterface,
@@ -289,22 +307,39 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
                     {
                         break;
                     }
-                    DISPATCHER_LOG_INFO((("loading library %S\n"), MSDK2WIDE(dllName)));
+                    DISPATCHER_LOG_INFO((("loading library %S\n"), dllName));
                     // try to load the selected DLL
                     curImpl = implTypes[curImplIdx].impl;
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+                    if (isSingleThread)
+                        curImpl |= MFX_IMPL_EXTERNAL_THREADING;
+#endif
                     mfxRes = pHandle->LoadSelectedDLL(dllName, implType, curImpl, implInterface, par);
                     // unload the failed DLL
                     if (MFX_ERR_NONE != mfxRes)
                     {
                         pHandle->Close();
+                        continue;
                     }
-                    else
+
+                    mfxPlatform platform = { MFX_PLATFORM_UNKNOWN, 0, MFX_MEDIA_UNKNOWN };
+                    if (pHandle->callTable[eMFXVideoCORE_QueryPlatform])
                     {
-                        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);
+                        mfxRes = MFXVideoCORE_QueryPlatform((mfxSession)pHandle, &platform);
+                        if (MFX_ERR_NONE != mfxRes)
+                        {
+                            DISPATCHER_LOG_WRN(("MFXVideoCORE_QueryPlatform failed, rejecting loaded library\n"));
+                            pHandle->Close();
+                            continue;
+                        }
                     }
+                    pHandle->mediaAdapterType = platform.MediaAdapterType;
+                    DISPATCHER_LOG_INFO((("media adapter type is %d\n"), pHandle->mediaAdapterType));
+
+                    libIterator.GetSubKeyName(pHandle->subkeyName, sizeof(pHandle->subkeyName) / sizeof(pHandle->subkeyName[0]));
+                    pHandle->storageID = libIterator.GetStorageID();
+                    allocatedHandle.push_back(pHandle);
+                    pHandle = new MFX_DISP_HANDLE_EX(requiredVersion);
 
                 } while (MFX_ERR_NONE != mfxRes);
             }
@@ -314,18 +349,19 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
 
         } while ((MFX_ERR_NONE != mfxRes) && (MFX::MFX_STORAGE_ID_LAST >= currentStorage));
 
-    } while ((MFX_ERR_NONE != mfxRes) && (++curImplIdx <= maxImplIdx));
-
+    } while (++curImplIdx <= maxImplIdx);
 
     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
     {
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+        if (isSingleThread && implTypes[curImplIdx].implType != MFX_LIB_HARDWARE)
+            continue;
+#endif
+
         implInterface = implInterfaceOrig;
         // initialize the library iterator
         mfxRes = libIterator.Init(implTypes[curImplIdx].implType,
@@ -357,10 +393,14 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
                 {
                     break;
                 }
-                DISPATCHER_LOG_INFO((("loading library %S\n"), MSDK2WIDE(dllName)));
+                DISPATCHER_LOG_INFO((("loading library %S\n"), dllName));
 
                 // try to load the selected DLL
                 curImpl = implTypes[curImplIdx].impl;
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+                if (isSingleThread)
+                    curImpl |= MFX_IMPL_EXTERNAL_THREADING;
+#endif
                 mfxRes = pHandle->LoadSelectedDLL(dllName, implType, curImpl, implInterface, par);
                 // unload the failed DLL
                 if (MFX_ERR_NONE != mfxRes)
@@ -377,20 +417,23 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
                     }
                     pHandle->storageID = MFX::MFX_UNKNOWN_KEY;
                     allocatedHandle.push_back(pHandle);
-                    pHandle = new MFX_DISP_HANDLE(requiredVersion);
+                    pHandle = new MFX_DISP_HANDLE_EX(requiredVersion);
                 }
 
             } while (MFX_ERR_NONE != mfxRes);
         }
     } 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
     {
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+        if (isSingleThread && implTypes[curImplIdx].implType != MFX_LIB_HARDWARE)
+            continue;
+#endif
+
         implInterface = implInterfaceOrig;
 
         if (par.Implementation & MFX_IMPL_AUDIO)
@@ -408,7 +451,7 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
 
         if (MFX_ERR_NONE == mfxRes)
         {
-            DISPATCHER_LOG_INFO((("loading default library %S\n"), MSDK2WIDE(dllName)))
+            DISPATCHER_LOG_INFO((("loading default library %S\n"), dllName))
 
                 // try to load the selected DLL using default DLL search mechanism
                 if (MFX_LIB_HARDWARE == implTypes[curImplIdx].implType)
@@ -424,10 +467,15 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
                 }
                 if (MFX_ERR_NONE == mfxRes)
                 {
+                    curImpl = implTypes[curImplIdx].impl;
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+                    if (isSingleThread)
+                        curImpl |= MFX_IMPL_EXTERNAL_THREADING;
+#endif
                     // try to load the selected DLL using default DLL search mechanism
                     mfxRes = pHandle->LoadSelectedDLL(dllName,
                         implTypes[curImplIdx].implType,
-                        implTypes[curImplIdx].impl,
+                        curImpl,
                         implInterface,
                         par);
                 }
@@ -441,7 +489,7 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
                 {
                     pHandle->storageID = MFX::MFX_UNKNOWN_KEY;
                     allocatedHandle.push_back(pHandle);
-                    pHandle = new MFX_DISP_HANDLE(requiredVersion);
+                    pHandle = new MFX_DISP_HANDLE_EX(requiredVersion);
                 }
         }
     }
@@ -460,9 +508,9 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
             if (HandleSort(&(*first), &(*it)) != 0)
                 NeedSort = true;
 
-        // select dll with version with lowest version number still greater or equal to requested
+        // sort allocatedHandle so that the most preferred dll is at the beginning
         if (NeedSort)
-            qsort(&(*allocatedHandle.begin()), allocatedHandle.size(), sizeof(MFX_DISP_HANDLE*), &HandleSort);
+            qsort(&(*allocatedHandle.begin()), allocatedHandle.size(), sizeof(MFX_DISP_HANDLE_EX*), &HandleSort);
     }
     HandleVector::iterator candidate = allocatedHandle.begin();
     // check the final result of loading
@@ -470,7 +518,7 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
     {
         pHandle = *candidate;
         //pulling up current mediasdk version, that required to match plugin version
-        mfxVersion apiVerActual = { 0 };
+        mfxVersion apiVerActual = { { 0, 0 } };
         mfxStatus stsQueryVersion = MFXQueryVersion((mfxSession)pHandle, &apiVerActual);
 
         if (MFX_ERR_NONE !=  stsQueryVersion)
@@ -504,14 +552,11 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
                 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;
@@ -526,7 +571,41 @@ mfxStatus MFXInitEx(mfxInitParam par, mfxSession *session)
 
     // everything is OK. Save pointers to the output variable
     *candidate = 0; // keep this one safe from guard destructor
-    *((MFX_DISP_HANDLE **) session) = pHandle;
+
+
+    //===================================
+
+    // MFXVideoCORE_QueryPlatform call creates d3d device handle, so we have handle right after MFXInit and can't accept external handle
+    // This is a workaround which calls close-init to remove that handle
+
+    mfxFunctionPointer *actualTable = (pHandle->impl & MFX_IMPL_AUDIO) ? pHandle->callAudioTable : pHandle->callTable;
+    mfxFunctionPointer pFunc;
+
+    pFunc = actualTable[eMFXClose];
+    mfxRes = (*(mfxStatus(MFX_CDECL *) (mfxSession)) pFunc) (pHandle->session);
+    if (mfxRes != MFX_ERR_NONE)
+        return mfxRes;
+
+    pHandle->session = 0;
+    bool callOldInit = (pHandle->impl & MFX_IMPL_AUDIO) || !actualTable[eMFXInitEx];
+    pFunc = actualTable[(callOldInit) ? eMFXInit : eMFXInitEx];
+
+    mfxVersion version(pHandle->apiVersion);
+    if (callOldInit)
+    {
+        pHandle->loadStatus = (*(mfxStatus(MFX_CDECL *) (mfxIMPL, mfxVersion *, mfxSession *)) pFunc) (pHandle->impl | pHandle->implInterface, &version, &pHandle->session);
+    }
+    else
+    {
+        mfxInitParam initPar = par;
+        initPar.Implementation = pHandle->impl | pHandle->implInterface;
+        initPar.Version = version;
+        pHandle->loadStatus = (*(mfxStatus(MFX_CDECL *) (mfxInitParam, mfxSession *)) pFunc) (initPar, &pHandle->session);
+    }
+
+    //===================================
+
+    *((MFX_DISP_HANDLE_EX **) session) = pHandle;
 
     return pHandle->loadStatus;
 
@@ -569,12 +648,12 @@ mfxStatus MFXVideoUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32
 {
     mfxStatus sts = MFX_ERR_NONE;
     bool ErrFlag = false;
-    MFX_DISP_HANDLE &pHandle = *(MFX_DISP_HANDLE *) session;
-    if (!&pHandle)
+    if (!session)
     {
         DISPATCHER_LOG_ERROR((("MFXVideoUSER_Load: session=NULL\n")));
         return MFX_ERR_NULL_PTR;
     }
+    MFX_DISP_HANDLE &pHandle = *(MFX_DISP_HANDLE *) session;
     if (!uid)
     {
         DISPATCHER_LOG_ERROR((("MFXVideoUSER_Load: uid=NULL\n")));
@@ -649,12 +728,12 @@ mfxStatus MFXVideoUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32
 
 mfxStatus MFXVideoUSER_LoadByPath(mfxSession session, const mfxPluginUID *uid, mfxU32 version, const mfxChar *path, mfxU32 len)
 {
-    MFX_DISP_HANDLE &pHandle = *(MFX_DISP_HANDLE *) session;
-    if (!&pHandle)
+    if (!session)
     {
         DISPATCHER_LOG_ERROR((("MFXVideoUSER_LoadByPath: session=NULL\n")));
         return MFX_ERR_NULL_PTR;
     }
+    MFX_DISP_HANDLE &pHandle = *(MFX_DISP_HANDLE *) session;
     if (!uid)
     {
         DISPATCHER_LOG_ERROR((("MFXVideoUSER_LoadByPath: uid=NULL\n")));
@@ -662,27 +741,24 @@ mfxStatus MFXVideoUSER_LoadByPath(mfxSession session, const mfxPluginUID *uid, m
     }
 
     DISPATCHER_LOG_INFO((("MFXVideoUSER_LoadByPath: %S uid=" MFXGUIDTYPE()" version=%d\n")
-        , MSDK2WIDE(path)
+        , path
         , MFXGUIDTOHEX(uid)
         , version))
 
     PluginDescriptionRecord record;
     record.sName[0] = 0;
 
-#ifdef _WIN32
-    msdk_disp_char 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;
+    wchar_t wPath[MAX_PLUGIN_PATH];
+    int res = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path, len, wPath, MAX_PLUGIN_PATH-1);
 
     if (!res)
     {
-        DISPATCHER_LOG_ERROR((("MFXVideoUSER_LoadByPath: cant convert UTF-8 path to UTF-16\n")));
+        DISPATCHER_LOG_ERROR((("MFXVideoUSER_LoadByPath: can't convert UTF-8 path to UTF-16\n")));
         return MFX_ERR_NOT_FOUND;
     }
-    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
+    wPath[res]=0;
+
+    wcscpy_s(record.sPath, MAX_PLUGIN_PATH, wPath);
 
     record.PluginUID = *uid;
     record.PluginVersion = (mfxU16)version;
@@ -701,12 +777,12 @@ 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 (!session)
     {
         DISPATCHER_LOG_ERROR((("MFXVideoUSER_UnLoad: session=NULL\n")));
         return MFX_ERR_NULL_PTR;
     }
+    MFX_DISP_HANDLE &rHandle = *(MFX_DISP_HANDLE *) session;
     if (!uid)
     {
         DISPATCHER_LOG_ERROR((("MFXVideoUSER_UnLoad: uid=NULL\n")));
@@ -727,12 +803,12 @@ mfxStatus MFXVideoUSER_UnLoad(mfxSession session, const mfxPluginUID *uid)
 
 mfxStatus MFXAudioUSER_Load(mfxSession session, const mfxPluginUID *uid, mfxU32 version)
 {
-    MFX_DISP_HANDLE &pHandle = *(MFX_DISP_HANDLE *) session;
-    if (!&pHandle)
+    if (!session)
     {
         DISPATCHER_LOG_ERROR((("MFXAudioUSER_Load: session=NULL\n")));
         return MFX_ERR_NULL_PTR;
     }
+    MFX_DISP_HANDLE &pHandle = *(MFX_DISP_HANDLE *) session;
     if (!uid)
     {
         DISPATCHER_LOG_ERROR((("MFXAudioUSER_Load: uid=NULL\n")));
@@ -789,12 +865,12 @@ 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 (!session)
     {
         DISPATCHER_LOG_ERROR((("MFXAudioUSER_UnLoad: session=NULL\n")));
         return MFX_ERR_NULL_PTR;
     }
+    MFX_DISP_HANDLE &rHandle = *(MFX_DISP_HANDLE *) session;
     if (!uid)
     {
         DISPATCHER_LOG_ERROR((("MFXAudioUSER_Load: uid=NULL\n")));
@@ -812,30 +888,74 @@ mfxStatus MFXAudioUSER_UnLoad(mfxSession session, const mfxPluginUID *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
+#else // relates to !defined (MEDIASDK_UWP_DISPATCHER), i.e. #else part as if MEDIASDK_UWP_DISPATCHER defined
 
-#include <windows.h>
-#include "intel_api_factory.h"
+static mfxModuleHandle hModule;
 
-// for the UWP_PROCTABLE purposes implementation of MFXinitEx is calling
-// InitializeInstance() implemented in intel_uwp-api.dll
+// for the UWP_DISPATCHER purposes implementation of MFXinitEx is calling
+// InitialiseMediaSession() implemented in intel_gfx_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;
+#if defined(MEDIASDK_ARM_LOADER)
+
+    return MFX_ERR_UNSUPPORTED;
+
+#else
+
+    wchar_t IntelGFXAPIdllName[MFX_MAX_DLL_PATH] = { 0 };
+    mfxI32 adapterNum = -1;
+
+    switch (par.Implementation & 0xf)
+    {
+    case MFX_IMPL_SOFTWARE:
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+    case MFX_IMPL_SINGLE_THREAD:
+#endif
+        return MFX_ERR_UNSUPPORTED;
+    case MFX_IMPL_AUTO:
+    case MFX_IMPL_HARDWARE:
+        adapterNum = 0;
+        break;
+    case MFX_IMPL_HARDWARE2:
+        adapterNum = 1;
+        break;
+    case MFX_IMPL_HARDWARE3:
+        adapterNum = 2;
+        break;
+    case MFX_IMPL_HARDWARE4:
+        adapterNum = 3;
+        break;
+    default:
+        return GfxApiInitPriorityIntegrated(par, session, hModule);
+    }
+
+    return GfxApiInitByAdapterNum(par, adapterNum, session, hModule);
+
+#endif
 }
 
-// for the UWP_PROCTABLE purposes implementation of MFXClose is calling
-// DisposeInstance() implemented in intel_uwp-api.dll
+// for the UWP_DISPATCHER purposes implementation of MFXClose is calling
+// DisposeMediaSession() implemented in intel_gfx_api.dll
 mfxStatus MFXClose(mfxSession session)
 {
-    if (nullptr == session) {
+    if (NULL == session) {
         return MFX_ERR_INVALID_HANDLE;
     }
 
-    HRESULT hr = DisposeMediaSession(HANDLE(session));
+    mfxStatus sts = MFX_ERR_NONE;
+
+#if defined(MEDIASDK_ARM_LOADER)
+
+    sts = MFX_ERR_UNSUPPORTED;
+
+#else
+
+    sts = GfxApiClose(session, hModule);
+
+#endif
+
     session = (mfxSession)NULL;
-    return (hr == S_OK) ? MFX_ERR_NONE : mfxStatus(hr);
+    return sts;
 }
 
 #undef FUNCTION
@@ -865,10 +985,7 @@ FUNCTION(mfxStatus, MFXVideoUSER_UnLoad, (mfxSession session, const mfxPluginUID
 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)
+#endif //!defined(MEDIASDK_UWP_DISPATCHER)
 
 mfxStatus MFXJoinSession(mfxSession session, mfxSession child_session)
 {
@@ -877,7 +994,7 @@ mfxStatus MFXJoinSession(mfxSession session, mfxSession child_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))
+    if ((pHandle) && (pChildHandle) && (pHandle->actualApiVersion == pChildHandle->actualApiVersion))
     {
         /* check whether it is audio session or video */
         int tableIndex = eMFXJoinSession;
@@ -936,8 +1053,6 @@ mfxStatus MFXCloneSession(mfxSession session, mfxSession *clone)
 
 } // mfxStatus MFXCloneSession(mfxSession session, mfxSession *clone)
 
-#endif // !defined(MEDIASDK_UWP_LOADER)
-
 mfxStatus MFXInit(mfxIMPL impl, mfxVersion *pVer, mfxSession *session)
 {
     mfxInitParam par = {};
@@ -998,7 +1113,6 @@ mfxStatus MFXInit(mfxIMPL impl, mfxVersion *pVer, mfxSession *session)
 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
 
@@ -1006,8 +1120,6 @@ 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 \

+ 19 - 33
plugins/obs-qsv11/libmfx/src/mfx_critical_section.cpp

@@ -1,37 +1,25 @@
-/* ****************************************************************************** *\
-
-Copyright (C) 2012-2013 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_critical_section.cpp
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #include "mfx_critical_section.h"
 
-#if defined(_WIN32) || defined(_WIN64)
-
 #include <windows.h>
 // SDK re-declares the following functions with different call declarator.
 // We don't need them. Just redefine them to nothing.
@@ -84,5 +72,3 @@ void mfxLeaveCriticalSection(mfxCriticalSection *pCSection)
 } // void mfxLeaveCriticalSection(mfxCriticalSection *pCSection)
 
 } // namespace MFX
-
-#endif // #if defined(_WIN32) || defined(_WIN64)

+ 369 - 55
plugins/obs-qsv11/libmfx/src/mfx_dispatcher.cpp

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_dispatcher.cpp
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2020 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #include "mfx_dispatcher.h"
 #include "mfx_dispatcher_log.h"
@@ -35,18 +25,20 @@ File Name: mfx_dispatcher.cpp
 #include <assert.h>
 
 #include <string.h>
-#if defined(_WIN32) || defined(_WIN64)
-    #include <windows.h>
-    #pragma warning(disable:4355)
-#else
-    #include <dlfcn.h>
-    #include <iostream>
-#endif // defined(_WIN32) || defined(_WIN64)
+#include <windows.h>
 
+#include "mfx_dxva2_device.h"
+#include "mfxvideo++.h"
+#include "mfx_vector.h"
+#include "mfxadapter.h"
+#include <algorithm>
+
+#pragma warning(disable:4355)
 
 MFX_DISP_HANDLE::MFX_DISP_HANDLE(const mfxVersion requiredVersion) :
     _mfxSession()
     ,apiVersion(requiredVersion)
+    ,pluginHive()
     ,pluginFactory((mfxSession)this)
 {
     actualApiVersion.Version = 0;
@@ -74,7 +66,7 @@ mfxStatus MFX_DISP_HANDLE::Close(void)
 
     mfxRes = UnLoadSelectedDLL();
 
-    // the library wasn't unloaded
+    // need to reset dispatcher state after unloading dll
     if (MFX_ERR_NONE == mfxRes)
     {
         implType = MFX_LIB_SOFTWARE;
@@ -90,7 +82,7 @@ mfxStatus MFX_DISP_HANDLE::Close(void)
 
 } // mfxStatus MFX_DISP_HANDLE::Close(void)
 
-mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImplType reqImplType,
+mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const wchar_t *pPath, eMfxImplType reqImplType,
                                            mfxIMPL reqImpl, mfxIMPL reqImplInterface, mfxInitParam &par)
 {
     mfxStatus mfxRes = MFX_ERR_NONE;
@@ -105,6 +97,9 @@ mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImpl
     }
     // only exact types of implementation is allowed
     if (!(reqImpl & MFX_IMPL_AUDIO) &&
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+        !(reqImpl & MFX_IMPL_EXTERNAL_THREADING) &&
+#endif
         (MFX_IMPL_SOFTWARE != reqImpl) &&
         (MFX_IMPL_HARDWARE != reqImpl) &&
         (MFX_IMPL_HARDWARE2 != reqImpl) &&
@@ -141,7 +136,7 @@ mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImpl
 
     {
         assert(hModule == (mfxModuleHandle)0);
-        DISPATCHER_LOG_BLOCK(("invoking LoadLibrary(%S)\n", MSDK2WIDE(pPath)));
+        DISPATCHER_LOG_BLOCK(("invoking LoadLibrary(%S)\n", pPath));
 
         // load the DLL into the memory
         hModule = MFX::mfx_dll_load(pPath);
@@ -151,9 +146,9 @@ mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImpl
             int i;
 
             DISPATCHER_LOG_OPERATION({
-                msdk_disp_char modulePath[1024];
+                wchar_t modulePath[1024];
                 GetModuleFileNameW((HMODULE)hModule, modulePath, sizeof(modulePath)/sizeof(modulePath[0]));
-                DISPATCHER_LOG_INFO((("loaded module %S\n"), MSDK2WIDE(modulePath)))
+                DISPATCHER_LOG_INFO((("loaded module %S\n"), modulePath))
             });
 
             if (impl & MFX_IMPL_AUDIO)
@@ -164,10 +159,6 @@ mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImpl
                     // construct correct name of the function - remove "_a" postfix
 
                     mfxFunctionPointer pProc = (mfxFunctionPointer) MFX::mfx_dll_get_addr(hModule, APIAudioFunc[i].pName);
-    #ifdef ANDROID
-                    // on Android very first call to dlsym may fail
-                    if (!pProc) pProc = (mfxFunctionPointer) MFX::mfx_dll_get_addr(hModule, APIAudioFunc[i].pName);
-    #endif
                     if (pProc)
                     {
                         // function exists in the library,
@@ -193,10 +184,6 @@ mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImpl
                 for (i = 0; i < eVideoFuncTotal; i += 1)
                 {
                     mfxFunctionPointer pProc = (mfxFunctionPointer) MFX::mfx_dll_get_addr(hModule, APIFunc[i].pName);
-    #ifdef ANDROID
-                    // on Android very first call to dlsym may fail
-                    if (!pProc) pProc = (mfxFunctionPointer) MFX::mfx_dll_get_addr(hModule, APIFunc[i].pName);
-    #endif
                     if (pProc)
                     {
                         // function exists in the library,
@@ -219,11 +206,7 @@ mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImpl
         }
         else
         {
-#if defined(_WIN32) || defined(_WIN64)
             DISPATCHER_LOG_WRN((("can't find DLL: GetLastErr()=0x%x\n"), GetLastError()))
-#else
-            DISPATCHER_LOG_WRN((("can't find DLL: dlerror() = \"%s\"\n"), dlerror()));
-#endif
             mfxRes = MFX_ERR_UNSUPPORTED;
         }
     }
@@ -295,7 +278,7 @@ mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImpl
     loadStatus = mfxRes;
     return mfxRes;
 
-} // mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImplType implType, mfxIMPL impl)
+} // mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const wchar_t *pPath, eMfxImplType implType, mfxIMPL impl)
 
 mfxStatus MFX_DISP_HANDLE::UnLoadSelectedDLL(void)
 {
@@ -344,4 +327,335 @@ mfxStatus MFX_DISP_HANDLE::UnLoadSelectedDLL(void)
 
     return mfxRes;
 
-} // mfxStatus MFX_DISP_HANDLE::UnLoadSelectedDLL(void)
+} // mfxStatus MFX_DISP_HANDLE::UnLoadSelectedDLL(void)
+
+
+MFX_DISP_HANDLE_EX::MFX_DISP_HANDLE_EX(const mfxVersion requiredVersion)
+    : MFX_DISP_HANDLE(requiredVersion)
+    , mediaAdapterType(MFX_MEDIA_UNKNOWN)
+{}
+
+
+#if (defined(_WIN64) || defined(_WIN32)) && (MFX_VERSION >= 1031)
+static mfxStatus InitDummySession(mfxU32 adapter_n, MFXVideoSession & dummy_session)
+{
+    mfxInitParam initPar;
+    memset(&initPar, 0, sizeof(initPar));
+
+    initPar.Version.Major = 1;
+    initPar.Version.Minor = 0;
+
+    switch (adapter_n)
+    {
+    case 0:
+        initPar.Implementation = MFX_IMPL_HARDWARE;
+        break;
+    case 1:
+        initPar.Implementation = MFX_IMPL_HARDWARE2;
+        break;
+    case 2:
+        initPar.Implementation = MFX_IMPL_HARDWARE3;
+        break;
+    case 3:
+        initPar.Implementation = MFX_IMPL_HARDWARE4;
+        break;
+
+    default:
+        // try searching on all display adapters
+        initPar.Implementation = MFX_IMPL_HARDWARE_ANY;
+        break;
+    }
+
+    initPar.Implementation |= MFX_IMPL_VIA_D3D11;
+
+    return dummy_session.InitEx(initPar);
+}
+
+static inline bool is_iGPU(const mfxAdapterInfo& adapter_info)
+{
+    return adapter_info.Platform.MediaAdapterType == MFX_MEDIA_INTEGRATED;
+}
+
+static inline bool is_dGPU(const mfxAdapterInfo& adapter_info)
+{
+    return adapter_info.Platform.MediaAdapterType == MFX_MEDIA_DISCRETE;
+}
+
+// This function implies that iGPU has higher priority
+static inline mfxI32 iGPU_priority(const void* ll, const void* rr)
+{
+    const mfxAdapterInfo& l = *(reinterpret_cast<const mfxAdapterInfo*>(ll));
+    const mfxAdapterInfo& r = *(reinterpret_cast<const mfxAdapterInfo*>(rr));
+
+    if (is_iGPU(l) && is_iGPU(r) || is_dGPU(l) && is_dGPU(r))
+        return 0;
+
+    if (is_iGPU(l) && is_dGPU(r))
+        return -1;
+
+    // The only combination left is_dGPU(l) && is_iGPU(r))
+    return 1;
+}
+
+
+static void RearrangeInPriorityOrder(const mfxComponentInfo & info, MFX::MFXVector<mfxAdapterInfo> & vec)
+{
+	(void)info;
+    {
+        // Move iGPU to top priority
+        qsort(vec.data(), vec.size(), sizeof(mfxAdapterInfo), &iGPU_priority);
+    }
+}
+
+static mfxStatus PrepareAdaptersInfo(const mfxComponentInfo * info, MFX::MFXVector<mfxAdapterInfo> & vec, mfxAdaptersInfo& adapters)
+{
+    // No suitable adapters on system to handle user's workload
+    if (vec.empty())
+    {
+        adapters.NumActual = 0;
+        return MFX_ERR_NOT_FOUND;
+    }
+
+    if (info)
+    {
+        RearrangeInPriorityOrder(*info, vec);
+    }
+
+    mfxU32 num_to_copy = (std::min)(mfxU32(vec.size()), adapters.NumAlloc);
+    for (mfxU32 i = 0; i < num_to_copy; ++i)
+    {
+        adapters.Adapters[i] = vec[i];
+    }
+
+    adapters.NumActual = num_to_copy;
+
+    if (vec.size() > adapters.NumAlloc)
+    {
+        return MFX_WRN_OUT_OF_RANGE;
+    }
+
+    return MFX_ERR_NONE;
+}
+
+static inline bool QueryAdapterInfo(mfxU32 adapter_n, mfxU32& VendorID, mfxU32& DeviceID)
+{
+    MFX::DXVA2Device dxvaDevice;
+
+    if (!dxvaDevice.InitDXGI1(adapter_n))
+        return false;
+
+    VendorID = dxvaDevice.GetVendorID();
+    DeviceID = dxvaDevice.GetDeviceID();
+
+    return true;
+}
+
+static inline mfxU32 MakeVersion(mfxU16 major, mfxU16 minor)
+{
+    return major * 1000 + minor;
+}
+
+mfxStatus MFXQueryAdaptersDecode(mfxBitstream* bitstream, mfxU32 codec_id, mfxAdaptersInfo* adapters)
+{
+    if (!adapters || !bitstream)
+        return MFX_ERR_NULL_PTR;
+
+    MFX::MFXVector<mfxAdapterInfo> obtained_info;
+
+    mfxU32 adapter_n = 0, VendorID, DeviceID;
+
+    mfxComponentInfo input_info;
+    memset(&input_info, 0, sizeof(input_info));
+    input_info.Type                     = mfxComponentType::MFX_COMPONENT_DECODE;
+    input_info.Requirements.mfx.CodecId = codec_id;
+
+    for(;;)
+    {
+        if (!QueryAdapterInfo(adapter_n, VendorID, DeviceID))
+            break;
+
+        ++adapter_n;
+
+        if (VendorID != INTEL_VENDOR_ID)
+            continue;
+
+        // Check if requested capabilities are supported
+        MFXVideoSession dummy_session;
+
+        mfxStatus sts = InitDummySession(adapter_n - 1, dummy_session);
+        if (sts != MFX_ERR_NONE)
+        {
+            continue;
+        }
+
+        mfxVideoParam stream_params, out;
+        memset(&out, 0, sizeof(out));
+        memset(&stream_params, 0, sizeof(stream_params));
+        out.mfx.CodecId = stream_params.mfx.CodecId = codec_id;
+
+        sts = MFXVideoDECODE_DecodeHeader(dummy_session.operator mfxSession(), bitstream, &stream_params);
+
+        if (sts != MFX_ERR_NONE)
+        {
+            continue;
+        }
+
+        sts = MFXVideoDECODE_Query(dummy_session.operator mfxSession(), &stream_params, &out);
+
+        if (sts != MFX_ERR_NONE) // skip MFX_ERR_UNSUPPORTED as well as MFX_WRN_INCOMPATIBLE_VIDEO_PARAM
+            continue;
+
+        mfxAdapterInfo info;
+        memset(&info, 0, sizeof(info));
+
+        //WA for initialization when application built w/ new API, but lib w/ old one.
+        mfxVersion apiVersion;
+        sts = dummy_session.QueryVersion(&apiVersion);
+        if (sts != MFX_ERR_NONE)
+            continue;
+
+        mfxU32 version = MakeVersion(apiVersion.Major, apiVersion.Minor);
+
+        if (version >= 1019)
+        {
+            sts = MFXVideoCORE_QueryPlatform(dummy_session.operator mfxSession(), &info.Platform);
+
+            if (sts != MFX_ERR_NONE)
+            {
+                continue;
+            }
+        }
+        else
+        {
+            // for API versions greater than 1.19 Device id is set inside QueryPlatform call
+            info.Platform.DeviceId = static_cast<mfxU16>(DeviceID);
+        }
+
+        info.Number = adapter_n - 1;
+
+        obtained_info.push_back(info);
+    }
+
+    return PrepareAdaptersInfo(&input_info, obtained_info, *adapters);
+}
+
+mfxStatus MFXQueryAdapters(mfxComponentInfo* input_info, mfxAdaptersInfo* adapters)
+{
+    if (!adapters)
+        return MFX_ERR_NULL_PTR;
+
+    MFX::MFXVector<mfxAdapterInfo> obtained_info;
+    //obtained_info.reserve(adapters->NumAdaptersAlloc);
+
+    mfxU32 adapter_n = 0, VendorID, DeviceID;
+
+    for (;;)
+    {
+        if (!QueryAdapterInfo(adapter_n, VendorID, DeviceID))
+            break;
+
+        ++adapter_n;
+
+        if (VendorID != INTEL_VENDOR_ID)
+            continue;
+
+        // Check if requested capabilities are supported
+        MFXVideoSession dummy_session;
+
+        mfxStatus sts = InitDummySession(adapter_n - 1, dummy_session);
+        if (sts != MFX_ERR_NONE)
+        {
+            continue;
+        }
+
+        // If input_info is NULL just return all Intel adapters and information about them
+        if (input_info)
+        {
+            mfxVideoParam out;
+            memset(&out, 0, sizeof(out));
+
+            switch (input_info->Type)
+            {
+            case mfxComponentType::MFX_COMPONENT_ENCODE:
+                {
+                    out.mfx.CodecId = input_info->Requirements.mfx.CodecId;
+
+                    sts = MFXVideoENCODE_Query(dummy_session.operator mfxSession(), &input_info->Requirements, &out);
+                }
+                break;
+            case mfxComponentType::MFX_COMPONENT_DECODE:
+                {
+                    out.mfx.CodecId = input_info->Requirements.mfx.CodecId;
+
+                    sts = MFXVideoDECODE_Query(dummy_session.operator mfxSession(), &input_info->Requirements, &out);
+                }
+                break;
+            case mfxComponentType::MFX_COMPONENT_VPP:
+                {
+                    sts = MFXVideoVPP_Query(dummy_session.operator mfxSession(), &input_info->Requirements, &out);
+                }
+                break;
+            default:
+                sts = MFX_ERR_UNSUPPORTED;
+            }
+        }
+
+        if (sts != MFX_ERR_NONE) // skip MFX_ERR_UNSUPPORTED as well as MFX_WRN_INCOMPATIBLE_VIDEO_PARAM
+            continue;
+
+        mfxAdapterInfo info;
+        memset(&info, 0, sizeof(info));
+
+        //WA for initialization when application built w/ new API, but lib w/ old one.
+        mfxVersion apiVersion;
+        sts = dummy_session.QueryVersion(&apiVersion);
+        if (sts != MFX_ERR_NONE)
+            continue;
+
+        mfxU32 version = MakeVersion(apiVersion.Major, apiVersion.Minor);
+
+        if (version >= 1019)
+        {
+            sts = MFXVideoCORE_QueryPlatform(dummy_session.operator mfxSession(), &info.Platform);
+
+            if (sts != MFX_ERR_NONE)
+            {
+                continue;
+            }
+        }
+        else
+        {
+            // for API versions greater than 1.19 Device id is set inside QueryPlatform call
+            info.Platform.DeviceId = static_cast<mfxU16>(DeviceID);
+        }
+
+        info.Number = adapter_n - 1;
+
+        obtained_info.push_back(info);
+    }
+
+    return PrepareAdaptersInfo(input_info, obtained_info, *adapters);
+}
+
+mfxStatus MFXQueryAdaptersNumber(mfxU32* num_adapters)
+{
+    if (!num_adapters)
+        return MFX_ERR_NULL_PTR;
+
+    mfxU32 intel_adapter_count = 0, VendorID, DeviceID;
+
+    for (mfxU32 cur_adapter = 0; ; ++cur_adapter)
+    {
+        if (!QueryAdapterInfo(cur_adapter, VendorID, DeviceID))
+            break;
+
+        if (VendorID == INTEL_VENDOR_ID)
+            ++intel_adapter_count;
+    }
+
+    *num_adapters = intel_adapter_count;
+
+    return MFX_ERR_NONE;
+}
+
+#endif // (defined(_WIN64) || defined(_WIN32)) && (MFX_VERSION >= 1031)

+ 19 - 31
plugins/obs-qsv11/libmfx/src/mfx_dispatcher_log.cpp

@@ -1,44 +1,32 @@
-/* ****************************************************************************** *\
-
-Copyright (C) 2012-2014 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_dispatcher_log.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #if defined(MFX_DISPATCHER_LOG)
 
 #include "mfx_dispatcher_log.h"
 #include "mfxstructures.h"
-#if defined(_WIN32) || defined(_WIN64)
 #include <windows.h>
 #if defined(DISPATCHER_LOG_REGISTER_EVENT_PROVIDER)
 #include <evntprov.h>
 #include <winmeta.h>
 #endif
-#endif // #if defined(_WIN32) || defined(_WIN64)
 #include <stdarg.h>
 #include <algorithm>
 #include <string>

+ 218 - 0
plugins/obs-qsv11/libmfx/src/mfx_driver_store_loader.cpp

@@ -0,0 +1,218 @@
+// Copyright (c) 2019-2020 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include <tchar.h>
+
+#include "mfx_driver_store_loader.h"
+#include "mfx_dispatcher_log.h"
+#include "mfx_load_dll.h"
+
+namespace MFX
+{
+
+
+inline bool IsIntelDeviceInstanceID(const wchar_t * DeviceID)
+{
+    return wcsstr(DeviceID, L"VEN_8086") || wcsstr(DeviceID, L"ven_8086");
+}
+
+inline bool ExctractDeviceID(const wchar_t* descrString, mfxU32& deviceID)
+{
+    const wchar_t *begin = wcsstr(descrString, L"DEV_");
+
+    if (!begin)
+    {
+        begin = wcsstr(descrString, L"dev_");
+        if (!begin)
+        {
+            DISPATCHER_LOG_WRN(("exctracting device id: failed to find device id substring\n"));
+            return false;
+        }
+    }
+
+    begin += wcslen(L"DEV_");
+    deviceID = wcstoul(begin, NULL, 16);
+    if (!deviceID)
+    {
+        DISPATCHER_LOG_WRN(("exctracting device id: failed to convert device id str to int\n"));
+        return false;
+    }
+
+    return true;
+}
+
+
+
+DriverStoreLoader::DriverStoreLoader(void)
+    : m_moduleCfgMgr(NULL)
+    , m_pCM_Get_Device_ID_List_Size(NULL)
+    , m_pCM_Get_Device_ID_List(NULL)
+    , m_pCM_Locate_DevNode(NULL)
+    , m_pCM_Open_DevNode_Key(NULL)
+{
+}
+
+DriverStoreLoader::~DriverStoreLoader(void)
+{
+}
+
+bool DriverStoreLoader::GetDriverStorePath(wchar_t * path, DWORD dwPathSize, mfxU32 deviceID)
+{
+    if (path == NULL || dwPathSize == 0)
+    {
+        return false;
+    }
+
+    // Obtain a PnP handle to the Intel graphics adapter
+    CONFIGRET    result = CR_SUCCESS;
+    ULONG        DeviceIDListSize = 0;
+    MFXVector<WCHAR> DeviceIDList;
+    wchar_t      DisplayGUID[40];
+    DEVINST      DeviceInst;
+
+    DISPATCHER_LOG_INFO(("Looking for MediaSDK in DriverStore\n"));
+
+    if (!LoadCfgMgr() || !LoadCmFuncs())
+    {
+        return false;
+    }
+
+    if (StringFromGUID2(GUID_DEVCLASS_DISPLAY, DisplayGUID, sizeof(DisplayGUID)) == 0)
+    {
+        DISPATCHER_LOG_WRN(("Couldn't prepare string from GUID\n"));
+        return false;
+    }
+
+    do
+    {
+        result = m_pCM_Get_Device_ID_List_Size(&DeviceIDListSize, DisplayGUID, CM_GETIDLIST_FILTER_CLASS | CM_GETIDLIST_FILTER_PRESENT);
+        if (result != CR_SUCCESS)
+        {
+            break;
+        }
+
+        try
+        {
+            DeviceIDList.resize(DeviceIDListSize);
+        }
+        catch (...)
+        {
+            return false;
+        }
+        result = m_pCM_Get_Device_ID_List(DisplayGUID, DeviceIDList.data(), DeviceIDListSize, CM_GETIDLIST_FILTER_CLASS | CM_GETIDLIST_FILTER_PRESENT);
+
+    } while (result == CR_BUFFER_SMALL);
+
+    if (result != CR_SUCCESS)
+    {
+        return false;
+    }
+
+    //Look for MediaSDK record
+    wchar_t *begin = DeviceIDList.data();
+    wchar_t *end = begin + DeviceIDList.size();
+    size_t len = 0;
+
+    for (; (begin < end) && (len = wcslen(begin)) > 0; begin += len + 1)
+    {
+        if (IsIntelDeviceInstanceID(begin))
+        {
+            mfxU32 curDeviceID = 0;
+            if (!ExctractDeviceID(begin, curDeviceID) || curDeviceID != deviceID)
+            {
+                continue;
+            }
+
+            result = m_pCM_Locate_DevNode(&DeviceInst, begin, CM_LOCATE_DEVNODE_NORMAL);
+            if (result != CR_SUCCESS)
+            {
+                continue;
+            }
+
+            HKEY hKey_sw;
+            result = m_pCM_Open_DevNode_Key(DeviceInst, KEY_READ, 0, RegDisposition_OpenExisting, &hKey_sw, CM_REGISTRY_SOFTWARE);
+            if (result != CR_SUCCESS)
+            {
+                continue;
+            }
+
+            ULONG nError;
+
+            DWORD pathSize = dwPathSize;
+
+            nError = RegQueryValueExW(hKey_sw, L"DriverStorePathForMediaSDK", 0, NULL, (LPBYTE)path, &pathSize);
+
+            RegCloseKey(hKey_sw);
+
+            if (ERROR_SUCCESS == nError)
+            {
+                if (path[wcslen(path) - 1] != '/' && path[wcslen(path) - 1] != '\\')
+                {
+                    wcscat_s(path, MFX_MAX_DLL_PATH, L"\\");
+                }
+                DISPATCHER_LOG_INFO(("DriverStore path is found\n"));
+                return true;
+            }
+        }
+    }
+
+    DISPATCHER_LOG_INFO(("DriverStore path isn't found\n"));
+    return false;
+
+} // bool DriverStoreLoader::GetDriverStorePath(wchar_t * path, DWORD dwPathSize)
+
+bool DriverStoreLoader::LoadCfgMgr()
+{
+    if (!m_moduleCfgMgr)
+    {
+        m_moduleCfgMgr = mfx_dll_load(L"cfgmgr32.dll");
+
+        if (!m_moduleCfgMgr)
+        {
+            DISPATCHER_LOG_WRN(("cfgmgr32.dll couldn't be loaded\n"));
+            return false;
+        }
+    }
+
+    return true;
+
+} // bool DriverStoreLoader::LoadCfgMgr()
+
+bool DriverStoreLoader::LoadCmFuncs()
+{
+    if (!m_pCM_Get_Device_ID_List || !m_pCM_Get_Device_ID_List_Size || !m_pCM_Locate_DevNode || !m_pCM_Open_DevNode_Key)
+    {
+        m_pCM_Get_Device_ID_List      = (Func_CM_Get_Device_ID_ListW)      mfx_dll_get_addr((HMODULE)m_moduleCfgMgr, "CM_Get_Device_ID_ListW");
+        m_pCM_Get_Device_ID_List_Size = (Func_CM_Get_Device_ID_List_SizeW) mfx_dll_get_addr((HMODULE)m_moduleCfgMgr, "CM_Get_Device_ID_List_SizeW");
+        m_pCM_Locate_DevNode          = (Func_CM_Locate_DevNodeW)          mfx_dll_get_addr((HMODULE)m_moduleCfgMgr, "CM_Locate_DevNodeW");
+        m_pCM_Open_DevNode_Key        = (Func_CM_Open_DevNode_Key)         mfx_dll_get_addr((HMODULE)m_moduleCfgMgr, "CM_Open_DevNode_Key");
+
+        if (!m_pCM_Get_Device_ID_List || !m_pCM_Get_Device_ID_List_Size || !m_pCM_Locate_DevNode || !m_pCM_Open_DevNode_Key)
+        {
+            DISPATCHER_LOG_WRN(("One of cfgmgr32.dll function isn't found\n"));
+            return false;
+        }
+    }
+
+    return true;
+
+} // bool DriverStoreLoader::LoadCmFuncs()
+
+} // namespace MFX

+ 88 - 97
plugins/obs-qsv11/libmfx/src/mfx_dxva2_device.cpp

@@ -1,34 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_dxva2_device.cpp
-
-\* ****************************************************************************** */
-
-#if defined(_WIN32) || defined(_WIN64)
+// Copyright (c) 2012-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #define INITGUID
 #include <d3d9.h>
@@ -107,27 +95,27 @@ void DXDevice::LoadDLLModule(const wchar_t *pModuleName)
     // unload the module if it is required
     UnloadDLLModule();
 
-#if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+#if !defined(MEDIASDK_UWP_DISPATCHER)
     DWORD prevErrorMode = 0;
     // set the silent error mode
-#if (_WIN32_WINNT >= 0x0600) && !(__GNUC__)
+#if (_WIN32_WINNT >= 0x0600)
     SetThreadErrorMode(SEM_FAILCRITICALERRORS, &prevErrorMode); 
 #else
     prevErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
 #endif
-#endif // !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+#endif // !defined(MEDIASDK_UWP_DISPATCHER)
 
     // load specified library
     m_hModule = LoadLibraryExW(pModuleName, NULL, 0);
 
-#if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+#if !defined(MEDIASDK_UWP_DISPATCHER)
     // set the previous error mode
-#if (_WIN32_WINNT >= 0x0600) && !(__GNUC__)
+#if (_WIN32_WINNT >= 0x0600)
     SetThreadErrorMode(prevErrorMode, NULL);
 #else
     SetErrorMode(prevErrorMode);
 #endif
-#endif //!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+#endif // !defined(MEDIASDK_UWP_DISPATCHER)
 
 } // void LoadDLLModule(const wchar_t *pModuleName)
 
@@ -325,6 +313,15 @@ bool DXGI1Device::Init(const mfxU32 adapterNum)
     // release the object before initialization
     Close();
 
+    IDXGIFactory1 *pFactory = NULL;
+    IDXGIAdapter1 *pAdapter = NULL;
+    DXGI_ADAPTER_DESC1 desc = { 0 };
+    mfxU32 curAdapter = 0;
+    mfxU32 maxAdapters = 0;
+    HRESULT hRes = E_FAIL;
+
+    DXGICreateFactoryFunc pFunc = NULL;
+
     // load up the library if it is not loaded
     if (NULL == m_hModule)
     {
@@ -333,81 +330,74 @@ bool DXGI1Device::Init(const mfxU32 adapterNum)
 
     if (m_hModule)
     {
-        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");
+        pFunc = (DXGICreateFactoryFunc)GetProcAddress(m_hModule, "CreateDXGIFactory1");
+    }
 
-        if (NULL == pFunc)
-        {
-            return false;
-        }
+    if (NULL == pFunc)
+    {
+        return false;
+    }
 
-        // create the factory
+    // create the factory
 #if _MSC_VER >= 1400
-        hRes = pFunc(__uuidof(IDXGIFactory1), (void**) (&pFactory));
+    hRes = pFunc(__uuidof(IDXGIFactory1), (void**)(&pFactory));
 #else
-        hRes = pFunc(IID_IDXGIFactory1, (void**) (&pFactory));
+    hRes = pFunc(IID_IDXGIFactory1, (void**)(&pFactory));
 #endif
+
+    if (FAILED(hRes))
+    {
+        return false;
+    }
+    m_pDXGIFactory1 = pFactory;
+
+    // get the number of adapters
+    curAdapter = 0;
+    maxAdapters = 0;
+    do
+    {
+        // get the required adapted
+        hRes = pFactory->EnumAdapters1(curAdapter, &pAdapter);
         if (FAILED(hRes))
         {
-            return false;
+            break;
         }
-        m_pDXGIFactory1 = pFactory;
-
-        // get the number of adapters
-        curAdapter = 0;
-        maxAdapters = 0;
-        do
-        {
-            // get the required adapted
-            hRes = pFactory->EnumAdapters1(curAdapter, &pAdapter);
-            if (FAILED(hRes))
-            {
-                break;
-            }
 
-            // if it is the required adapter, save the interface
-            if (curAdapter == adapterNum)
-            {
-                m_pDXGIAdapter1 = pAdapter;
-            }
-            else
-            {
-                pAdapter->Release();
-            }
-
-            // get the next adapter
-            curAdapter += 1;
-
-        } while (SUCCEEDED(hRes));
-        maxAdapters = curAdapter;
-
-        // there is no required adapter
-        if (adapterNum >= maxAdapters)
+        // if it is the required adapter, save the interface
+        if (curAdapter == adapterNum)
         {
-            return false;
+            m_pDXGIAdapter1 = pAdapter;
         }
-        pAdapter = (IDXGIAdapter1 *) m_pDXGIAdapter1;
-
-        // get the adapter's parameters
-        hRes = pAdapter->GetDesc1(&desc);
-        if (FAILED(hRes))
+        else
         {
-            return false;
+            pAdapter->Release();
         }
 
-        // save the parameters
-        m_vendorID = desc.VendorId;
-        m_deviceID = desc.DeviceId;
-        *((LUID *) &m_luid) = desc.AdapterLuid;
+        // get the next adapter
+        curAdapter += 1;
+
+    } while (SUCCEEDED(hRes));
+    maxAdapters = curAdapter;
+
+    // there is no required adapter
+    if (adapterNum >= maxAdapters)
+    {
+        return false;
     }
+    pAdapter = (IDXGIAdapter1 *) m_pDXGIAdapter1;
+
+    // get the adapter's parameters
+    hRes = pAdapter->GetDesc1(&desc);
+    if (FAILED(hRes))
+    {
+        return false;
+    }
+
+    // save the parameters
+    m_vendorID = desc.VendorId;
+    m_deviceID = desc.DeviceId;
+    *((LUID *) &m_luid) = desc.AdapterLuid;
 
     return true;
 
@@ -455,6 +445,7 @@ bool DXVA2Device::InitD3D9(const mfxU32 adapterNum)
         return false;
     }
 
+
     m_numAdapters = d3d9Device.GetAdapterCount();
 
     // check if the application is under Remote Desktop
@@ -574,4 +565,4 @@ mfxU32 DXVA2Device::GetAdapterCount(void) const
     return m_numAdapters;
 
 } // mfxU32 DXVA2Device::GetAdapterCount(void) const
-#endif
+

+ 27 - 37
plugins/obs-qsv11/libmfx/src/mfx_function_table.cpp

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-Copyright (C) 2012-2014 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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_function_table.cpp
-
-\* ****************************************************************************** */
+// Copyright (c) 2012-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #include "mfx_dispatcher.h"
 
@@ -86,9 +76,9 @@ namespace
 mfxStatus pseudoMFXInit(mfxIMPL impl, mfxVersion *ver, mfxSession *session)
 {
     // touch unreferenced parameters
-    impl = impl;
-    ver = ver;
-    session = session;
+    (void) impl;
+    (void) ver;
+    (void) session;
 
     return MFX_ERR_UNKNOWN;
 
@@ -97,7 +87,7 @@ mfxStatus pseudoMFXInit(mfxIMPL impl, mfxVersion *ver, mfxSession *session)
 mfxStatus pseudoMFXClose(mfxSession session)
 {
     // touch unreferenced parameters
-    session = session;
+    (void) session;
 
     return MFX_ERR_UNKNOWN;
 
@@ -106,8 +96,8 @@ mfxStatus pseudoMFXClose(mfxSession session)
 mfxStatus pseudoMFXJoinSession(mfxSession session, mfxSession child_session)
 {
     // touch unreferenced parameters
-    session = session;
-    child_session = child_session;
+    (void) session;
+    (void) child_session;
 
     return MFX_ERR_UNKNOWN;
 
@@ -116,8 +106,8 @@ mfxStatus pseudoMFXJoinSession(mfxSession session, mfxSession child_session)
 mfxStatus pseudoMFXCloneSession(mfxSession session, mfxSession *clone)
 {
     // touch unreferenced parameters
-    session = session;
-    clone = clone;
+    (void) session;
+    (void) clone;
 
     return MFX_ERR_UNKNOWN;
 

+ 141 - 114
plugins/obs-qsv11/libmfx/src/mfx_library_iterator.cpp

@@ -1,34 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_library_iterator.cpp
-
-\* ****************************************************************************** */
-
-#if defined(_WIN32) || defined(_WIN64)
+// Copyright (c) 2012-2020 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #include "mfx_library_iterator.h"
 
@@ -41,8 +29,6 @@ File Name: mfx_library_iterator.cpp
 #include <tchar.h>
 #include <windows.h>
 
-#include <vector>
-
 namespace MFX
 {
 
@@ -74,7 +60,11 @@ mfxStatus SelectImplementationType(const mfxU32 adapterNum, mfxIMPL *pImplInterf
     {
         return MFX_ERR_NULL_PTR;
     }
+#if (MFX_VERSION >= MFX_VERSION_NEXT)
+    mfxIMPL impl_via = (*pImplInterface & ~MFX_IMPL_EXTERNAL_THREADING);
+#else
     mfxIMPL impl_via = *pImplInterface;
+#endif
 
     DXVA2Device dxvaDevice;
     if (MFX_IMPL_VIA_D3D9 == impl_via)
@@ -82,7 +72,7 @@ mfxStatus SelectImplementationType(const mfxU32 adapterNum, mfxIMPL *pImplInterf
         // try to create the Direct3D 9 device and find right adapter
         if (!dxvaDevice.InitD3D9(adapterNum))
         {
-            DISPATCHER_LOG_INFO((("dxvaDevice.InitD3D9(%d) Failed "), adapterNum ));
+            DISPATCHER_LOG_INFO((("dxvaDevice.InitD3D9(%d) Failed\n"), adapterNum ));
             return MFX_ERR_UNSUPPORTED;
         }
     }
@@ -91,7 +81,7 @@ mfxStatus SelectImplementationType(const mfxU32 adapterNum, mfxIMPL *pImplInterf
         // try to open DXGI 1.1 device to get hardware ID
         if (!dxvaDevice.InitDXGI1(adapterNum))
         {
-            DISPATCHER_LOG_INFO((("dxvaDevice.InitDXGI1(%d) Failed "), adapterNum ));
+            DISPATCHER_LOG_INFO((("dxvaDevice.InitDXGI1(%d) Failed\n"), adapterNum ));
             return MFX_ERR_UNSUPPORTED;
         }
     }
@@ -109,13 +99,13 @@ mfxStatus SelectImplementationType(const mfxU32 adapterNum, mfxIMPL *pImplInterf
         }
         else
         {
-            DISPATCHER_LOG_INFO((("Unsupported adapter %d "), adapterNum ));
+            DISPATCHER_LOG_INFO((("Unsupported adapter %d\n"), adapterNum ));
             return MFX_ERR_UNSUPPORTED;
         }
     }
     else
     {
-        DISPATCHER_LOG_ERROR((("Unknown implementation type %d "), *pImplInterface ));
+        DISPATCHER_LOG_ERROR((("Unknown implementation type %d\n"), *pImplInterface ));
         return MFX_ERR_UNSUPPORTED;
     }
 
@@ -130,6 +120,9 @@ mfxStatus SelectImplementationType(const mfxU32 adapterNum, mfxIMPL *pImplInterf
 }
 
 MFXLibraryIterator::MFXLibraryIterator(void)
+#if !defined(MEDIASDK_UWP_DISPATCHER)
+    : m_baseRegKey()
+#endif
 {
     m_implType = MFX_LIB_PSEUDO;
     m_implInterface = MFX_IMPL_UNSUPPORTED;
@@ -168,7 +161,7 @@ void MFXLibraryIterator::Release(void)
 
 DECLSPEC_NOINLINE HMODULE GetThisDllModuleHandle()
 {
-  HMODULE hDll = HMODULE(-1);
+  HMODULE hDll = NULL;
 
   GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
                       GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
@@ -176,8 +169,8 @@ DECLSPEC_NOINLINE HMODULE GetThisDllModuleHandle()
   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)
+// wchar_t* sImplPath must be allocated with size not less then msdk_disp_path_len
+bool GetImplPath(int storageID, wchar_t* sImplPath)
 {
     HMODULE hModule = NULL;
 
@@ -187,17 +180,13 @@ bool GetImplPath(int storageID, msdk_disp_char* sImplPath)
     case MFX_APP_FOLDER:
         hModule = 0;
         break;
-
-#if defined(MEDIASDK_UWP_LOADER) || defined(MEDIASDK_UWP_PROCTABLE)
     case MFX_PATH_MSDK_FOLDER:
         hModule = GetThisDllModuleHandle();
+        HMODULE exeModule = GetModuleHandleW(NULL);
+        //It should works only if Dispatcher is linked with Dynamic Linked Library
+        if (!hModule || !exeModule || hModule == exeModule)
+            return false;
         break;
-#endif
-
-    }
-
-    if(hModule == HMODULE(-1)) {
-        return false;
     }
 
     DWORD nSize = 0;
@@ -214,7 +203,7 @@ bool GetImplPath(int storageID, msdk_disp_char* sImplPath)
     // 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'\\');
+    wchar_t * dirSeparator = wcsrchr(sImplPath, L'\\');
     if (dirSeparator != NULL && dirSeparator < (sImplPath + msdk_disp_path_len))
     {
         *++dirSeparator = 0;
@@ -235,27 +224,57 @@ mfxStatus MFXLibraryIterator::Init(eMfxImplType implType, mfxIMPL implInterface,
     Release();
     m_StorageID = storageID;
     m_lastLibIndex = 0;
+    m_implType = implType;
+    m_implInterface = implInterface != 0
+        ? implInterface
+        : MFX_IMPL_VIA_ANY;
 
-#if defined(MEDIASDK_USE_REGISTRY) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
+    // for HW impl check impl interface, check adapter, obtain deviceID and vendorID
+    if (m_implType != MFX_LIB_SOFTWARE)
+    {
+        mfxStatus mfxRes = MFX::SelectImplementationType(adapterNum, &m_implInterface, &m_vendorID, &m_deviceID);
+        if (MFX_ERR_NONE != mfxRes)
+        {
+            return mfxRes;
+        }
+    }
+
+#if !defined(MEDIASDK_UWP_DISPATCHER)
     if (storageID == MFX_CURRENT_USER_KEY || storageID == MFX_LOCAL_MACHINE_KEY)
     {
-        return InitRegistry(implType, implInterface, adapterNum, storageID);
+        return InitRegistry(storageID);
+    }
+
+#if defined(MFX_TRACER_WA_FOR_DS)
+    if (storageID == MFX_TRACER)
+    {
+        return InitRegistryTracer();
     }
 #endif
 
-    msdk_disp_char  sCurrentModulePath[msdk_disp_path_len];
+#endif
+
+    wchar_t  sMediaSDKPath[msdk_disp_path_len] = {};
 
-    if(!GetImplPath(storageID, sCurrentModulePath)) {
+    if (storageID == MFX_DRIVER_STORE)
+    {
+        if (!m_driverStoreLoader.GetDriverStorePath(sMediaSDKPath, sizeof(sMediaSDKPath), m_deviceID))
+        {
+            return MFX_ERR_UNSUPPORTED;
+        }
+    }
+    else if(!GetImplPath(storageID, sMediaSDKPath))
+    {
         return MFX_ERR_UNSUPPORTED;
     }
 
-    return InitFolder(implType, implInterface, adapterNum, sCurrentModulePath);
+    return InitFolder(implType, sMediaSDKPath, storageID);
 
 } // mfxStatus MFXLibraryIterator::Init(eMfxImplType implType, const mfxU32 adapterNum, int storageID)
 
-mfxStatus MFXLibraryIterator::InitRegistry(eMfxImplType implType, mfxIMPL implInterface, const mfxU32 adapterNum, int storageID)
+mfxStatus MFXLibraryIterator::InitRegistry(int storageID)
 {
-#if defined(MEDIASDK_USE_REGISTRY) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
+#if !defined(MEDIASDK_UWP_DISPATCHER)
     HKEY rootHKey;
     bool bRes;
 
@@ -270,22 +289,6 @@ mfxStatus MFXLibraryIterator::InitRegistry(eMfxImplType implType, mfxIMPL implIn
             return MFX_ERR_UNKNOWN;
     }
 
-    // set the required library's implementation type
-    m_implType = implType;
-    m_implInterface = implInterface != 0
-        ? implInterface
-        : MFX_IMPL_VIA_ANY;
-
-    //deviceID and vendorID are not actual for SW library loading
-    if (m_implType != MFX_LIB_SOFTWARE)
-    {
-        mfxStatus mfxRes = MFX::SelectImplementationType(adapterNum, &m_implInterface, &m_vendorID, &m_deviceID);
-        if (MFX_ERR_NONE != mfxRes)
-        {
-            return mfxRes;
-        }
-    }
-
     DISPATCHER_LOG_INFO((("Inspecting %s\\%S\n"),
         (MFX_LOCAL_MACHINE_KEY == storageID) ? ("HKEY_LOCAL_MACHINE") : ("HKEY_CURRENT_USER"),
         rootDispPath))
@@ -293,45 +296,53 @@ mfxStatus MFXLibraryIterator::InitRegistry(eMfxImplType implType, mfxIMPL implIn
     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)
+#endif // #if !defined(MEDIASDK_UWP_DISPATCHER)
 
-} // mfxStatus MFXLibraryIterator::InitRegistry(eMfxImplType implType, mfxIMPL implInterface, const mfxU32 adapterNum, int storageID)
+} // mfxStatus MFXLibraryIterator::InitRegistry(int storageID)
 
-mfxStatus MFXLibraryIterator::InitFolder(eMfxImplType implType, mfxIMPL implInterface, const mfxU32 adapterNum, const msdk_disp_char * path)
+#if defined(MFX_TRACER_WA_FOR_DS)
+mfxStatus MFXLibraryIterator::InitRegistryTracer()
 {
-     const int maxPathLen = sizeof(m_path)/sizeof(m_path[0]);
-     m_path[0] = 0;
-     msdk_disp_char_cpy_s(m_path, maxPathLen, path);
-     size_t pathLen = wcslen(m_path);
+#if !defined(MEDIASDK_UWP_DISPATCHER)
+
+    const wchar_t tracerRegKeyPath[] = L"Software\\Intel\\MediaSDK\\Dispatch\\tracer";
+
+    if (!m_baseRegKey.Open(HKEY_LOCAL_MACHINE, tracerRegKeyPath, KEY_READ) && !m_baseRegKey.Open(HKEY_CURRENT_USER, tracerRegKeyPath, KEY_READ))
+    {
+        DISPATCHER_LOG_WRN(("can't find tracer registry key\n"))
+        return MFX_ERR_UNKNOWN;
+    }
+
+    DISPATCHER_LOG_INFO(("found tracer registry key\n"))
+    return MFX_ERR_NONE;
 
-#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, msdk_disp_path_len - pathLen,  MFX_LIB_SOFTWARE);
 #else
-     mfx_get_default_dll_name(m_path + pathLen, msdk_disp_path_len - pathLen, implType);
+    return MFX_ERR_UNSUPPORTED;
+#endif // #if !defined(MEDIASDK_UWP_DISPATCHER)
+
+} // mfxStatus MFXLibraryIterator::InitRegistryTracer()
 #endif
 
-     // set the required library's implementation type
-     m_implType = implType;
-     m_implInterface = implInterface != 0
-         ? implInterface
-         : MFX_IMPL_VIA_ANY;
+mfxStatus MFXLibraryIterator::InitFolder(eMfxImplType implType, const wchar_t * path, const int storageID)
+{
+     const int maxPathLen = sizeof(m_path)/sizeof(m_path[0]);
+     m_path[0] = 0;
+     wcscpy_s(m_path, maxPathLen, path);
+     size_t pathLen = wcslen(m_path);
 
-     //deviceID and vendorID are not actual for SW library loading
-     if (m_implType != MFX_LIB_SOFTWARE)
+     if(storageID==MFX_APP_FOLDER)
+     {
+         // we looking for runtime in application folder, it should be named libmfxsw64 or libmfxsw32
+         mfx_get_default_dll_name(m_path + pathLen, msdk_disp_path_len - pathLen,  MFX_LIB_SOFTWARE);
+     }
+     else
      {
-         mfxStatus mfxRes = MFX::SelectImplementationType(adapterNum, &m_implInterface, &m_vendorID, &m_deviceID);
-         if (MFX_ERR_NONE != mfxRes)
-         {
-             return mfxRes;
-         }
+         mfx_get_default_dll_name(m_path + pathLen, msdk_disp_path_len - pathLen, implType);
      }
+
      return MFX_ERR_NONE;
-} // mfxStatus MFXLibraryIterator::InitFolder(eMfxImplType implType, mfxIMPL implInterface, const mfxU32 adapterNum, const msdk_disp_char * path)
+} // mfxStatus MFXLibraryIterator::InitFolder(eMfxImplType implType, const wchar_t * path, const int storageID)
 
 mfxStatus MFXLibraryIterator::SelectDLLVersion(wchar_t *pPath
                                              , size_t pathSize
@@ -347,30 +358,48 @@ mfxStatus MFXLibraryIterator::SelectDLLVersion(wchar_t *pPath
             return MFX_ERR_UNKNOWN;
 
         m_lastLibIndex = 1;
-        msdk_disp_char_cpy_s(pPath, pathSize, m_path);
+        wcscpy_s(pPath, pathSize, m_path);
         *pImplType = MFX_LIB_SOFTWARE;
         return MFX_ERR_NONE;
     }
 
-#if defined(MEDIASDK_UWP_LOADER) || defined(MEDIASDK_UWP_PROCTABLE)
-
-    if (m_StorageID == MFX_PATH_MSDK_FOLDER) {
-
+    if (m_StorageID == MFX_PATH_MSDK_FOLDER || m_StorageID == MFX_DRIVER_STORE)
+    {
         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);
+        wcscpy_s(pPath, pathSize, m_path);
         // do not change impl type
-        //*pImplType = MFX_LIB_HARDWARE;
         return MFX_ERR_NONE;
     }
 
+#if !defined(MEDIASDK_UWP_DISPATCHER)
+
+#if defined(MFX_TRACER_WA_FOR_DS)
+    if (m_StorageID == MFX_TRACER)
+    {
+        if (m_lastLibIndex != 0)
+            return MFX_ERR_NOT_FOUND;
+        if (m_vendorID != INTEL_VENDOR_ID)
+            return MFX_ERR_UNKNOWN;
+
+        m_lastLibIndex = 1;
+
+        if (m_baseRegKey.Query(pathKeyName, REG_SZ, (LPBYTE)pPath, (DWORD*)&pathSize))
+        {
+            DISPATCHER_LOG_INFO((("loaded %S : %S\n"), pathKeyName, pPath));
+        }
+        else
+        {
+            DISPATCHER_LOG_WRN((("error querying %S : RegQueryValueExA()==0x%x\n"), pathKeyName, GetLastError()));
+        }
+        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;
@@ -503,8 +532,8 @@ mfxStatus MFXLibraryIterator::SelectDLLVersion(wchar_t *pPath
                         {
                             DISPATCHER_LOG_INFO((("loaded %S : %S\n"), pathKeyName, tmpPath));
 
-                            msdk_disp_char_cpy_s(libPath, sizeof(libPath) / sizeof(libPath[0]), tmpPath);
-                            msdk_disp_char_cpy_s(m_SubKeyName, sizeof(m_SubKeyName) / sizeof(m_SubKeyName[0]), subKeyName);
+                            wcscpy_s(libPath, sizeof(libPath) / sizeof(libPath[0]), tmpPath);
+                            wcscpy_s(m_SubKeyName, sizeof(m_SubKeyName) / sizeof(m_SubKeyName[0]), subKeyName);
 
                             libMerit = merit;
                             libIndex = index;
@@ -538,7 +567,7 @@ mfxStatus MFXLibraryIterator::SelectDLLVersion(wchar_t *pPath
         return MFX_ERR_NOT_FOUND;
     }
 
-    msdk_disp_char_cpy_s(pPath, pathSize, libPath);
+    wcscpy_s(pPath, pathSize, libPath);
 
     m_lastLibIndex = libIndex;
     m_lastLibMerit = libMerit;
@@ -555,11 +584,9 @@ mfxIMPL MFXLibraryIterator::GetImplementationType()
     return m_implInterface;
 } // mfxIMPL MFXLibraryIterator::GetImplementationType()
 
-bool MFXLibraryIterator::GetSubKeyName(msdk_disp_char *subKeyName, size_t length) const
+bool MFXLibraryIterator::GetSubKeyName(wchar_t *subKeyName, size_t length) const
 {
-    msdk_disp_char_cpy_s(subKeyName, length, m_SubKeyName);
+    wcscpy_s(subKeyName, length, m_SubKeyName);
     return m_bIsSubKeyValid;
 }
 } // namespace MFX
-#endif // #if defined(_WIN32) || defined(_WIN64)
-

+ 65 - 83
plugins/obs-qsv11/libmfx/src/mfx_load_dll.cpp

@@ -1,34 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_load_dll.cpp
-
-\* ****************************************************************************** */
-
-#if defined(_WIN32) || defined(_WIN64)
+// Copyright (c) 2012-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #include "mfx_dispatcher.h"
 #include "mfx_load_dll.h"
@@ -37,8 +25,6 @@ File Name: mfx_load_dll.cpp
 #include <string.h>
 #include <windows.h>
 
-#if !defined(_DEBUG)
-
 #if defined(_WIN64)
 const
 wchar_t * const defaultDLLName[2] = {L"libmfxhw64.dll",
@@ -51,6 +37,11 @@ const
 wchar_t  * const defaultPluginDLLName[2] = {L"mfxplugin64_hw.dll",
                                             L"mfxplugin64_sw.dll"};
 
+#if defined(MEDIASDK_UWP_DISPATCHER)
+const
+wchar_t  * const IntelGFXAPIDLLName = {L"intel_gfx_api-x64.dll"};
+#endif
+
 #elif defined(_WIN32)
 const
 wchar_t * const defaultDLLName[2] = {L"libmfxhw32.dll",
@@ -64,45 +55,18 @@ const
 wchar_t  * const defaultPluginDLLName[2] = {L"mfxplugin32_hw.dll",
                                             L"mfxplugin32_sw.dll"};
 
-#endif // (defined(_WIN64))
-
-#else // defined(_DEBUG)
-
-#if defined(_WIN64)
+#if defined(MEDIASDK_UWP_DISPATCHER)
 const
-wchar_t * const defaultDLLName[2] = {L"libmfxhw64_d.dll",
-                                     L"libmfxsw64_d.dll"};
-const
-wchar_t * const defaultAudioDLLName[2] = {L"libmfxaudiosw64_d.dll",
-                                          L"libmfxaudiosw64_d.dll"};
-
-const 
-wchar_t  * const defaultPluginDLLName[2] = {L"mfxplugin64_hw_d.dll",
-                                            L"mfxplugin64_sw_d.dll"};
-
-#elif defined(WIN32)
-const
-wchar_t * const defaultDLLName[2] = {L"libmfxhw32_d.dll",
-                                     L"libmfxsw32_d.dll"};
-
-
-const
-wchar_t * const defaultAudioDLLName[2] = {L"libmfxaudiosw32_d.dll",
-                                          L"libmfxaudiosw32_d.dll"};
-
-const 
-wchar_t  * const defaultPluginDLLName[2] = {L"mfxplugin32_hw_d.dll",
-                                            L"mfxplugin32_sw_d.dll"};
+wchar_t  * const IntelGFXAPIDLLName = {L"intel_gfx_api-x86.dll"};
+#endif
 
 #endif // (defined(_WIN64))
 
-#endif // !defined(_DEBUG)
-
 namespace MFX
 {
 
 
-mfxStatus mfx_get_default_dll_name(msdk_disp_char *pPath, size_t pathSize, eMfxImplType implType)
+mfxStatus mfx_get_default_dll_name(wchar_t *pPath, size_t pathSize, eMfxImplType implType)
 {
     if (!pPath)
     {
@@ -120,7 +84,25 @@ mfxStatus mfx_get_default_dll_name(msdk_disp_char *pPath, size_t pathSize, eMfxI
 #endif
 } // mfxStatus mfx_get_default_dll_name(wchar_t *pPath, size_t pathSize, eMfxImplType implType)
 
-mfxStatus mfx_get_default_plugin_name(msdk_disp_char *pPath, size_t pathSize, eMfxImplType implType)
+#if defined(MEDIASDK_UWP_DISPATCHER)
+mfxStatus mfx_get_default_intel_gfx_api_dll_name(wchar_t *pPath, size_t pathSize)
+{
+    if (!pPath)
+    {
+        return MFX_ERR_NULL_PTR;
+    }
+
+#if _MSC_VER >= 1400
+    return 0 == wcscpy_s(pPath, pathSize, IntelGFXAPIDLLName)
+        ? MFX_ERR_NONE : MFX_ERR_UNKNOWN;
+#else
+    wcscpy(pPath, IntelGFXAPIDLLName);
+    return MFX_ERR_NONE;
+#endif
+} // mfx_get_default_intel_gfx_api_dll_name(wchar_t *pPath, size_t pathSize)
+#endif
+
+mfxStatus mfx_get_default_plugin_name(wchar_t *pPath, size_t pathSize, eMfxImplType implType)
 {
     if (!pPath)
     {
@@ -138,7 +120,7 @@ mfxStatus mfx_get_default_plugin_name(msdk_disp_char *pPath, size_t pathSize, eM
 #endif
 }
 
-mfxStatus mfx_get_default_audio_dll_name(msdk_disp_char *pPath, size_t pathSize, eMfxImplType implType)
+mfxStatus mfx_get_default_audio_dll_name(wchar_t *pPath, size_t pathSize, eMfxImplType implType)
 {
     if (!pPath)
     {
@@ -155,7 +137,7 @@ mfxStatus mfx_get_default_audio_dll_name(msdk_disp_char *pPath, size_t pathSize,
 #endif
 } // mfxStatus mfx_get_default_audio_dll_name(wchar_t *pPath, size_t pathSize, eMfxImplType implType)
 
-mfxModuleHandle mfx_dll_load(const msdk_disp_char *pFileName)
+mfxModuleHandle mfx_dll_load(const wchar_t *pFileName)
 {
     mfxModuleHandle hModule = (mfxModuleHandle) 0;
 
@@ -164,27 +146,29 @@ mfxModuleHandle mfx_dll_load(const msdk_disp_char *pFileName)
     {
         return NULL;
     }
-#if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+#if !defined(MEDIASDK_UWP_DISPATCHER)
     // set the silent error mode
     DWORD prevErrorMode = 0;
-#if (_WIN32_WINNT >= 0x0600) && !(__GNUC__)
+#if (_WIN32_WINNT >= 0x0600)
     SetThreadErrorMode(SEM_FAILCRITICALERRORS, &prevErrorMode);
 #else
     prevErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
 #endif
-#endif // !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+#endif // !defined(MEDIASDK_UWP_DISPATCHER)
 
-        // load the library's module
-        hModule = LoadLibraryExW(pFileName, NULL, 0);
+    // load the library's module
+#if !defined(MEDIASDK_ARM_LOADER)
+    hModule = LoadLibraryExW(pFileName, NULL, 0);
+#endif
 
-#if !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
-        // set the previous error mode
-#if (_WIN32_WINNT >= 0x0600) && !(__GNUC__)
+#if !defined(MEDIASDK_UWP_DISPATCHER)
+    // set the previous error mode
+#if (_WIN32_WINNT >= 0x0600)
     SetThreadErrorMode(prevErrorMode, NULL);
 #else
     SetErrorMode(prevErrorMode);
 #endif
-#endif // !defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
+#endif // !defined(MEDIASDK_UWP_DISPATCHER)
 
     return hModule;
 
@@ -212,8 +196,8 @@ 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)
+#if !defined(MEDIASDK_UWP_DISPATCHER)
+mfxModuleHandle mfx_get_dll_handle(const wchar_t *pFileName)
 {
     mfxModuleHandle hModule = (mfxModuleHandle) 0;
 
@@ -225,7 +209,7 @@ mfxModuleHandle mfx_get_dll_handle(const msdk_disp_char *pFileName)
 
     // set the silent error mode
     DWORD prevErrorMode = 0;
-#if (_WIN32_WINNT >= 0x0600) && !(__GNUC__)
+#if (_WIN32_WINNT >= 0x0600)
     SetThreadErrorMode(SEM_FAILCRITICALERRORS, &prevErrorMode); 
 #else
     prevErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
@@ -233,16 +217,14 @@ mfxModuleHandle mfx_get_dll_handle(const msdk_disp_char *pFileName)
     // load the library's module
     GetModuleHandleExW(0, pFileName, (HMODULE*) &hModule);
     // set the previous error mode
-#if (_WIN32_WINNT >= 0x0600) && !(__GNUC__)
+#if (_WIN32_WINNT >= 0x0600)
     SetThreadErrorMode(prevErrorMode, NULL);
 #else
     SetErrorMode(prevErrorMode);
 #endif
     return hModule;
 }
-#endif //!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE)
-
+#endif //!defined(MEDIASDK_UWP_DISPATCHER)
 
 } // namespace MFX
 
-#endif // #if defined(_WIN32) || defined(_WIN64)

+ 31 - 40
plugins/obs-qsv11/libmfx/src/mfx_load_plugin.cpp

@@ -1,32 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_load_plugin.h
-
-\* ****************************************************************************** */
+// Copyright (c) 2013-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #include "mfx_load_plugin.h"
 #include "mfx_load_dll.h"
@@ -48,7 +38,7 @@ MFX::PluginModule::PluginModule(const PluginModule & that)
     : mHmodule(mfx_dll_load(that.mPath))
     , mCreatePluginPtr(that.mCreatePluginPtr)
 {
-    msdk_disp_char_cpy_s(mPath, sizeof(mPath) / sizeof(*mPath), that.mPath);
+    wcscpy_s(mPath, sizeof(mPath) / sizeof(*mPath), that.mPath);
 }
 
 MFX::PluginModule & MFX::PluginModule::operator = (const MFX::PluginModule & that)
@@ -58,20 +48,20 @@ MFX::PluginModule & MFX::PluginModule::operator = (const MFX::PluginModule & tha
         Tidy();
         mHmodule = mfx_dll_load(that.mPath);
         mCreatePluginPtr = that.mCreatePluginPtr;
-        msdk_disp_char_cpy_s(mPath, sizeof(mPath) / sizeof(*mPath), that.mPath);
+        wcscpy_s(mPath, sizeof(mPath) / sizeof(*mPath), that.mPath);
     }
     return *this;
 }
 
-MFX::PluginModule::PluginModule(const msdk_disp_char * path)
+MFX::PluginModule::PluginModule(const wchar_t * path)
     : mCreatePluginPtr()
 {
     mHmodule = mfx_dll_load(path);
     if (NULL == mHmodule) {
-        TRACE_PLUGIN_ERROR("Cannot load module: %S\n", MSDK2WIDE(path));
+        TRACE_PLUGIN_ERROR("Cannot load module: %S\n", path);
         return ;
     }
-    TRACE_PLUGIN_INFO("Plugin loaded at: %S\n", MSDK2WIDE(path));
+    TRACE_PLUGIN_INFO("Plugin loaded at: %S\n", path);
 
     mCreatePluginPtr = (CreatePluginPtr_t)mfx_dll_get_addr(mHmodule, CREATE_PLUGIN_FNC);
     if (NULL == mCreatePluginPtr) {
@@ -79,7 +69,7 @@ MFX::PluginModule::PluginModule(const msdk_disp_char * path)
         return ;
     }
 
-    msdk_disp_char_cpy_s(mPath, sizeof(mPath) / sizeof(*mPath), path);
+    wcscpy_s(mPath, sizeof(mPath) / sizeof(*mPath), path);
 }
 
 bool MFX::PluginModule::Create( mfxPluginUID uid, mfxPlugin& plg)
@@ -90,9 +80,9 @@ bool MFX::PluginModule::Create( mfxPluginUID uid, mfxPlugin& plg)
         mfxStatus mfxResult = mCreatePluginPtr(uid, &plg);
         result = (MFX_ERR_NONE == mfxResult);
         if (!result) {
-            TRACE_PLUGIN_ERROR("\"%S::%s\" returned %d\n", MSDK2WIDE(mPath), CREATE_PLUGIN_FNC, mfxResult);
+            TRACE_PLUGIN_ERROR("\"%S::%s\" returned %d\n", mPath, CREATE_PLUGIN_FNC, mfxResult);
         } else {
-            TRACE_PLUGIN_INFO("\"%S::%s\" SUCCEED\n", MSDK2WIDE(mPath), CREATE_PLUGIN_FNC);
+            TRACE_PLUGIN_INFO("\"%S::%s\" SUCCEED\n", mPath, CREATE_PLUGIN_FNC);
         }
     }
     return result;
@@ -110,7 +100,7 @@ MFX::PluginModule::~PluginModule(void)
     Tidy();
 }
 
-#if !defined(MEDIASDK_UWP_PROCTABLE)
+#if !defined(MEDIASDK_UWP_DISPATCHER)
 
 bool MFX::MFXPluginFactory::RunVerification( const mfxPlugin & plg, const PluginDescriptionRecord &dsc, mfxPluginParam &pluginParams)
 {
@@ -413,7 +403,8 @@ MFX::MFXPluginFactory::~MFXPluginFactory()
     Close();
 }
 
-MFX::MFXPluginFactory::MFXPluginFactory( mfxSession session )
+MFX::MFXPluginFactory::MFXPluginFactory( mfxSession session ) :
+    mPlugins()
 {
     mSession = session;
     nPlugins = 0;
@@ -460,4 +451,4 @@ void MFX::MFXPluginFactory::DestroyPlugin( FactoryRecord & record)
     }
 }
 
-#endif //!defined(MEDIASDK_UWP_PROCTABLE)
+#endif //!defined(MEDIASDK_UWP_DISPATCHER)

+ 96 - 115
plugins/obs-qsv11/libmfx/src/mfx_plugin_hive.cpp

@@ -1,34 +1,22 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_plugin_hive.cpp
-
-\* ****************************************************************************** */
-
-#if defined(_WIN32) || defined(_WIN64)
+// Copyright (c) 2013-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
 
 #include "mfx_plugin_hive.h"
 #include "mfx_library_iterator.h"
@@ -40,7 +28,7 @@ File Name: mfx_plugin_hive.cpp
 #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 
+namespace
 {
     const wchar_t rootPluginPath[] = L"Software\\Intel\\MediaSDK\\Plugin";
     const wchar_t rootDispatchPath[] = L"Software\\Intel\\MediaSDK\\Dispatch";
@@ -54,7 +42,7 @@ namespace
     const wchar_t APIVerKeyName[] = L"APIVersion";
 }
 
-namespace 
+namespace
 {
 #ifdef _WIN64
     const wchar_t pluginFileName[] = L"FileName64";
@@ -71,7 +59,7 @@ namespace
     const mfxU32 defaultPluginNameLen = 25;
     const mfxU32 charsPermfxU8 = 2;
     const mfxU32 slashLen = 1;
-    enum 
+    enum
     {
         MAX_PLUGIN_FILE_LINE = 4096
     };
@@ -79,10 +67,11 @@ namespace
     #define alignStr() "%-14S"
 }
 
-MFX::MFXPluginsInHive::MFXPluginsInHive(int mfxStorageID, const msdk_disp_char *msdkLibSubKey, mfxVersion currentAPIVersion)
+#if !defined(MEDIASDK_UWP_DISPATCHER)
+
+MFX::MFXPluginsInHive::MFXPluginsInHive(int mfxStorageID, const wchar_t *msdkLibSubKey, mfxVersion currentAPIVersion)
     : MFXPluginStorageBase(currentAPIVersion)
 {
-#if defined(MEDIASDK_USE_REGISTRY) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
     HKEY rootHKey;
     bool bRes;
     WinRegKey regKey;
@@ -104,7 +93,7 @@ MFX::MFXPluginsInHive::MFXPluginsInHive(int mfxStorageID, const msdk_disp_char *
             bRes = regKey.Open(regKey, pluginSubkey, KEY_READ);
         }
     }
-    else 
+    else
     {
         bRes = regKey.Open(rootHKey, rootPluginPath, KEY_READ);
     }
@@ -116,7 +105,7 @@ MFX::MFXPluginsInHive::MFXPluginsInHive(int mfxStorageID, const msdk_disp_char *
     if (!regKey.QueryInfo(&index)) {
         return;
     }
-    try 
+    try
     {
         resize(index);
     }
@@ -125,7 +114,7 @@ MFX::MFXPluginsInHive::MFXPluginsInHive(int mfxStorageID, const msdk_disp_char *
         return;
     }
 
-    for(index = 0; ; index++) 
+    for(index = 0; ; index++)
     {
         wchar_t   subKeyName[MFX_MAX_REGISTRY_KEY_NAME];
         DWORD     subKeyNameSize = sizeof(subKeyName) / sizeof(subKeyName[0]);
@@ -143,12 +132,12 @@ MFX::MFXPluginsInHive::MFXPluginsInHive(int mfxStorageID, const msdk_disp_char *
             continue;
         }
 
-        if (msdkLibSubKey) 
+        if (msdkLibSubKey)
         {
             TRACE_HIVE_INFO("Found Plugin: %s\\%S\\%S\\%S\\%S\n", (MFX_LOCAL_MACHINE_KEY == mfxStorageID) ? ("HKEY_LOCAL_MACHINE") : ("HKEY_CURRENT_USER"),
                 rootDispatchPath, msdkLibSubKey, pluginSubkey, subKeyName);
         }
-        else 
+        else
         {
             TRACE_HIVE_INFO("Found Plugin: %s\\%S\\%S\n", (MFX_LOCAL_MACHINE_KEY == mfxStorageID) ? ("HKEY_LOCAL_MACHINE") : ("HKEY_CURRENT_USER"),
                 rootPluginPath, subKeyName);
@@ -156,66 +145,66 @@ MFX::MFXPluginsInHive::MFXPluginsInHive(int mfxStorageID, const msdk_disp_char *
 
         PluginDescriptionRecord descriptionRecord;
 
-        if (!QueryKey(subKey, TypeKeyName, descriptionRecord.Type)) 
+        if (!QueryKey(subKey, TypeKeyName, descriptionRecord.Type))
         {
             continue;
         }
         TRACE_HIVE_INFO(alignStr()" : %d\n", TypeKeyName, descriptionRecord.Type);
 
-        if (QueryKey(subKey, CodecIDKeyName, descriptionRecord.CodecId)) 
+        if (QueryKey(subKey, CodecIDKeyName, descriptionRecord.CodecId))
         {
-            TRACE_HIVE_INFO(alignStr()" : "MFXFOURCCTYPE()" \n", CodecIDKeyName, MFXU32TOFOURCC(descriptionRecord.CodecId));
+            TRACE_HIVE_INFO(alignStr()" : " MFXFOURCCTYPE()" \n", CodecIDKeyName, MFXU32TOFOURCC(descriptionRecord.CodecId));
         }
         else
         {
                 TRACE_HIVE_INFO(alignStr()" : \n", CodecIDKeyName, "NOT REGISTERED");
         }
 
-        if (!QueryKey(subKey, GUIDKeyName, descriptionRecord.PluginUID)) 
+        if (!QueryKey(subKey, GUIDKeyName, descriptionRecord.PluginUID))
         {
             continue;
         }
-        TRACE_HIVE_INFO(alignStr()" : "MFXGUIDTYPE()"\n", GUIDKeyName, MFXGUIDTOHEX(&descriptionRecord.PluginUID));
+        TRACE_HIVE_INFO(alignStr()" : " MFXGUIDTYPE()"\n", GUIDKeyName, MFXGUIDTOHEX(&descriptionRecord.PluginUID));
 
         mfxU32 nSize = sizeof(descriptionRecord.sPath)/sizeof(*descriptionRecord.sPath);
-        if (!subKey.Query(PathKeyName, descriptionRecord.sPath, nSize)) 
+        if (!subKey.Query(PathKeyName, descriptionRecord.sPath, nSize))
         {
             TRACE_HIVE_WRN("no value for : %S\n", PathKeyName);
             continue;
         }
         TRACE_HIVE_INFO(alignStr()" : %S\n", PathKeyName, descriptionRecord.sPath);
 
-        if (!QueryKey(subKey, DefaultKeyName, descriptionRecord.Default)) 
+        if (!QueryKey(subKey, DefaultKeyName, descriptionRecord.Default))
         {
             continue;
         }
         TRACE_HIVE_INFO(alignStr()" : %s\n", DefaultKeyName, descriptionRecord.Default ? "true" : "false");
 
-        mfxU32 version;
-        if (!QueryKey(subKey, PlgVerKeyName, version)) 
+        mfxU32 version = 0;
+        if (!QueryKey(subKey, PlgVerKeyName, version))
         {
             continue;
         }
         descriptionRecord.PluginVersion = static_cast<mfxU16>(version);
-        if (0 == version) 
+        if (0 == version)
         {
             TRACE_HIVE_ERROR(alignStr()" : %d, which is invalid\n", PlgVerKeyName, descriptionRecord.PluginVersion);
             continue;
-        } 
-        else 
-        { 
+        }
+        else
+        {
             TRACE_HIVE_INFO(alignStr()" : %d\n", PlgVerKeyName, descriptionRecord.PluginVersion);
         }
 
-        mfxU32 APIVersion;
-        if (!QueryKey(subKey, APIVerKeyName, APIVersion)) 
+        mfxU32 APIVersion = 0;
+        if (!QueryKey(subKey, APIVerKeyName, APIVersion))
         {
             continue;
         }
         ConvertAPIVersion(APIVersion, descriptionRecord);
         TRACE_HIVE_INFO(alignStr()" : %d.%d \n", APIVerKeyName, descriptionRecord.APIVersion.Major, descriptionRecord.APIVersion.Minor);
 
-        try 
+        try
         {
             operator[](index) = descriptionRecord;
         }
@@ -223,56 +212,48 @@ 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 ) 
+MFX::MFXPluginsInFS::MFXPluginsInFS( mfxVersion currentAPIVersion )
     : MFXPluginStorageBase(currentAPIVersion)
     , mIsVersionParsed()
     , mIsAPIVersionParsed()
 {
     WIN32_FIND_DATAW find_data;
-    msdk_disp_char currentModuleName[MAX_PLUGIN_PATH];
-    
+    wchar_t currentModuleName[MAX_PLUGIN_PATH];
+
     GetModuleFileNameW(NULL, currentModuleName, MAX_PLUGIN_PATH);
-    if (GetLastError() != 0) 
+    if (GetLastError() != 0)
     {
         TRACE_HIVE_ERROR("GetModuleFileName() reported an error: %d\n", GetLastError());
         return;
     }
-    msdk_disp_char *lastSlashPos = wcsrchr(currentModuleName, L'\\');
+    wchar_t *lastSlashPos = wcsrchr(currentModuleName, L'\\');
     if (!lastSlashPos) {
         lastSlashPos = currentModuleName;
     }
     mfxU32 executableDirLen = (mfxU32)(lastSlashPos - currentModuleName) + slashLen;
-    if (executableDirLen + pluginDirNameLen + pluginCfgFileNameLen >= MAX_PLUGIN_PATH) 
+    if (executableDirLen + pluginDirNameLen + pluginCfgFileNameLen >= MAX_PLUGIN_PATH)
     {
         TRACE_HIVE_ERROR("MAX_PLUGIN_PATH which is %d, not enough to locate plugin path\n", MAX_PLUGIN_PATH);
         return;
     }
-    msdk_disp_char_cpy_s(lastSlashPos + slashLen
+    wcscpy_s(lastSlashPos + slashLen
         , MAX_PLUGIN_PATH - executableDirLen, pluginSearchPattern);
 
     HANDLE fileFirst = FindFirstFileW(currentModuleName, &find_data);
-    if (INVALID_HANDLE_VALUE == fileFirst) 
+    if (INVALID_HANDLE_VALUE == fileFirst)
     {
         TRACE_HIVE_ERROR("FindFirstFileW() unable to locate any plugins folders\n", 0);
         return;
     }
-    do 
+    do
     {
-        if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) 
+        if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
         {
             continue;
         }
-        if (pluginDirNameLen != wcslen(find_data.cFileName)) 
+        if (pluginDirNameLen != wcslen(find_data.cFileName))
         {
             continue;
         }
@@ -282,10 +263,10 @@ MFX::MFXPluginsInFS::MFXPluginsInFS( mfxVersion currentAPIVersion )
         descriptionRecord.onlyVersionRegistered = true;
 
         mfxU32 i = 0;
-        for(i = 0; i != pluginDirNameLen / charsPermfxU8; i++) 
+        for(i = 0; i != pluginDirNameLen / charsPermfxU8; i++)
         {
             mfxU32 hexNum = 0;
-            if (1 != swscanf_s(find_data.cFileName + charsPermfxU8 * i, L"%2x", &hexNum)) 
+            if (1 != swscanf_s(find_data.cFileName + charsPermfxU8 * i, L"%2x", &hexNum))
             {
                 // it is ok to have non-plugin subdirs with length 32
                 //TRACE_HIVE_INFO("folder name \"%S\" is not a valid GUID string\n", find_data.cFileName);
@@ -303,37 +284,37 @@ MFX::MFXPluginsInFS::MFXPluginsInFS( mfxVersion currentAPIVersion )
             continue;
         }
 
-        msdk_disp_char_cpy_s(currentModuleName + executableDirLen
+        wcscpy_s(currentModuleName + executableDirLen
             , MAX_PLUGIN_PATH - executableDirLen, find_data.cFileName);
 
-        msdk_disp_char_cpy_s(currentModuleName + executableDirLen + pluginDirNameLen
+        wcscpy_s(currentModuleName + executableDirLen + pluginDirNameLen
             , MAX_PLUGIN_PATH - executableDirLen - pluginDirNameLen, L"\\");
 
         //this is path to plugin directory
-        msdk_disp_char_cpy_s(descriptionRecord.sPath
+        wcscpy_s(descriptionRecord.sPath
             , sizeof(descriptionRecord.sPath) / sizeof(*descriptionRecord.sPath), currentModuleName);
-        
-        msdk_disp_char_cpy_s(currentModuleName + executableDirLen + pluginDirNameLen + slashLen
+
+        wcscpy_s(currentModuleName + executableDirLen + pluginDirNameLen + slashLen
             , MAX_PLUGIN_PATH - executableDirLen - pluginDirNameLen - slashLen, pluginCfgFileName);
 
         FILE *pluginCfgFile = 0;
         _wfopen_s(&pluginCfgFile, currentModuleName, L"r");
-        if (!pluginCfgFile) 
+        if (!pluginCfgFile)
         {
             TRACE_HIVE_INFO("in directory \"%S\" no mandatory \"%S\"\n"
                 , find_data.cFileName, pluginCfgFileName);
             continue;
         }
-        
-        if (ParseFile(pluginCfgFile, descriptionRecord)) 
+
+        if (ParseFile(pluginCfgFile, descriptionRecord))
         {
-            try 
+            try
             {
                 push_back(descriptionRecord);
             }
             catch (...) {
                 TRACE_HIVE_ERROR("mRecords.push_back(descriptionRecord); - threw exception \n", 0);
-            }            
+            }
         }
 
         fclose(pluginCfgFile);
@@ -341,26 +322,26 @@ MFX::MFXPluginsInFS::MFXPluginsInFS( mfxVersion currentAPIVersion )
     FindClose(fileFirst);
 }
 
-bool MFX::MFXPluginsInFS::ParseFile(FILE * f, PluginDescriptionRecord & descriptionRecord) 
+bool MFX::MFXPluginsInFS::ParseFile(FILE * f, PluginDescriptionRecord & descriptionRecord)
 {
-    msdk_disp_char line[MAX_PLUGIN_FILE_LINE];
-    
+    wchar_t line[MAX_PLUGIN_FILE_LINE];
+
     while(NULL != fgetws(line, sizeof(line) / sizeof(*line), f))
     {
-        msdk_disp_char *delimiter = wcschr(line, L'=');
-        if (0 == delimiter) 
+        wchar_t *delimiter = wcschr(line, L'=');
+        if (0 == delimiter)
         {
             TRACE_HIVE_INFO("plugin.cfg contains line \"%S\" which is not in K=V format, skipping \n", line);
             continue;
         }
         *delimiter = 0;
-        if (!ParseKVPair(line, delimiter + 1, descriptionRecord)) 
+        if (!ParseKVPair(line, delimiter + 1, descriptionRecord))
         {
             return false;
         }
     }
 
-    if (!mIsVersionParsed) 
+    if (!mIsVersionParsed)
     {
         TRACE_HIVE_ERROR("%S : Mandatory  key %S not found\n", pluginCfgFileName, PlgVerKeyName);
         return false;
@@ -372,7 +353,7 @@ bool MFX::MFXPluginsInFS::ParseFile(FILE * f, PluginDescriptionRecord & descript
         return false;
     }
 
-    if (!wcslen(descriptionRecord.sPath)) 
+    if (!wcslen(descriptionRecord.sPath))
     {
         TRACE_HIVE_ERROR("%S : Mandatory  key %S not found\n", pluginCfgFileName, pluginFileName);
         return false;
@@ -381,18 +362,18 @@ bool MFX::MFXPluginsInFS::ParseFile(FILE * f, PluginDescriptionRecord & descript
     return true;
 }
 
-bool MFX::MFXPluginsInFS::ParseKVPair( msdk_disp_char * key, msdk_disp_char* value, PluginDescriptionRecord & descriptionRecord)
+bool MFX::MFXPluginsInFS::ParseKVPair( wchar_t * key, wchar_t* value, PluginDescriptionRecord & descriptionRecord)
 {
     if (0 != wcsstr(key, PlgVerKeyName))
     {
         mfxU32 version ;
-        if (0 == swscanf_s(value, L"%d", &version)) 
+        if (0 == swscanf_s(value, L"%d", &version))
         {
             return false;
         }
         descriptionRecord.PluginVersion = (mfxU16)version;
-        
-        if (0 == descriptionRecord.PluginVersion) 
+
+        if (0 == descriptionRecord.PluginVersion)
         {
             TRACE_HIVE_ERROR("%S: %S = %d,  which is invalid\n", pluginCfgFileName, PlgVerKeyName, descriptionRecord.PluginVersion);
             return false;
@@ -406,7 +387,7 @@ bool MFX::MFXPluginsInFS::ParseKVPair( msdk_disp_char * key, msdk_disp_char* val
     if (0 != wcsstr(key, APIVerKeyName))
     {
         mfxU32 APIversion;
-        if (0 == swscanf_s(value, L"%d", &APIversion)) 
+        if (0 == swscanf_s(value, L"%d", &APIversion))
         {
             return false;
         }
@@ -421,15 +402,15 @@ bool MFX::MFXPluginsInFS::ParseKVPair( msdk_disp_char * key, msdk_disp_char* val
 
     if (0!=wcsstr(key, pluginFileName))
     {
-        msdk_disp_char *startQuoteMark = wcschr(value, L'\"');
+        wchar_t *startQuoteMark = wcschr(value, L'\"');
         if (!startQuoteMark)
         {
             TRACE_HIVE_ERROR("plugin filename not in quotes : %S\n", value);
             return false;
         }
-        msdk_disp_char *endQuoteMark = wcschr(startQuoteMark + 1, L'\"');
+        wchar_t *endQuoteMark = wcschr(startQuoteMark + 1, L'\"');
 
-        if (!endQuoteMark) 
+        if (!endQuoteMark)
         {
             TRACE_HIVE_ERROR("plugin filename not in quotes : %S\n", value);
             return false;
@@ -445,42 +426,43 @@ bool MFX::MFXPluginsInFS::ParseKVPair( msdk_disp_char * key, msdk_disp_char* val
         }
 
         size_t restrictedCharIdx = wcscspn(startQuoteMark + 1, pluginFileNameRestrictedCharacters);
-        if (restrictedCharIdx != wcslen(startQuoteMark + 1)) 
+        if (restrictedCharIdx != wcslen(startQuoteMark + 1))
         {
             TRACE_HIVE_ERROR("plugin filename :%S, contains one of restricted characters: %S\n", startQuoteMark + 1, pluginFileNameRestrictedCharacters);
             return false;
         }
 
-        msdk_disp_char_cpy_s(descriptionRecord.sPath + currentPathLen
+        wcscpy_s(descriptionRecord.sPath + currentPathLen
             , sizeof(descriptionRecord.sPath) / sizeof(*descriptionRecord.sPath) - currentPathLen, startQuoteMark + 1);
 
         TRACE_HIVE_INFO("%S: %S = \"%S\" \n", pluginCfgFileName, pluginFileName, startQuoteMark + 1);
-     
+
         return true;
     }
-   
+
 
     return true;
 }
-#endif //#if defined(MEDIASDK_USE_CFGFILES) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
+
+#endif //#if !defined(MEDIASDK_UWP_DISPATCHER)
 
 MFX::MFXDefaultPlugins::MFXDefaultPlugins(mfxVersion currentAPIVersion, MFX_DISP_HANDLE * hdl, int implType)
     : MFXPluginStorageBase(currentAPIVersion)
 {
-    msdk_disp_char libModuleName[MAX_PLUGIN_PATH];
+    wchar_t libModuleName[MAX_PLUGIN_PATH];
 
     GetModuleFileNameW((HMODULE)hdl->hModule, libModuleName, MAX_PLUGIN_PATH);
-    if (GetLastError() != 0) 
+    if (GetLastError() != 0)
     {
         TRACE_HIVE_ERROR("GetModuleFileName() reported an error: %d\n", GetLastError());
         return;
     }
-    msdk_disp_char *lastSlashPos = wcsrchr(libModuleName, L'\\');
+    wchar_t *lastSlashPos = wcsrchr(libModuleName, L'\\');
     if (!lastSlashPos) {
         lastSlashPos = libModuleName;
     }
     mfxU32 executableDirLen = (mfxU32)(lastSlashPos - libModuleName) + slashLen;
-    if (executableDirLen + defaultPluginNameLen >= MAX_PLUGIN_PATH) 
+    if (executableDirLen + defaultPluginNameLen >= MAX_PLUGIN_PATH)
     {
         TRACE_HIVE_ERROR("MAX_PLUGIN_PATH which is %d, not enough to locate default plugin path\n", MAX_PLUGIN_PATH);
         return;
@@ -495,7 +477,7 @@ MFX::MFXDefaultPlugins::MFXDefaultPlugins(mfxVersion currentAPIVersion, MFX_DISP
         descriptionRecord.APIVersion = currentAPIVersion;
         descriptionRecord.Default = true;
 
-        msdk_disp_char_cpy_s(descriptionRecord.sPath
+        wcscpy_s(descriptionRecord.sPath
             , sizeof(descriptionRecord.sPath) / sizeof(*descriptionRecord.sPath), libModuleName);
 
         push_back(descriptionRecord);
@@ -507,4 +489,3 @@ MFX::MFXDefaultPlugins::MFXDefaultPlugins(mfxVersion currentAPIVersion, MFX_DISP
 }
 
 
-#endif

+ 22 - 33
plugins/obs-qsv11/libmfx/src/mfx_win_reg_key.cpp

@@ -1,35 +1,24 @@
-/* ****************************************************************************** *\
-
-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:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-- Neither the name of Intel Corporation nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-File Name: mfx_win_reg_key.cpp
-
-\* ****************************************************************************** */
-
-#if defined(_WIN32) || defined(_WIN64)
-
+// Copyright (c) 2012-2019 Intel Corporation
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#if !defined(MEDIASDK_UWP_DISPATCHER)
 #include "mfx_win_reg_key.h"
 #include "mfx_dispatcher_log.h"
 
@@ -225,4 +214,4 @@ bool WinRegKey::QueryInfo(LPDWORD lpcSubkeys)
 
 } // namespace MFX
 
-#endif // #if defined(_WIN32) || defined(_WIN64)
+#endif // #if !defined(MEDIASDK_UWP_DISPATCHER)

Некоторые файлы не были показаны из-за большого количества измененных файлов