I am using MediaFoundation to achieve camera capture. Since my camera supports H264 preview, I follow the instructions of the official document https://learn.microsoft.com/en-us/windows/win32/medfound/supporting-dxva-2-0-in-media-foundation to use DXVA2.0 in MediaFoundation. The following is part of my code. When compiling and linking, an error message of LNK2001 unresolved external symbol DXVA2_ModeH264_E appears. How can I solve it?
#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