'Video Processor MFT interlaced output

Does anyone know if it is possible to set Video Processor MFT to interlaced output. Progressive output is working but when I try to set output media type to progressive I am getting error 0xc00d36b4 : The data specified for the media type is invalid, inconsistent, or not supported by this object. I am using Video Processor MFT for scaling, my input is interlaced e.g. PAL resolution and I need to deliver 1080i resolution interlaced.

I tried this:

hr = CoCreateInstance(CLSID_VideoProcessorMFT, nullptr, 
CLSCTX_INPROC_SERVER, IID_IMFTransform, (void\*\*)&pMFTransform);

    for (DWORD i = 0;; i++)
{
    hr = pMFTransform->GetInputAvailableType(0, i, &pInputMediaType);
    
    if(SUCCEEDED(hr))
        break;
}

// Input
// set GUID major type
hr = pInputMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
if (FAILED(hr))
{
    return hr;
}

// set GUID subtype
hr = pInputMediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_YUY2);
if (FAILED(hr))
{
    return hr;
}

hr = MFSetAttributeSize(pInputMediaType, MF_MT_FRAME_SIZE, inputFrameWidth, inputFrameHeight);
if (FAILED(hr))
{
    return hr;
}

MFVideoInterlaceMode interlacedMode;


interlacedMode = MFVideoInterlace_FieldInterleavedUpperFirst;

hr = pInputMediaType->SetUINT32(MF_MT_INTERLACE_MODE, interlacedMode);
if (FAILED(hr))
{
    return hr;
}

hr = pInputMediaType->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE);
if (FAILED(hr))
{
    return hr;
}

// Set type.
hr = pMFTransform->SetInputType(0, pInputMediaType, 0);
if (FAILED(hr))
{
    return hr;
}

for (DWORD i = 0;; i++)
{
    hr = pMFTransform->GetOutputAvailableType(0, i, &pOutputMediaType_);

    if (SUCCEEDED(hr))
        break;
}

// Output
// set GUID major type
hr = pOutputMediaType_->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
if (FAILED(hr))
{
    return hr;
}

// set GUID subtype
hr = pOutputMediaType_->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_YUY2);
if (FAILED(hr))
{
    return hr;
}

hr = MFSetAttributeSize(pOutputMediaType_, MF_MT_FRAME_SIZE, outputFrameWidth, outputFrameHeight);
if (FAILED(hr))
{
    return hr;
}

// output supports only progressive mode?
hr = pOutputMediaType_->SetUINT32(MF_MT_INTERLACE_MODE,                 MFVideoInterlace_FieldInterleavedUpperFirst);
if (FAILED(hr))
{
    return hr;
}

hr = pOutputMediaType_->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE);
if (FAILED(hr))
{
    return hr;
}

hr = pMFTransform->SetOutputType(0, pOutputMediaType_, 0);
if (FAILED(hr))
{
    return hr;
}

In this case pMFTransform->SetOutputType will fail with error 0xc00d36b4 : The data specified for the media type is invalid, inconsistent, or not supported by this object. If I change to pOutputMediaType_->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive); all is working fine. I want to try scaling to interlaced (if possible) to compare picture quality. I wonder if Video Processor MFT supports interlaced output at all.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source