HEVC Decoder MFT Sample RRS feed

  • Question

  • I am trying to use H265 HEVC Video decoder with MFT as described here:


    Here is the code to create the decoder:

    CoCreateInstance(__uuidof(CMSH264DecoderMFT), NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(m_pDecoder))
    m_pInputStreamType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
    m_pInputStreamType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_HEVC_ES);
    rc = m_pDecoder->SetInputType(0, m_pInputStreamType, 0);

    It fails at the last statement, rc = 0xc00d36b4 : The data specified for the media type is invalid, inconsistent, or not supported by this object.

    I am using Window10 professional. Is there a sample to show how the decoding could be done and output to a raw buffer?

    Thursday, March 31, 2016 3:25 AM

All replies

  • You are doing H.264 CLSID CMSH264DecoderMFT with MFVideoFormat_HEVC_ES. Use proper CLSID instead: CLSID_CMSH265EncoderMFT.


    Thursday, March 31, 2016 7:51 AM
  • I could not use CLSID_CMSH265EncoderMFT as I got an link error it can't be found as externals. I used __uuidof(CMSH265EncoderMFT) instead and it compiles. But I got the error:

    0xc00d6d60 : A valid type has not been set for this stream or a stream that it depends on.

    What's going on here?

    Thursday, March 31, 2016 7:28 PM
  • You can hardcode the CLSID this way:

    class __declspec(uuid("{420A51A3-D605-430C-B4FC-45274FA6C562}")) _CLSID_CMSH265DecoderMFT;
    const CLSID& CLSID_CMSH265DecoderMFT = __uuidof(_CLSID_CMSH265DecoderMFT);
    CComPtr<IMFTransform> pTransform;

    Before writing previous post I verified that your code snippet succeeds with SetInputType.

    Apparently your trying to use encoder CLSID to initialize decoder is not going to work out well, hence the second error you got.


    Thursday, March 31, 2016 7:34 PM
  • Thanks. What's the supported output stream type? I found that P010 is available, but when I set the output type, got an error:

    m_pDecoder->GetOutputAvailableType(0, p010_index, &m_pOutputStreamType);

    m_pDecoder->SetOutputType(0, m_pOutputStreamType, 0);

    error 0xc00d36e6 : The requested attribute was not found.

    I am decoding 10 bit data so NV12 would not work I guess.

    Thursday, March 31, 2016 8:19 PM
  • They don't have it documented well (yet, hopefully), but you need to follow suggestions for H.264 ES:

    To avoid an initial format change, provide as much information in the input type as possible, including:

    Have more attributes (MF_MT_FRAME_SIZE etc) set in input media type and you will pass SetOutputType.


    Thursday, March 31, 2016 9:03 PM
  • After the above initialization, it passed SetOutputType. Then I called:

    m_pDecoder->ProcessMessage(MFT_MESSAGE_SET_D3D_MANAGER, reinterpret_cast<ULONG_PTR>(s_pDXGIManager)); m_pDecoder->ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, 0);

    MFT_OUTPUT_DATA_BUFFER mftOutputDataBuffer = { 0 };
    mftOutputDataBuffer.dwStreamID = 0;
    mftOutputDataBuffer.pSample = NULL;

    HRESULT result = m_pDecoder->ProcessOutput(0, 1, &mftOutputDataBuffer, &status);

    The result should be MF_E_TRANSFORM_NEED_MORE_INPUT but I got an error:

    E_INVALIDARG : One or more arguments are invalid. Is there a complete sample that I can refer to?

    Friday, April 1, 2016 3:42 AM
  • I am not aware of a complete sample and it does not look like Google sees anything with MFVideoFormat_HEVC_ES yet, but what you are doing does not look good for me. The MFT does not advsertise support for being able to discard output and/or provide output samples. You are responsible to provide a valid buffer in mftOutputDataBuffer.pSample. Do it and you will get your MF_E_TRANSFORM_NEED_MORE_INPUT.


    Friday, April 1, 2016 6:47 AM
  • I set the pSample now and it did pass this step. I got the MF_E_TRANSFORM_STREAM_CHANGE from ProcessOutput, I get the available output type again and set the output format to P010 again. But the subsequent ProcessOutput got an error:

    E_INVALIDARG : One or more arguments are invalid

    Not a single output frame can be gotten.

    Saturday, April 2, 2016 12:12 AM