我正在使用MediaFoundation来实现相机捕获。由于我的相机支持H264预览,所以我按照官方文档的说明进行操作https://learn.microsoft.com/en-us/windows/win32/medfound/supporting-dxva-2-0-in-media-foundation在MediaFoundation中使用DXVA2.0。以下是我的代码的一部分。编译链接时,出现LNK2001 unresolved external symbol DXVA2_ModeH264_E的错误消息。我该如何解决?
#include <evr.h>
#include <mfapi.h>
#include <mfidl.h>
#include <mfreadwrite.h>
#include <mferror.h>
#include <strsafe.h>
#include <ks.h>
#include <ksproxy.h>
#include <Vidcap.h>
#include <Ksmedia.h>
#include <d3d9.h>
#include <dxva2api.h>
#pragma comment(lib, "mf.lib")
#pragma comment(lib, "mfplat.lib")
#pragma comment(lib, "mfplay.lib")
#pragma comment(lib, "mfreadwrite.lib")
#pragma comment(lib, "mfuuid.lib")
#pragma comment(lib, "evr.lib")
#pragma comment(lib, "strmiids.lib")
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "dxva2.lib")
....
HANDLE pDeviceHandle = nullptr;
hr = pD3DManager->OpenDeviceHandle(&pDeviceHandle);
if (hr != S_OK)
return -1;
IDirectXVideoDecoderService *pDirectXVideoDecoderService = nullptr;
hr = pD3DManager->GetVideoService(pDeviceHandle, IID_PPV_ARGS(&pDirectXVideoDecoderService));
if (hr != S_OK)
return -1;
UINT guidCount = 0;
GUID *pGUIDs = nullptr;
hr = pDirectXVideoDecoderService->GetDecoderDeviceGuids(&guidCount, &pGUIDs);
if (hr != S_OK)
return -1;
GUID guid;
for (UINT i = 0; i < guidCount; ++i)
{
if (pGUIDs != nullptr)
{
guid = pGUIDs[i];
// DXVA2_ModeH264_VLD_Stereo_Progressive_NoFGT
// DXVA2_ModeH264_VLD_Stereo_NoFGT
// DXVA2_ModeH264_VLD_NoFGT
if (IsEqualGUID(guid, DXVA2_ModeH264_VLD_NoFGT))
break;
}
}
Severity Code Description Project File Line Suppression State Details
Error LNK2001 unresolved external symbol DXVA2_ModeH264_E DDemo D:\RHCTProject\VisualStudioPro\DDemo\mediacapture.obj 1
Severity Code Description Project File Line Suppression State Details
Error LNK1120 1 unresolved externals DDemo D:\RHCTProject\VisualStudioPro\DDemo\x64\Debug\DDemo.exe 1
在带有入口点的文件开头添加#include