H.265 / HEVC Video Decoder Media Foundation has been around for a while, but using Media Foundation overall one step off straightforward basic paths is like walking a minefield.
A twenty-liner below hits memory access violation inside IMFTransform::GetInputStreamInfo
“Exception thrown at 0x6D1E71E7 (hevcdecoder.dll) in MfHevcDecoder01.exe: 0xC0000005: Access violation reading location 0x00000000.”:
#include "stdafx.h"
#include <mfapi.h>
#include <mftransform.h>
#include <wmcodecdsp.h>
#include <atlbase.h>
#include <atlcom.h>
#pragma comment(lib, "mfplat.lib")
#pragma comment(lib, "mfuuid.lib")
#pragma comment(lib, "wmcodecdspuuid.lib")
int main()
{
ATLVERIFY(SUCCEEDED(CoInitialize(NULL)));
ATLVERIFY(SUCCEEDED(MFStartup(MF_VERSION)));
CComPtr<IMFTransform> pTransform;
#if 1
static const MFT_REGISTER_TYPE_INFO InputTypeInformation = { MFMediaType_Video, MFVideoFormat_HEVC };
IMFActivate** ppActivates;
UINT32 nActivateCount = 0;
ATLVERIFY(SUCCEEDED(MFTEnumEx(MFT_CATEGORY_VIDEO_DECODER, 0, &InputTypeInformation, NULL, &ppActivates, &nActivateCount)));
ATLASSERT(nActivateCount > 0);
ATLVERIFY(SUCCEEDED(ppActivates[0]->ActivateObject(__uuidof(IMFTransform), (VOID**) &pTransform)));
#else
ATLVERIFY(SUCCEEDED(pTransform.CoCreateInstance(CLSID_CMSH265EncoderMFT)));
#endif
MFT_INPUT_STREAM_INFO InputInformation;
ATLVERIFY(SUCCEEDED(pTransform->GetInputStreamInfo(0, &InputInformation)));
return 0;
}
Interestingly, alternative path around IMFActivate
(see #if
above) seems to be working fine.