With CopyResource, for example like CreateBmpFileFromNV12Texture function at https://github.com/wangf1978/DirectXVideoScreen/blob/47113c61aff16540744ef737b34b1f053e563010/DirectXVideoScreen/D3D11ShaderNV12/D3D11ShaderNV12.cpp#L1700
how to convert IMFMediaBuffer to ID3D11Texture2D?
mc
5,406
Reputation points
I am using IMFTransform
and there is IMFMediaBuffer that format is DXGI_Format_NV12
and I use this code:
BYTE* ppbBuffer3 = NULL;
DWORD pcbMaxLength = 0, pcbCurrentLength = 0;
buff->Lock(&ppbBuffer3, &pcbMaxLength, &pcbCurrentLength);
//buff->Unlock();
ID3D11Texture2D* texture = NULL;
D3D11_TEXTURE2D_DESC desc{};
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
desc.MiscFlags = 0;
desc.CPUAccessFlags = 0;
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_NV12;
desc.Height = height;
desc.Width = width;
desc.MipLevels = 1;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT;
auto h3 = device->CreateTexture2D(&desc, NULL, &texture);
ctx->UpdateSubresource(texture, D3D11CalcSubresource(1, 0, 1), NULL, ppbBuffer3, 7680, 0);
buff->Unlock();
and I the ID3D11Texture2D
is all black and there is nothing
why?
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,772 questions