{"id":1809,"date":"2017-09-25T21:19:13","date_gmt":"2017-09-25T19:19:13","guid":{"rendered":"https:\/\/alax.info\/blog\/?p=1809"},"modified":"2017-09-25T21:19:13","modified_gmt":"2017-09-25T19:19:13","slug":"greetings-from-h-265-hevc-video-decoder-media-foundation-transform","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/1809","title":{"rendered":"Greetings from H.265 \/ HEVC Video Decoder Media Foundation Transform"},"content":{"rendered":"<p><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/mt218785\">H.265 \/ HEVC Video Decoder<\/a> Media Foundation has been around for a while, but using Media Foundation overall one step off straightforward basic paths is like walking a minefield.<\/p>\n<p>A twenty-liner below hits memory access violation inside <code>IMFTransform::GetInputStreamInfo<\/code> &#8220;Exception thrown at 0x6D1E71E7 (hevcdecoder.dll) in MfHevcDecoder01.exe: 0xC0000005: Access violation reading location 0x00000000.&#8221;:<\/p>\n<pre><code>#include \"stdafx.h\"\r\n#include &lt;mfapi.h&gt;\r\n#include &lt;mftransform.h&gt;\r\n#include &lt;wmcodecdsp.h&gt;\r\n#include &lt;atlbase.h&gt;\r\n#include &lt;atlcom.h&gt;\r\n\r\n#pragma comment(lib, \"mfplat.lib\")\r\n#pragma comment(lib, \"mfuuid.lib\")\r\n#pragma comment(lib, \"wmcodecdspuuid.lib\")\r\n\r\nint main()\r\n{\r\n    ATLVERIFY(SUCCEEDED(CoInitialize(NULL)));\r\n    ATLVERIFY(SUCCEEDED(MFStartup(MF_VERSION)));\r\n    CComPtr&lt;IMFTransform&gt; pTransform;\r\n#if 1\r\n    static const MFT_REGISTER_TYPE_INFO InputTypeInformation = { MFMediaType_Video, MFVideoFormat_HEVC };\r\n    IMFActivate** ppActivates;\r\n    UINT32 nActivateCount = 0;\r\n    ATLVERIFY(SUCCEEDED(MFTEnumEx(MFT_CATEGORY_VIDEO_DECODER, 0, &amp;InputTypeInformation, NULL, &amp;ppActivates, &amp;nActivateCount)));\r\n    ATLASSERT(nActivateCount &gt; 0);\r\n    ATLVERIFY(SUCCEEDED(ppActivates[0]-&gt;ActivateObject(__uuidof(IMFTransform), (VOID**) &amp;pTransform)));\r\n#else\r\n    ATLVERIFY(SUCCEEDED(pTransform.CoCreateInstance(CLSID_CMSH265EncoderMFT)));\r\n#endif\r\n    MFT_INPUT_STREAM_INFO InputInformation;\r\n    ATLVERIFY(SUCCEEDED(pTransform-&gt;GetInputStreamInfo(0, &amp;InputInformation)));\r\n    return 0;\r\n}\r\n<\/code><\/pre>\n<p>Interestingly, alternative path around <code>IMFActivate<\/code> (see <code>#if<\/code> above) seems to be working fine.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8220;Exception thrown at 0x6D1E71E7 (hevcdecoder.dll) in MfHevcDecoder01.exe: 0xC0000005: Access violation reading location 0x00000000.&#8221;: #include &#8220;stdafx.h&#8221; #include &lt;mfapi.h&gt;&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/1809\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[504,540,424,426,70],"class_list":["post-1809","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-h-265","tag-hevc","tag-media-foundation","tag-mft","tag-winapi"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/1809","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=1809"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/1809\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=1809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=1809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=1809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}