Quantcast
Channel: Media Foundation Development for Windows Desktop forum
Viewing all articles
Browse latest Browse all 1079

How to use the MS MFT HEVC decoder after enable the HW acceleration

$
0
0

Hi all:

I'm trying to enable the HW acceleration of MS MFT HEVC decoder.

Windows 10, Intel(R) core(TM) i7-6700K CPU @ 4.00GHz, Intel(R) HD Graphics 530

Using ProcessInput and ProcessOutput, I can get every decoded frame if I don't enable the HW acceleration, but I can only get 14 decoded frames with the HW acceleration. 

HRESULT CreateDX11DevManager()
{
UINT32 dx11_dev_manager_reset_token;
HRESULT hr = MFCreateDXGIDeviceManager(&dx11_dev_manager_reset_token, &d3d11_device_manager_);

D3D_FEATURE_LEVEL feature_levels[] = {
D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_1 };
UINT flags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT;
D3D_FEATURE_LEVEL feature_level_out = D3D_FEATURE_LEVEL_11_0;
hr = D3D11CreateDevice(NULL,
D3D_DRIVER_TYPE_HARDWARE,
NULL,
flags,
feature_levels,
7,
D3D11_SDK_VERSION,
&d3d11_device_,
&feature_level_out,
NULL);

hr = d3d11_device_manager_->ResetDevice(d3d11_device_,
dx11_dev_manager_reset_token);

return hr;
}

HRESULT hr = CoCreateInstance(CLSID_CMSH265DecoderMFT, NULL, CLSCTX_INPROC_SERVER, IID_IMFTransform, (void**)&mft_);

hr = CreateDX11DevManager();
hr = mft_->ProcessMessage(MFT_MESSAGE_SET_D3D_MANAGER, (ULONG_PTR)d3d11_device_manager_);

... ...

MFT_OUTPUT_DATA_BUFFER output_data_buffer = { 0 };
HRESULT mftProcessOutput = mft_->ProcessOutput(0, 1, &output_data_buffer, &processOutputStatus);

if(mftProcessOutput == S_OK)

{
BYTE *pbBuffer;
DWORD cbMaxLength = 0, cbCurrentLength = 0;
IMFMediaBuffer *mediaBuffer = NULL;
//output_data_buffer.pSample->ConvertToContiguousBuffer(&mediaBuffer);
output_data_buffer.pSample->GetBufferByIndex(0, &mediaBuffer);
mediaBuffer->Lock(&pbBuffer, &cbMaxLength, &cbCurrentLength);
...
mediaBuffer->Unlock();
mediaBuffer->Release();
output_data_buffer.pSample->Release();

}

After I get 14 frames from ProcessOutput, the mftProcessOutput will always be 0xc00d6d72 (The transform cannot produce output until it gets more input samples), but I'm calling ProcessInput all the time.

Maybe I haven't release some resource for HW acceleration?

BTW, mediaBuffer->Lock is very slow, how can I get the pixel data more faster?

Thanks

wuchangqing


Viewing all articles
Browse latest Browse all 1079

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>