我正在实现将在 PC 和 Hololens 2 上运行的 VP9 硬件解码器。
当我尝试加载“MSVP9DEC.dll”时,它在 PC 上运行良好,但在 Hololens 上找不到 DLL。
我已经在设备上安装了 VP9 视频扩展。
这里是截断的代码。Hololens 上的“assert(DecoderDll)”失败:
HRESULT CreateCOMObjectFromDll(HMODULE dll,
const CLSID& clsid,
const IID& iid,
void** object);
void CreateVP9Decoder()
{
#if PLATFORM_HOLOLENS
HMODULE DecoderDll = ::LoadPackagedLibrary(L"MSVP9DEC.dll", 0ul);
#else
HMODULE DecoderDll = ::LoadLibrary(L"MSVP9DEC.dll");
#endif
assert(DecoderDll);
const GUID CLSID_VpxDecoder = { 0xE3AAF548, 0xC9A4, 0x4C6E, {0x23, 0x4D, 0x5A, 0xDA, 0x37, 0x4B, 0x00, 0x00 } };
Microsoft::WRL::ComPtr<IMFTransform> VP9Decoder;
HRESULT hr = CreateCOMObjectFromDll(DecoderDll, CLSID_VpxDecoder,
IID_PPV_ARGS(&VP9Decoder));
assert(SUCCEEDED(hr));
//...
}
__pragma(warning(push))
__pragma(warning(disable: 4191))
//@See: https://chromium.googlesource.com/chromium/src/+/master/media/gpu/windows/dxva_video_decode_accelerator_win.cc
HRESULT CreateCOMObjectFromDll(HMODULE dll,
const CLSID& clsid,
const IID& iid,
void** object) {
if (!dll || !object)
return E_INVALIDARG;
using GetClassObject =
HRESULT(WINAPI*)(const CLSID& clsid, const IID& iid, void** object);
GetClassObject get_class_object = reinterpret_cast<GetClassObject>(
GetProcAddress(dll, "DllGetClassObject"));
assert(get_class_object);
TComPtr<IClassFactory> factory;
HRESULT hr = get_class_object(clsid, IID_PPV_ARGS(&factory));
assert(SUCCEEDED(hr));
hr = factory->CreateInstance(NULL, iid, object);
return hr;
}
__pragma(warning(pop))
谢谢!