gpt4 book ai didi

visual-c++ - 颜色转换器 DSP ProcessOutput 总是返回 MF_E_TRANSFORM_NEED_MORE_INPUT

转载 作者:行者123 更新时间:2023-12-03 17:52:59 25 4
gpt4 key购买 nike

我需要将视频帧从 RGB32 转换为 IYUV,但颜色转换器 MFT 拒绝处理样本。对于每一帧,我调用 IMFTransform::ProcessInput() 和 IMFTransform::ProcessOutput() 但我收到 MF_E_TRANSFORM_NEED_MORE_INPUT .如果我尝试用另一个 sample 喂给 MFT,我会得到 MF_E_NOTACCEPTING 错误。

下面我粘贴一个代码来显示我的问题。希望你们能帮上忙。

首先我创建媒体类型:

//DSP input MediaType
CHECK_HR(hr = MFCreateMediaType(&m_pInputMediaType));
CHECK_HR(hr = m_pInputMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video));
CHECK_HR(hr = m_pInputMediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_RGB32))
CHECK_HR(hr = m_pInputMediaType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive))
CHECK_HR(hr = MFSetAttributeSize(m_pInputMediaType, MF_MT_FRAME_SIZE, m_pStreamParams->StreamWidth, m_pStreamParams->StreamHeight))
CHECK_HR(hr = MFSetAttributeRatio(m_pInputMediaType, MF_MT_FRAME_RATE, m_pStreamParams->StreamFramerate, 1))
CHECK_HR(hr = MFSetAttributeRatio(m_pInputMediaType, MF_MT_PIXEL_ASPECT_RATIO, 1, 1));

//DSP output MediaType
CHECK_HR(hr = MFCreateMediaType(&m_pIntermediateMediaType));
CHECK_HR(hr = m_pIntermediateMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video));
CHECK_HR(hr = m_pIntermediateMediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_IYUV));
CHECK_HR(hr = m_pIntermediateMediaType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive));
CHECK_HR(hr = MFSetAttributeSize(m_pIntermediateMediaType, MF_MT_FRAME_SIZE, m_pStreamParams->StreamWidth, m_pStreamParams->StreamHeight));
CHECK_HR(hr = MFSetAttributeRatio(m_pIntermediateMediaType, MF_MT_FRAME_RATE, m_pStreamParams->StreamFramerate, 1));
CHECK_HR(hr = MFSetAttributeRatio(m_pIntermediateMediaType, MF_MT_PIXEL_ASPECT_RATIO, 1, 1));

然后我初始化 DSP 并设置 MediaTypes
CHECK_HR(hr = CoCreateInstance(CLSID_CColorConvertDMO, NULL, CLSCTX_ALL, IID_PPV_ARGS(&m_pColorDSP)));
CHECK_HR(hr = m_pColorDSP->SetInputType(0, m_pInputMediaType, 0));
CHECK_HR(hr = m_pColorDSP->SetOutputType(0, m_pIntermediateMediaType, 0));

还有我的帧处理方法
HRESULT LibStreaming3::WriteFrame(DWORD* videoFrameBuffer)

{
IMFSample *pRGBSample = NULL;
IMFMediaBuffer *pBuffer = NULL;


if(!m_bStreaming)
{
LOG("Failed: Not streaming!");
return E_FAIL;
}
assert(m_pStreamParams);
assert(m_pH264Encoder);
assert(m_pColorDSP);
const LONG cbWidth = 4 * m_pStreamParams->StreamWidth;
const DWORD cbBuffer = cbWidth * m_pStreamParams->StreamHeight;

BYTE *pData = NULL;

// Create a new memory buffer.
HRESULT hr = MFCreateMemoryBuffer(cbBuffer, &pBuffer);

// Lock the buffer and copy the video frame to the buffer.
if (SUCCEEDED(hr))
{
hr = pBuffer->Lock(&pData, NULL, NULL);
}
if (SUCCEEDED(hr))
{
hr = MFCopyImage(
pData, // Destination buffer.
cbWidth, // Destination stride.
(BYTE*)videoFrameBuffer, // First row in source image.
cbWidth, // Source stride.
cbWidth, // Image width in bytes.
m_pStreamParams->StreamHeight // Image height in pixels.
);
}
if (pBuffer)
{
pBuffer->Unlock();
}
do
{

// Set the data length of the buffer.
CHECK_HR(hr = pBuffer->SetCurrentLength(cbBuffer));

// Create a media sample and add the buffer to the sample.
CHECK_HR(hr = MFCreateSample(&pRGBSample));
CHECK_HR(hr = pRGBSample->AddBuffer(pBuffer));

// Set the time stamp and the duration.
CHECK_HR(hr = pRGBSample->SetSampleTime(m_rtStart));
CHECK_HR(hr = pRGBSample->SetSampleDuration(m_rtDuration));
/************************************************************************/
/* CONVERT COLORS */
/************************************************************************/

MFT_OUTPUT_DATA_BUFFER IYUVOutputDataBuffer;
IYUVOutputDataBuffer.dwStreamID = 0;
IYUVOutputDataBuffer.dwStatus = 0;
IYUVOutputDataBuffer.pEvents = NULL;
IYUVOutputDataBuffer.pSample = NULL;

DWORD dwDSPStatus = 0;
//IMFSample* pIYUVSample = NULL;
MFT_INPUT_STREAM_INFO info;
hr = m_pColorDSP->GetInputStreamInfo(0,&info );
hr = m_pColorDSP->ProcessInput(0, pRGBSample, 0); //Will provide only one sample, every next call will result in MF_E_NOTACCEPTING
hr = m_pColorDSP->ProcessOutput(0, 1, &IYUVOutputDataBuffer,&dwDSPStatus); // Always returns MF_E_TRANSFORM_NEED_MORE_INPUT


} while (false);
m_rtStart += m_rtDuration;
SafeRelease(&pRGBSample);
SafeRelease(&pBuffer);
return hr;
}

此致,
帕维尔

最佳答案

我也遇到了同样的错误,这是由于给了 ProcessInput和无效样本。它没有报告错误,而是愉快地忽略了它,因此导致了 MF_E_TRANSFORM_NEED_MORE_INPUT来自 ProcessOutput

关于visual-c++ - 颜色转换器 DSP ProcessOutput 总是返回 MF_E_TRANSFORM_NEED_MORE_INPUT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16588349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com