|
|
@@ -56,7 +56,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
#include "QSV_Encoder_Internal.h"
|
|
|
#include "QSV_Encoder.h"
|
|
|
-#include <mfxvideo++.h>
|
|
|
+#include <vpl/mfxstructures.h>
|
|
|
+#include <vpl/mfxvideo++.h>
|
|
|
+#include <vpl/mfxdispatcher.h>
|
|
|
#include <obs-module.h>
|
|
|
|
|
|
#define do_log(level, format, ...) \
|
|
|
@@ -69,8 +71,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
mfxHDL QSV_Encoder_Internal::g_DX_Handle = NULL;
|
|
|
mfxU16 QSV_Encoder_Internal::g_numEncodersOpen = 0;
|
|
|
|
|
|
-QSV_Encoder_Internal::QSV_Encoder_Internal(mfxIMPL &impl, mfxVersion &version,
|
|
|
- bool isDGPU)
|
|
|
+QSV_Encoder_Internal::QSV_Encoder_Internal(mfxVersion &version, bool isDGPU)
|
|
|
: m_pmfxSurfaces(NULL),
|
|
|
m_pmfxENC(NULL),
|
|
|
m_nSPSBufferSize(1024),
|
|
|
@@ -82,32 +83,48 @@ QSV_Encoder_Internal::QSV_Encoder_Internal(mfxIMPL &impl, mfxVersion &version,
|
|
|
m_outBitstream(),
|
|
|
m_isDGPU(isDGPU)
|
|
|
{
|
|
|
- mfxIMPL tempImpl;
|
|
|
+ mfxVariant tempImpl;
|
|
|
mfxStatus sts;
|
|
|
|
|
|
+ mfxLoader loader = MFXLoad();
|
|
|
+ mfxConfig cfg = MFXCreateConfig(loader);
|
|
|
+
|
|
|
+ tempImpl.Type = MFX_VARIANT_TYPE_U32;
|
|
|
+ tempImpl.Data.U32 = MFX_IMPL_TYPE_HARDWARE;
|
|
|
+ MFXSetConfigFilterProperty(
|
|
|
+ cfg, (const mfxU8 *)"mfxImplDescription.Impl", tempImpl);
|
|
|
+
|
|
|
+ tempImpl.Type = MFX_VARIANT_TYPE_U32;
|
|
|
+ tempImpl.Data.U32 = INTEL_VENDOR_ID;
|
|
|
+ MFXSetConfigFilterProperty(
|
|
|
+ cfg, (const mfxU8 *)"mfxImplDescription.VendorID", tempImpl);
|
|
|
#if defined(_WIN32)
|
|
|
m_bUseD3D11 = true;
|
|
|
m_bD3D9HACK = true;
|
|
|
m_bUseTexAlloc = true;
|
|
|
|
|
|
- tempImpl = impl | MFX_IMPL_VIA_D3D11;
|
|
|
- const char *sImpl = "D3D11";
|
|
|
+ tempImpl.Type = MFX_VARIANT_TYPE_U32;
|
|
|
+ tempImpl.Data.U32 = MFX_ACCEL_MODE_VIA_D3D11;
|
|
|
+ MFXSetConfigFilterProperty(
|
|
|
+ cfg, (const mfxU8 *)"mfxImplDescription.AccelerationMode",
|
|
|
+ tempImpl);
|
|
|
#else
|
|
|
m_bUseTexAlloc = false;
|
|
|
- tempImpl = impl | MFX_IMPL_VIA_VAAPI;
|
|
|
- const char *sImpl = "VAAPI";
|
|
|
+ tempImpl.Type = MFX_VARIANT_TYPE_U32;
|
|
|
+ tempImpl.Data.U32 = MFX_ACCEL_MODE_VIA_VAAPI;
|
|
|
+ MFXSetConfigFilterProperty(
|
|
|
+ cfg, (const mfxU8 *)"mfxImplDescription.AccelerationMode",
|
|
|
+ tempImpl);
|
|
|
#endif
|
|
|
- sts = m_session.Init(tempImpl, &version);
|
|
|
+ sts = MFXCreateSession(loader, 0, &m_session);
|
|
|
if (sts == MFX_ERR_NONE) {
|
|
|
- m_session.QueryVersion(&version);
|
|
|
- m_session.Close();
|
|
|
+ MFXQueryVersion(m_session, &version);
|
|
|
+ MFXClose(m_session);
|
|
|
+ MFXUnload(loader);
|
|
|
|
|
|
- blog(LOG_INFO,
|
|
|
- "\timpl: %s\n"
|
|
|
- "\tsurf: %s",
|
|
|
- sImpl, m_bUseTexAlloc ? "Texture" : "SysMem");
|
|
|
+ blog(LOG_INFO, "\tsurf: %s",
|
|
|
+ m_bUseTexAlloc ? "Texture" : "SysMem");
|
|
|
|
|
|
- m_impl = tempImpl;
|
|
|
m_ver = version;
|
|
|
return;
|
|
|
}
|
|
|
@@ -115,16 +132,34 @@ QSV_Encoder_Internal::QSV_Encoder_Internal(mfxIMPL &impl, mfxVersion &version,
|
|
|
#if defined(_WIN32)
|
|
|
// D3D11 failed at this point.
|
|
|
m_bUseD3D11 = false;
|
|
|
- tempImpl = impl | MFX_IMPL_VIA_D3D9;
|
|
|
- sts = m_session.Init(tempImpl, &version);
|
|
|
+ loader = MFXLoad();
|
|
|
+ cfg = MFXCreateConfig(loader);
|
|
|
+
|
|
|
+ tempImpl.Type = MFX_VARIANT_TYPE_U32;
|
|
|
+ tempImpl.Data.U32 = MFX_IMPL_TYPE_HARDWARE;
|
|
|
+ MFXSetConfigFilterProperty(
|
|
|
+ cfg, (const mfxU8 *)"mfxImplDescription.Impl", tempImpl);
|
|
|
+
|
|
|
+ tempImpl.Type = MFX_VARIANT_TYPE_U32;
|
|
|
+ tempImpl.Data.U32 = INTEL_VENDOR_ID;
|
|
|
+ MFXSetConfigFilterProperty(
|
|
|
+ cfg, (const mfxU8 *)"mfxImplDescription.VendorID", tempImpl);
|
|
|
+
|
|
|
+ tempImpl.Type = MFX_VARIANT_TYPE_U32;
|
|
|
+ tempImpl.Data.U32 = MFX_ACCEL_MODE_VIA_D3D9;
|
|
|
+ MFXSetConfigFilterProperty(
|
|
|
+ cfg, (const mfxU8 *)"mfxImplDescription.AccelerationMode",
|
|
|
+ tempImpl);
|
|
|
+
|
|
|
+ sts = MFXCreateSession(loader, 0, &m_session);
|
|
|
if (sts == MFX_ERR_NONE) {
|
|
|
- m_session.QueryVersion(&version);
|
|
|
- m_session.Close();
|
|
|
+ MFXQueryVersion(m_session, &version);
|
|
|
+ MFXClose(m_session);
|
|
|
+ MFXUnload(loader);
|
|
|
|
|
|
blog(LOG_INFO, "\timpl: D3D09\n"
|
|
|
"\tsurf: SysMem");
|
|
|
|
|
|
- m_impl = tempImpl;
|
|
|
m_ver = version;
|
|
|
m_bUseD3D11 = false;
|
|
|
}
|
|
|
@@ -144,16 +179,16 @@ mfxStatus QSV_Encoder_Internal::Open(qsv_param_t *pParams, enum qsv_codec codec)
|
|
|
#if defined(_WIN32)
|
|
|
if (m_bUseD3D11)
|
|
|
// Use D3D11 surface
|
|
|
- sts = Initialize(m_impl, m_ver, &m_session, &m_mfxAllocator,
|
|
|
+ sts = Initialize(m_ver, &m_session, &m_mfxAllocator,
|
|
|
&g_DX_Handle, false, false);
|
|
|
else if (m_bD3D9HACK)
|
|
|
// Use hack
|
|
|
- sts = Initialize(m_impl, m_ver, &m_session, &m_mfxAllocator,
|
|
|
+ sts = Initialize(m_ver, &m_session, &m_mfxAllocator,
|
|
|
&g_DX_Handle, false, true);
|
|
|
else
|
|
|
- sts = Initialize(m_impl, m_ver, &m_session, NULL);
|
|
|
+ sts = Initialize(m_ver, &m_session, NULL, NULL, NULL, NULL);
|
|
|
#else
|
|
|
- sts = Initialize(m_impl, m_ver, &m_session, NULL, NULL, false, false);
|
|
|
+ sts = Initialize(m_ver, &m_session, NULL, NULL, false, false);
|
|
|
#endif
|
|
|
|
|
|
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
|
|
|
@@ -721,8 +756,8 @@ mfxStatus QSV_Encoder_Internal::Encode(uint64_t ts, uint8_t *pDataY,
|
|
|
|
|
|
while (MFX_ERR_NOT_FOUND == nTaskIdx || MFX_ERR_NOT_FOUND == nSurfIdx) {
|
|
|
// No more free tasks or surfaces, need to sync
|
|
|
- sts = m_session.SyncOperation(
|
|
|
- m_pTaskPool[m_nFirstSyncTask].syncp, 60000);
|
|
|
+ sts = MFXVideoCORE_SyncOperation(
|
|
|
+ m_session, m_pTaskPool[m_nFirstSyncTask].syncp, 60000);
|
|
|
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
|
|
|
|
|
|
mfxU8 *pTemp = m_outBitstream.Data;
|
|
|
@@ -811,8 +846,8 @@ mfxStatus QSV_Encoder_Internal::Encode_tex(uint64_t ts, uint32_t tex_handle,
|
|
|
|
|
|
while (MFX_ERR_NOT_FOUND == nTaskIdx || MFX_ERR_NOT_FOUND == nSurfIdx) {
|
|
|
// No more free tasks or surfaces, need to sync
|
|
|
- sts = m_session.SyncOperation(
|
|
|
- m_pTaskPool[m_nFirstSyncTask].syncp, 60000);
|
|
|
+ sts = MFXVideoCORE_SyncOperation(
|
|
|
+ m_session, m_pTaskPool[m_nFirstSyncTask].syncp, 60000);
|
|
|
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
|
|
|
|
|
|
mfxU8 *pTemp = m_outBitstream.Data;
|
|
|
@@ -869,8 +904,8 @@ mfxStatus QSV_Encoder_Internal::Drain()
|
|
|
mfxStatus sts = MFX_ERR_NONE;
|
|
|
|
|
|
while (m_pTaskPool && m_pTaskPool[m_nFirstSyncTask].syncp) {
|
|
|
- sts = m_session.SyncOperation(
|
|
|
- m_pTaskPool[m_nFirstSyncTask].syncp, 60000);
|
|
|
+ sts = MFXVideoCORE_SyncOperation(
|
|
|
+ m_session, m_pTaskPool[m_nFirstSyncTask].syncp, 60000);
|
|
|
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
|
|
|
|
|
|
m_pTaskPool[m_nFirstSyncTask].syncp = NULL;
|
|
|
@@ -923,7 +958,7 @@ mfxStatus QSV_Encoder_Internal::ClearData()
|
|
|
Release();
|
|
|
g_DX_Handle = NULL;
|
|
|
}
|
|
|
- m_session.Close();
|
|
|
+ MFXVideoENCODE_Close(m_session);
|
|
|
return sts;
|
|
|
}
|
|
|
|