本文介绍了如何从D11纹理为Intel MFT编码器创建IMFSample的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用英特尔®快速同步视频H.264编码器MFT"对视频进行编码.如果我从系统缓冲区创建IMFSample,则效果很好.就像下面这样:

I want to encode video using the "Intel® Quick Sync Video H.264 Encoder MFT".If I create IMFSample from system buffers, it works well. Just like following:

IMFMediaBuffer *pBuffer = NULL;
MFCreateMemoryBuffer(cbSize, &pBuffer);
BYTE *pData = NULL;
pBuffer->Lock(&pData, NULL, NULL);
memcpy(pData, bufferIhaveinYYYYUV format, buffer size);
pBuffer->Unlock();
IMFSample *pSample = NULL;
MFCreateSample(&pSample);
pSample->AddBuffer(pBuffer);

现在,我正在研究是否可以将ID3D11Texture2D曲面作为输入(DXGI_FORMAT_NV12,1280x720)作为输入,以提高性能.我试图将使用MFCreateVideoSampleFromSurface或MFCreateDXGISurfaceBuffer创建的IMFSample实例传递给IMFTransform :: ProcessInput并进行了多次实验(尝试使用不同的纹理创建标志),但是最好的结果是所有输入样本都被接受,但没有产生输出样本.万一有问题,我从未尝试过将数据上传到纹理上,假设这与填充垃圾像素数据的纹理没有区别.

Now I'm investigating whether I can feed it ID3D11Texture2D surfaces as input (DXGI_FORMAT_NV12, 1280x720) in order to improve performance. I tried to pass IMFSample instances created with MFCreateVideoSampleFromSurface or MFCreateDXGISurfaceBuffer to IMFTransform::ProcessInput and made multiple experiments (trying different texture creation flags), but the best result was that all input samples were accepted, but no output samples produced. In case it matters, I never actually tried uploading data to the textures, assuming this would not make a difference from textures filled with garbage pixel data.

我做错什么了吗?

推荐答案

您基本上是在重复,但仍未添加任何无效的代码.

You are basically repeating your earlier question but still without adding any code which does not work.

您可以提供正常的(内存中的)样本并使编码器工作,这一事实表明您正在做正确的一切.请注意,在Direct3D模式下,您不仅应提供Direct3D 9曲面或Direct3D 11纹理,而且还应遵守MFT的相应初始化.具体来说,纹理和MFT的内部必须属于同一Direct3D设备,因此必须在流开始之前执行必需的步骤.不仅需要调用MFCreateDXGISurfaceBuffer.

The fact that you can feed normal (in-memory) samples and have the encoder working suggest that you are doing everything about right. Note that in Direct3D mode you are supposed to not only provide Direct3D 9 surfaces or Direct3D 11 textures, but also comply with respective initialization of the MFT. Specifically, the textures and the MFT's internals have to belong to the same Direct3D device and hence the required steps before the streaming starts. It is not only MFCreateDXGISurfaceBuffer which is needed to be called.

通常,该方法在MSDN上的支持Direct3D 11 Media Foundation中的视频解码文章.同样适用于编码方案.您应该使用IMFDXGIDeviceManager指针,并且您应该使用MFT_MESSAGE_SET_D3D_MANAGER消息. MFT按照MSDN的建议运行,并切换到Direct3D 11模式,以接受携带输入帧数据的基于纹理的样本.

In general, the approach is outlined on MSDN in Supporting Direct3D 11 Video Decoding in Media Foundation article. The same equally well applies to encoding scenario. You are expected to use IMFDXGIDeviceManager pointer and you are expected to use MFT_MESSAGE_SET_D3D_MANAGER message. The MFT operates as MSDN suggests and switches to Direct3D 11 mode accepting texture based samples carrying input frame data.

这篇关于如何从D11纹理为Intel MFT编码器创建IMFSample的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 22:51